We're sorry but this app doesn't work properly without JavaScript enabled. Please enable it to continue.

This lesson's interactive features are locked, please to keep using them

IAM Groups

While inline policies are attached directly to a single user, the preferred way to manage permissions in AWS is to create groups and give them the policies (sometimes called customer-managed policies).

This DRYs up your permissions management and makes it much easier to ensure that everyone has only the access levels they need.

Let's convert our inline policy into a customer-managed policy, then attach it to a group.

Assignment

PatientPing's CISO has "thoughts" about our inline policies. Per last week's security review: no more inline policies on users.

Create a customer-managed policy patientping-ec2-readonly and a group patientping-ec2-readers. Attach the policy to the group, add patientping-admin-vinny to the group, and remove the inline policy from the user.

Cost check: Creating IAM groups and policies is free; costs arise from service usage.

    1. {
        "Version": "2012-10-17",
        "Statement": [
          {
            "Effect": "Allow",
            "Action": ["ec2:Describe*"],
            "Resource": "*"
          }
        ]
      }
      

Run and submit the CLI tests.

Tip

For CLI users, here's how to create IAM groups, policies, and manage group membership:

# Create a customer-managed policy
aws iam create-policy --policy-name POLICY-NAME --policy-document file://POLICY-FILE.json

# Create a group
aws iam create-group --group-name GROUP-NAME

# Attach policy to group
aws iam attach-group-policy --group-name GROUP-NAME --policy-arn POLICY-ARN

# Add user to group
aws iam add-user-to-group --group-name GROUP-NAME --user-name USER-NAME

# Remove the inline policy from the user
aws iam delete-user-policy --user-name USER-NAME --policy-name POLICY-NAME