Skip to content

Commit a99784b

Browse files
Deploy via GitHub OIDC role instead of IAM access keys
Switch both deploy workflows from long-lived AWS_ACCESS_KEY_ID / AWS_SECRET_ACCESS_KEY secrets to a GitHub Actions OIDC-assumed role. Add id-token: write permission and assume the automator-lambda-deploy role (provisioned in infra-terraform) via role-to-assume. Role ARN is set in the workflow env block.
1 parent 3a00724 commit a99784b

2 files changed

Lines changed: 10 additions & 4 deletions

File tree

.github/workflows/deploy-automator.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,14 @@ on:
1010
env:
1111
AWS_REGION: eu-west-1
1212
FUNCTION_NAME: automator-process-reaction
13+
DEPLOY_ROLE_ARN: arn:aws:iam::387546586013:role/automator-lambda-deploy
1314

1415
jobs:
1516
deploy:
1617
runs-on: ubuntu-latest
18+
permissions:
19+
id-token: write # request the OIDC token for AWS role assumption
20+
contents: read
1721
# Deploy only when Test Automator passed on main, or when manually run from main.
1822
if: (github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.head_branch == 'main') || (github.event_name == 'workflow_dispatch' && github.ref == 'refs/heads/main')
1923
defaults:
@@ -31,8 +35,7 @@ jobs:
3135
- name: Configure AWS credentials
3236
uses: aws-actions/configure-aws-credentials@v4
3337
with:
34-
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
35-
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
38+
role-to-assume: ${{ env.DEPLOY_ROLE_ARN }}
3639
aws-region: ${{ env.AWS_REGION }}
3740

3841
- name: Package Lambda function

.github/workflows/deploy-router.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,14 @@ on:
1010
env:
1111
AWS_REGION: eu-west-1
1212
ROUTER_FUNCTION_NAME: ${{ vars.ROUTER_FUNCTION_NAME || 'slack-test' }}
13+
DEPLOY_ROLE_ARN: arn:aws:iam::387546586013:role/automator-lambda-deploy
1314

1415
jobs:
1516
deploy-router:
1617
runs-on: ubuntu-latest
18+
permissions:
19+
id-token: write # request the OIDC token for AWS role assumption
20+
contents: read
1721
# Deploy only when Test Router passed on main, or when manually run from main.
1822
if: (github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.head_branch == 'main') || (github.event_name == 'workflow_dispatch' && github.ref == 'refs/heads/main')
1923
defaults:
@@ -26,8 +30,7 @@ jobs:
2630
- name: Configure AWS credentials
2731
uses: aws-actions/configure-aws-credentials@v4
2832
with:
29-
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
30-
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
33+
role-to-assume: ${{ env.DEPLOY_ROLE_ARN }}
3134
aws-region: ${{ env.AWS_REGION }}
3235

3336
- name: Package router Lambda

0 commit comments

Comments
 (0)