File tree 1 file changed +15
-5
lines changed
1 file changed +15
-5
lines changed Original file line number Diff line number Diff line change @@ -120,12 +120,22 @@ if [ "$#" -lt 2 ]; then
120
120
about
121
121
fi
122
122
123
- if [ -n " $AWS_OIDC_ROLE_ARN " ]; then
124
- echo " Assuming role: $AWS_OIDC_ROLE_ARN "
125
- role_session_name=" SomeSessionName" # You can customize this session name
126
123
127
- # Assume role and get temporary credentials
128
- creds=$( aws sts assume-role --role-arn " $AWS_OIDC_ROLE_ARN " --role-session-name " $role_session_name " --query ' Credentials' --output json)
124
+ if [ -n " $AWS_OIDC_ROLE_ARN " ] && [ -n " $BITBUCKET_STEP_OIDC_TOKEN " ]; then
125
+ echo " Using Bitbucket OIDC Token for AWS Authentication"
126
+
127
+ timestamp=$( date +%Y%m%d-%H%M%S)
128
+ # Set the OIDC token and AWS Role ARN
129
+ oidc_token=$BITBUCKET_STEP_OIDC_TOKEN
130
+ aws_role_arn=$AWS_OIDC_ROLE_ARN
131
+
132
+ # Assume the AWS role using the OIDC token
133
+ creds=$( aws sts assume-role-with-web-identity \
134
+ --role-arn " $aws_role_arn " \
135
+ --role-session-name " BitbucketSession" \
136
+ --web-identity-token " $oidc_token " \
137
+ --query ' Credentials' \
138
+ --output json)
129
139
130
140
# Set temporary credentials for subsequent AWS CLI commands
131
141
AWS_ACCESS_KEY_ID=$( echo " $creds " | jq -r ' .AccessKeyId' )
You can’t perform that action at this time.
0 commit comments