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:
{ "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:
deployport iam identity-policy show builtin.rootThis policy is very permissive, so attach it carefully. A custom policy is how you restrict an identity to the permissions it needs.
Create a custom policy
Section titled “Create a custom policy”-
Generate a template policy file
Terminal window deployport iam identity-policy example > example.json -
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. -
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 nameAttach a policy
Section titled “Attach a policy”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 to a user
Section titled “Attach to a user”Attach a policy to a user to grant or deny access:
deployport iam users policies attach --username <username> --policy <policy-name>Example:
deployport iam users policies attach --username john --policy exampleAttach to a role
Section titled “Attach to a role”A role takes the same attachment:
deployport iam roles policies attach --role <role-name> --policy <policy-name>Example:
deployport iam roles policies attach --role developer-access --policy repository-accessList identity policies
Section titled “List identity policies”List every identity policy in the account:
deployport iam identity-policy listExample:
- name: builtin.iam-manager- name: builtin.root- name: myrepo-consumerAdd --attachments to see what each policy is attached to:
deployport iam identity-policy list --attachmentsExample:
- name: builtin.iam-manager- name: builtin.root- name: myrepo-consumer attachments: list: - targetDRN: iam:User(myrepo-consumer)Best practices
Section titled “Best practices”- 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