Skip to content

Commit 4ad00a4

Browse files
committed
Use configure-aws-credentials Actions
the Action supports ID token issued by GitHub OIDC and GitHub Acitons can assume the specified role using IAM identity provider. See aws-actions/configure-aws-credentials#262 for more details.
1 parent d5c2d93 commit 4ad00a4

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

.github/workflows/main.yml

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ on:
66
description: 'Your AWS account ID you deployed GitHub Acitons IAM role via Terraform'
77
required: true
88
default: 'YOU_AWS_ACCOUNT_ID'
9+
aws_iam_role:
10+
description: 'Your AWS IAM role assumed by GitHub Actions using IAM identity provider'
11+
required: true
12+
default: 'GitHubActions'
913

1014
jobs:
1115
test-github-id-token-with-aws:
@@ -15,18 +19,12 @@ jobs:
1519
contents: read
1620
steps:
1721
- run: sleep 5 # there's still a race condition for now
18-
22+
# https://github.com/aws-actions/configure-aws-credentials
23+
# Specifying role-to-assume without providing an aws-access-key-id or a web-identity-token-file will signal to the action that you wish to use the OIDC provider.
1924
- name: Configure AWS
20-
run: |
21-
export AWS_ROLE_ARN=arn:aws:iam::${{ github.event.inputs.aws_account_id}}:role/GitHubActions
22-
export AWS_WEB_IDENTITY_TOKEN_FILE=/tmp/awscreds
23-
export AWS_DEFAULT_REGION=ap-northeast-1
24-
25-
echo AWS_WEB_IDENTITY_TOKEN_FILE=$AWS_WEB_IDENTITY_TOKEN_FILE >> $GITHUB_ENV
26-
echo AWS_ROLE_ARN=$AWS_ROLE_ARN >> $GITHUB_ENV
27-
echo AWS_DEFAULT_REGION=$AWS_DEFAULT_REGION >> $GITHUB_ENV
28-
29-
curl -H "Authorization: bearer $ACTIONS_ID_TOKEN_REQUEST_TOKEN" "$ACTIONS_ID_TOKEN_REQUEST_URL" | jq -r '.value' > $AWS_WEB_IDENTITY_TOKEN_FILE
30-
25+
uses: aws-actions/configure-aws-credentials@v1
26+
with:
27+
role-to-assume: arn:aws:iam::${{ github.event.inputs.aws_account_id}}:role/${{ github.event.inputs.aws_iam_role }}
28+
aws-region: ap-northeast-1
3129
- run: aws sts get-caller-identity
3230
- run: aws s3 ls | grep github-actions

0 commit comments

Comments
 (0)