AWS IAM Essentials
Policy
Create
Create a new IAM policy from a JSON file
aws iam create-policy --policy-name NewPolicy --policy-document file://policy.json
Attach To Role
Attach IAM policy to a role
aws iam attach-role-policy --role-name NEW_ROLE --policy-arn "<NEW_POLICY_ARN>"
Role
Create
Create a new I am Role
aws iam create-role --role-name NEW_ROLE --assume-role-policy-document file://policy.json
List Attached Policy
List policies attached to a role
aws iam list-attached-role-policies --role-name NEW_ROLE
List Roles
aws iam list-roles
Instance Profile
Create
Create a new Instance Profile
aws iam create-instance-profile --instance-profile-name NEW_PROFILE
Add Role to Instance Profile
Attach a role to an instance profile
aws iam add-role-to-instance-profile --instance-profile-name NEW_PROFILE --role-name NEW_ROLE
Get Instance Profile
aws iam get-instance-profile --instance-profile-name NEW_PROFILE
Associate Instance Profile With EC2 Instance
aws ec2 associate-iam-instance-profile --instance-id i-999999999 --iam-instance-profile Name="NEW_PROFILE"
Related
Links
- https://docs.aws.amazon.com/iam/index.html
- https://aws.amazon.com/iam/
- https://policysim.aws.amazon.com/home/index.jsp