Skip to content

Instantly share code, notes, and snippets.

@gwsu2008
Last active February 5, 2021 23:28
Show Gist options
  • Save gwsu2008/d7759c261276f5b7dbf4ea557df10a36 to your computer and use it in GitHub Desktop.
Save gwsu2008/d7759c261276f5b7dbf4ea557df10a36 to your computer and use it in GitHub Desktop.
iam assume role
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