Last active
February 5, 2021 23:28
-
-
Save gwsu2008/d7759c261276f5b7dbf4ea557df10a36 to your computer and use it in GitHub Desktop.
iam assume role
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
first configure role to allow assume role in trust relationship | |
{ | |
"Version": "2012-10-17", | |
"Statement": [ | |
{ | |
"Effect": "Allow", | |
"Principal": { | |
"AWS": "arn:aws:iam::12345678:user/xyz", | |
"Service": "ec2.amazonaws.com" | |
}, | |
"Action": "sts:AssumeRole" | |
} | |
] | |
} | |
create iam policy to assume role | |
{ | |
"Version": "2012-10-17", | |
"Statement": { | |
"Effect": "Allow", | |
"Action": "sts:AssumeRole", | |
"Resource": "arn:aws:iam::12345678:role/my-role" | |
} | |
} | |
ec2-instance | |
[profile sandbox] | |
output = json | |
region = us-west-2 | |
role_arn = arn:aws:iam::1111111111:role/my-role | |
credential_source = Ec2InstanceMetadata |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment