aws iam attach-role-policy --role-name
aws iam attach-role-policy --role-name <name> --policy-arn <arn>
Risk: Careful
What it does
Clips a managed policy onto a role, so the role gets its keys.
When to use it
After you write a small policy. Careful: a broad policy hands out broad keys.
Example
$ aws iam attach-role-policy --role-name kedai-web --policy-arn arn:aws:iam::111122223333:policy/menu-readerGive the web server's role the menu-reader key.
$ aws iam list-attached-role-policies --role-name kedai-webWhich policies does this role hold?
$ aws iam detach-role-policy --role-name kedai-web --policy-arn arn:aws:iam::111122223333:policy/menu-readerTake the policy off again.
Learn it in: Roles for services · Official docs