Getting started with Identity and Access Management
Create a group with read-only compute access, put a new IAM user in it, check what the user may do, and clean up.
Last updated 18 November 2026View as Markdown
In about ten minutes you give a group the managed policy Ec2ReadOnlyAccess, add an IAM user
called alice to it, and confirm with the policy simulator that she may list instances but not
terminate them. Nothing here is charged. Replace org-EXAMPLE1234 with your organization id,
and the ids the CLI prints where the commands ask for them.
Prerequisites
- You are the organization owner, or your policies allow
iam:CreateGroup,iam:AttachGroupPolicy,iam:CreateUser,iam:AddUserToGroup,iam:SimulatePrincipalPolicy,iam:DeleteUserandiam:DeleteGroup. - For the console, also
iam:ListGroups,iam:GetGroup,iam:ListUsersandiam:GetUserto open the lists and the pages (a group's or user's page answers 404 without theGetaction). - For the CLI, also
iam:ListPoliciesto find the policy's id. - For the CLI:
dcloud auth loginhas signed you in; see Sign in the CLI.
Step 1: Create a group
- Open Identity, then choose Groups.
- Choose Create group, enter developers as the group name, and choose Create group. The group's page opens.
dcloud iam groups create --name developers --description "Read-only compute"The answer holds the group's id.
Step 2: Attach a managed policy to the group
- On the group's page, choose Permissions.
- Open the policy list, choose
Ec2ReadOnlyAccess, then choose Attach.
Find the policy's id, then attach it:
dcloud iam policies list
dcloud iam groups attach-policy group-id --policy-id policy-idStep 3: Create an IAM user and add it to the group
- Choose Users, then Create user.
- For Username, enter alice. Leave Type at User.
- Choose Create user. The user's page opens.
- Go back to the group developers and choose Members.
- Open the user list, choose alice, then choose Add.
dcloud iam users create --username alice
dcloud iam groups add-member group-id --iam-user-id user-idStep 4: Check what the user may do
- Choose Policy simulator.
- For Who, choose alice. For Action, search for and choose
ec2:DescribeInstances. For Resource, enterrn:ews:de1:org-EXAMPLE1234:ec2:*. - Choose Simulate. The answer is Allowed, through the group developers.
- Choose
ec2:TerminateInstancesfor Action and choose Simulate again. The answer is Implicitly denied: no statement allows it.
dcloud iam policies simulate --action ec2:DescribeInstances \
--resource 'rn:ews:de1:org-EXAMPLE1234:ec2:*' \
--principal '{"type":"user","id":"user-id"}'The answer's decision is allowed. With --action ec2:TerminateInstances it is
implicitly_denied.
Clean up
Deleting the user removes its group membership; deleting the group detaches its policy. The managed policy itself stays.
- Open the user alice, choose Danger zone, then Delete IAM user. Type the user name and confirm.
- Open the group developers, choose Danger zone, then Delete group. Type the group name and confirm.
dcloud iam users delete user-id
dcloud iam groups delete group-idNext steps
- Invite a person: give a colleague access with their own email address.
- Create a policy: write a policy of your own.
- Grant access to one resource
Did this page help you?