How do i create an aws iam role?
-
Link to IAM command: https://docs.aws.amazon.com/cli/latest/reference/iam/index.html
Link to list-roles subcommand: https://docs.aws.amazon.com/cli/latest/reference/iam/list-roles.html
Link to get-role: https://docs.aws.amazon.com/cli/latest/reference/iam/get-role.htmlFirst you have to create a policy in a text file. The text file here is called assume_role_policy_document.json
This is actually an example from the AWS website. It was for demo purposes only.
{ "Version": "2012-10-17", "Statement": [ { "Sid": "", "Effect": "Allow", "Principal": { "Service": "cloudtrail.amazonaws.com" }, "Action": "sts:AssumeRole" } ] }
Create the role with assigned policy. The will be the role json output.
$ aws iam create-role --role-name MyWatchRole --assume-role-policy-document file://assume_role_policy_document.json
To list the role you just created.
$ aws iam get-role --role-name MyWatchRole
© Lightnetics 2024