Skip to content

Instantly share code, notes, and snippets.

@ottokruse
Created January 11, 2022 13:34
Show Gist options
  • Save ottokruse/1eea8be3509d822749c2b1d4b0537b98 to your computer and use it in GitHub Desktop.
Save ottokruse/1eea8be3509d822749c2b1d4b0537b98 to your computer and use it in GitHub Desktop.
AWS CLI assume role in AWS CodeBuild through ECS credentials
version: '0.2'
phases:
build:
commands:
- |
cat << EOF > aws_config
[profile test]
role_arn = arn:aws:iam::123456789012:role/my-role-to-assume
role_session_name = IntegrationTest
credential_source = EcsContainer
EOF
- export AWS_CONFIG_FILE=./aws_config
- aws sts get-caller-identity --profile test # Uses the assumed role
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment