|
16 | 16 | description: AWS IAM role ARN |
17 | 17 | required: false |
18 | 18 | type: string |
| 19 | + useOIDC: |
| 20 | + description: Whether to use OIDC for assume role |
| 21 | + required: false |
| 22 | + type: boolean |
| 23 | + default: false |
| 24 | + githubOIDCRoleArn: |
| 25 | + description: Github OIDC role ARN |
| 26 | + required: false |
| 27 | + type: string |
| 28 | + default: "" |
19 | 29 | awsRegion: |
20 | 30 | description: AWS region |
21 | 31 | required: false |
|
42 | 52 | secrets: |
43 | 53 | awsAccessKeyId: |
44 | 54 | description: AWS access key ID |
45 | | - required: true |
| 55 | + required: false |
46 | 56 | awsSecretAccessKey: |
47 | 57 | description: AWS secret access key |
48 | | - required: true |
| 58 | + required: false |
49 | 59 | slackToken: |
50 | 60 | description: Slack API token |
51 | 61 | required: false |
|
55 | 65 | runs-on: ubuntu-22.04-arm64 |
56 | 66 | steps: |
57 | 67 | - name: assume IAM role |
| 68 | + if: inputs.useOIDC == false |
58 | 69 | uses: aws-actions/configure-aws-credentials@v4 |
59 | 70 | with: |
60 | 71 | aws-access-key-id: ${{ secrets.awsAccessKeyId }} |
|
67 | 78 | # which does not work for cross-account assume |
68 | 79 | role-skip-session-tagging: true |
69 | 80 |
|
| 81 | + # First assume GithubOIDCRole role, the trust relationship between GitHub and AWS is defined in IAM GithubOIDCRole in the organization account. This role has permissions to assume Deployer roles only. |
| 82 | + - name: assume GithubOIDCRole |
| 83 | + if: inputs.useOIDC == true |
| 84 | + uses: aws-actions/configure-aws-credentials@v4 |
| 85 | + with: |
| 86 | + aws-region: ${{ inputs.awsRegion }} |
| 87 | + role-to-assume: ${{ inputs.githubOIDCRoleArn }} |
| 88 | + role-duration-seconds: ${{ inputs.awsSessionDuration }} |
| 89 | + |
| 90 | + # This parameter is needed otherwise this action is trying to tag session |
| 91 | + # which does not work for cross-account assume |
| 92 | + role-skip-session-tagging: true |
| 93 | + |
| 94 | + # Then assume Deployer role, which can be assumed by GithubOIDCRole and has all the permissions needed. |
| 95 | + - name: assume Deployer role |
| 96 | + if: inputs.useOIDC == true |
| 97 | + uses: aws-actions/configure-aws-credentials@v4 |
| 98 | + with: |
| 99 | + aws-region: ${{ inputs.awsRegion }} |
| 100 | + role-to-assume: ${{ inputs.awsRoleArn }} |
| 101 | + role-duration-seconds: ${{ inputs.awsSessionDuration }} |
| 102 | + role-chaining: true |
| 103 | + role-skip-session-tagging: true |
| 104 | + |
70 | 105 | - name: invalidate |
71 | 106 | run: | |
72 | 107 | echo ">>> Invalidating path ${{ inputs.path }} of distribution ${{ inputs.distributionId }}" |
|
0 commit comments