Create an IAM role - Kahuna915/Capstone-Cloud-Integration GitHub Wiki
AWS step-by-step guide on how to create an IAM role through the console
-
Open the IAM console
-
Choose Roles and then choose Create role
- Choose AWS account
- To create a role for your account, choose This Account.
To create a role for another account, choose Another AWS account and ender the Account ID
-
Choose Next
-
Select the policy to use for the permissions policy or choose Create policy to open a new browser tab and create a new policy from scratch.
- Enter a Role name
- (Optional) For Description, enter a description for the new role
- Choose Edit in Step 1: Select trusted entities or Step 2: Add permissions sections to edit the use cases and permissions for the role
- Create Role
AWS step-by-step guide on how to create an IAM role through the CLI
- Create a role: aws iam create-role
- Attach a managed permissions policy to the role: aws iam attach-role-policy or Create an inline permissions policy for the role: aws iam put-role-policy
- (Optional) Add custom attributes to the role by attaching tags: aws iam tag-role For more information, see Managing tags on IAM roles (AWS CLI or AWS API)
- (Optional) Set the permissions boundary for the role: aws iam put-role-permissions-boundary A permissions boundary controls the maximum permissions that a role can have. Permissions boundaries are an advanced AWS feature
Example Code
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": { "AWS": "arn:aws:iam::123456789012:root" },
"Action": "sts:AssumeRole",
"Condition": { "Bool": { "aws:MultiFactorAuthPresent": "true" } }
}
]
}
CLI Commands
aws iam create-role --role-name Test-UserAccess-Role --assume-role-policy-document file://C:\policies\trustpolicyforacct123456789012.json
aws iam attach-role-policy --role-name Test-UserAccess-Role --policy-arn arn:aws:iam::123456789012:role/PolicyForRole