Created
January 31, 2023 13:25
-
-
Save NYARAS/59e7bff2b82e0e530318e3f6062ca557 to your computer and use it in GitHub Desktop.
Gitlab OIDC Gitlab CI
This file contains 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
variables: | |
AWS_ROLE_ARN: <AWS_ROLE_ARN> | |
AWS_WEB_IDENTITY_TOKEN_FILE: /tmp/web-identity-token | |
assume role: | |
image: | |
name: amazon/aws-cli | |
entrypoint: [""] | |
script: | |
- > | |
export $(printf "AWS_ACCESS_KEY_ID=%s AWS_SECRET_ACCESS_KEY=%s AWS_SESSION_TOKEN=%s" | |
$(aws sts assume-role-with-web-identity | |
--role-arn $AWS_ROLE_ARN | |
--role-session-name "GitLabRunner-${CI_PROJECT_ID}-${CI_PIPELINE_ID}" | |
--web-identity-token $CI_JOB_JWT_V2 | |
--duration-seconds 3600 | |
--query 'Credentials.[AccessKeyId,SecretAccessKey,SessionToken]' | |
--output text)) | |
- aws sts get-caller-identity | |
- aws s3 ls s3://oidc-test-bucket/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment