Sub topic 6
Attaching policies: managed, inline, and permissions boundaries
This chapter assumes you know IAM policy JSON and have a permission set, with INSTANCE_ARN and PS_ARN set as in earlier examples. A permission set holds no permissions of its own. The policies you attach to it become the policies on the role that Identity Center creates in each assigned account.
Three ways to attach policies
| Type | What it is | Where it lives | Good for |
|---|---|---|---|
| AWS managed policy | A policy AWS writes and maintains | Same ARN in every account | Common job functions such as `ReadOnlyAccess` |
| Inline policy | One JSON document stored in the permission set | Inside the permission set | Small, specific additions |
| Permissions boundary | A policy that sets a maximum | AWS managed policy, or a customer managed policy reference | Capping what the role can ever do |
You can attach several managed policies, but a permission set has only one inline policy. Quotas limit the number of managed policies and the size of the inline policy, so check the current Identity Center quotas page before you design around them.
How the policies combine
The role's effective permissions are the union of the managed and inline policies, limited by the boundary if one is set. A boundary never grants access. It only removes anything outside its scope.
Attach an inline policy
Save the policy to a file, then attach it. This example lets the role start and stop EC2 instances.
cat > inline.json <<'EOF'
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": ["ec2:StartInstances", "ec2:StopInstances"],
"Resource": "*"
}
]
}
EOF
aws sso-admin put-inline-policy-to-permission-set \
--instance-arn "$INSTANCE_ARN" \
--permission-set-arn "$PS_ARN" \
--inline-policy file://inline.jsonCalling this command again replaces the whole inline policy. It does not merge with the old one.
Set a permissions boundary
This command caps the role at what PowerUserAccess allows.
aws sso-admin put-permissions-boundary-to-permission-set \
--instance-arn "$INSTANCE_ARN" \
--permission-set-arn "$PS_ARN" \
--permissions-boundary ManagedPolicyArn=arn:aws:iam::aws:policy/PowerUserAccessWith this boundary, an inline iam:CreateUser allow has no effect, because PowerUserAccess excludes IAM user management. The next chapter covers boundaries that reference a customer managed policy.
Re-provision after changes
Changing a permission set that is already assigned does not update the roles in your accounts. Run provision-permission-set to push the change out.
aws sso-admin provision-permission-set \
--instance-arn "$INSTANCE_ARN" \
--permission-set-arn "$PS_ARN" \
--target-type ALL_PROVISIONED_ACCOUNTSCommon errors
- Permission still denied after an edit. You did not re-provision, or the boundary does not cover the action. Both the identity policy and the boundary must allow it.
- Inline policy disappeared. A second
put-inline-policy-to-permission-setcall overwrote it. Keep the full document in version control. - Boundary seems to grant access. It cannot. Check that an attached policy actually allows the action.
Exercise
A permission set has the managed policy ReadOnlyAccess, an inline policy allowing s3:PutObject, and a boundary of ReadOnlyAccess. Can a user sign in with this permission set and upload to S3?
Show answer
No. The inline policy allows s3:PutObject, but the boundary (ReadOnlyAccess) does not include it. The effective permissions are limited to what both the identity policies and the boundary allow.