Skip to content

Identity policies

Identity policies define what actions users and roles are allowed or denied on specific resources. They use a JSON-based policy language with statements that specify permissions, resources, and effects. A single identity policy can be attached to multiple users and roles, making them reusable within your account.

IAM provides some built-in policies for easy management. For example, the builtin.root identity policy looks as follows:

builtin.root
{
"name": "builtin.root",
"builtin": true,
"statements": [
{
"actions": ["*"], // allows all actions across all services
"resources": ["drn:v1 *"], // allows all resources in the account
"effect": "allow",
},
],
}
Want to inspect the definition of an identity policy?

You can use the show command to inspect an identity policy. For example, to inspect the builtin.root policy, run:

Terminal window
deployport iam identity-policy show builtin.root

This policy is very permissive, so attach it carefully. A custom policy is how you restrict an identity to the permissions it needs.

  1. Generate a template policy file

    Terminal window
    deployport iam identity-policy example > example.json
  2. Modify the policy

    Edit example.json: name the actions, the resources they reach, and the effect of each statement. Identity policy JSON reference has the sample the command prints, every field, and how a statement is matched.

  3. Create the policy

    Terminal window
    deployport iam identity-policy create --file example.json

The policy appears in deployport iam identity-policy list, and deployport iam identity-policy show <policy-name> prints the statements you wrote.

How can I change the name of the policy?

The policy name is defined in the JSON file. Look for the following field and modify it:

"name": "your-policy-name" // Change this to your desired policy name

A policy can be attached to more than one user and more than one role, so one definition covers every identity that needs it.

Attach a policy to a user to grant or deny access:

Terminal window
deployport iam users policies attach --username <username> --policy <policy-name>

Example:

Terminal window
deployport iam users policies attach --username john --policy example

A role takes the same attachment:

Terminal window
deployport iam roles policies attach --role <role-name> --policy <policy-name>

Example:

Terminal window
deployport iam roles policies attach --role developer-access --policy repository-access

List every identity policy in the account:

Terminal window
deployport iam identity-policy list

Example:

- name: builtin.iam-manager
- name: builtin.root
- name: myrepo-consumer

Add --attachments to see what each policy is attached to:

Terminal window
deployport iam identity-policy list --attachments

Example:

- name: builtin.iam-manager
- name: builtin.root
- name: myrepo-consumer
attachments:
list:
- targetDRN: iam:User(myrepo-consumer)
  • Start restrictive: begin with the minimum permissions and add more as needed
  • Use variables: use ${username} for user-specific resource access
  • Test policies: create a test policy with a limited scope before a broad one
  • Document purpose: the policy format makes the intention readable, and JS-style comments (//) clarify it further