Hi,
Didn't work when the role switch needs an external-id parameter.
What worked for me:
- Extracted the external_id parameter from the profile in ~/.aws/config
- added the --external-id parameter to the sts cmd
- Removed the --profile parameter from the sts cmd. If not, the sts assume-role fail with:
An error occurred (AccessDenied) when calling the AssumeRole operation: User: arn:aws:sts::0000000:assumed-role/somerole/botocore-session-000000 is not authorized to perform: sts:AssumeRole on resource: arn:aws:iam::0000000:role/somerole
The final cmd is:
['/usr/local/bin/aws', 'sts', 'assume-role', '--role-arn', 'arn:aws:iam::0000000:role/somerole', '--role-session-name', 'someprofile-00000000', '--external-id', 'some-external-id']
My ~/.aws/config
[default]
region = my-region
[profile someprofile]
role_arn = arn:aws:iam::000000:role/some_role
source_profile = default
external_id = some-external-id
My ~/.aws/credentials
[default]
aws_access_key_id = KEY
aws_secret_access_key = SECRET
Hi,
Didn't work when the role switch needs an external-id parameter.
What worked for me:
The final cmd is:
['/usr/local/bin/aws', 'sts', 'assume-role', '--role-arn', 'arn:aws:iam::0000000:role/somerole', '--role-session-name', 'someprofile-00000000', '--external-id', 'some-external-id']