Skip to content

Commit 09001b2

Browse files
chore(ci): change token permissions / update aws-credentials action (#5861)
* Improving security * Improving security
1 parent 1b81fbf commit 09001b2

8 files changed

+32
-23
lines changed

.github/workflows/bootstrap_region.yml

+7-6
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
name: Region Bootstrap
2+
13
# bootstraps new regions
24
#
35
# PURPOSE
@@ -27,7 +29,6 @@ on:
2729
required: true
2830
description: AWS region to bootstrap (i.e. eu-west-1)
2931

30-
name: Region Bootstrap
3132
run-name: Region Bootstrap ${{ inputs.region }}
3233

3334
permissions:
@@ -38,13 +39,13 @@ jobs:
3839
name: Install CDK
3940
runs-on: ubuntu-latest
4041
permissions:
41-
contents: write
42+
contents: read
4243
id-token: write
4344
environment: layer-${{ inputs.environment }}
4445
steps:
4546
- id: credentials
4647
name: AWS Credentials
47-
uses: aws-actions/configure-aws-credentials@e3dd6a429d7300a6a4c196c26e071d42e0343502
48+
uses: aws-actions/configure-aws-credentials@e3dd6a429d7300a6a4c196c26e071d42e0343502 # v4.0.2
4849
with:
4950
aws-region: ${{ inputs.region }}
5051
role-to-assume: ${{ secrets.REGION_IAM_ROLE }}
@@ -69,7 +70,7 @@ jobs:
6970
name: Copy Layers
7071
runs-on: ubuntu-latest
7172
permissions:
72-
contents: write
73+
contents: read
7374
id-token: write
7475
strategy:
7576
matrix:
@@ -90,7 +91,7 @@ jobs:
9091
steps:
9192
- id: credentials
9293
name: AWS Credentials
93-
uses: aws-actions/configure-aws-credentials@e3dd6a429d7300a6a4c196c26e071d42e0343502
94+
uses: aws-actions/configure-aws-credentials@e3dd6a429d7300a6a4c196c26e071d42e0343502 # v4.0.2
9495
with:
9596
aws-region: us-east-1
9697
role-to-assume: ${{ secrets.REGION_IAM_ROLE }}
@@ -106,4 +107,4 @@ jobs:
106107
run: go install github.com/aws-powertools/actions/layer-balancer/cmd/balance@latest
107108
- id: run-balance
108109
name: Run Balance
109-
run: balance -read-region us-east-1 -write-region ${{ inputs.region }} -write-role ${{ secrets.BALANCE_ROLE_ARN }} -layer-name ${{ matrix.layer }} -dry-run=false
110+
run: balance -read-region us-east-1 -write-region ${{ inputs.region }} -write-role ${{ secrets.BALANCE_ROLE_ARN }} -layer-name ${{ matrix.layer }} -dry-run=false

.github/workflows/layer_govcloud.yml

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
name: Layer Deployment (GovCloud)
2+
13
# GovCloud Layer Publish
24
# ---
35
# This workflow publishes a specific layer version in an AWS account based on the environment input.
@@ -32,9 +34,11 @@ on:
3234
type: string
3335
required: true
3436

35-
name: Layer Deployment (GovCloud)
3637
run-name: Layer Deployment (GovCloud) - ${{ inputs.environment }}
3738

39+
permissions:
40+
contents: read
41+
3842
jobs:
3943
download:
4044
runs-on: ubuntu-latest

.github/workflows/publish_v3_layer.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -303,8 +303,8 @@ jobs:
303303
needs: [update_v3_layer_arn_docs, prepare_docs_alias]
304304
permissions:
305305
# lower privilege propagated from parent workflow (release.yml)
306-
contents: write
307-
pages: write
306+
#contents: write
307+
#pages: write
308308
pull-requests: none
309309
id-token: write
310310
secrets: inherit

.github/workflows/reusable_deploy_v3_layer_stack.yml

+3-2
Original file line numberDiff line numberDiff line change
@@ -154,11 +154,12 @@ jobs:
154154

155155
- name: Install poetry
156156
run: pipx install git+https://github.com/python-poetry/poetry@68b88e5390720a3dd84f02940ec5200bfce39ac6 # v1.5.0
157-
- name: aws credentials
158-
uses: aws-actions/configure-aws-credentials@5fd3084fc36e372ff1fff382a39b10d03659f355 # v2.2.0
157+
- name: Configure AWS credentials
158+
uses: aws-actions/configure-aws-credentials@e3dd6a429d7300a6a4c196c26e071d42e0343502 # v4.0.2
159159
with:
160160
aws-region: ${{ matrix.region }}
161161
role-to-assume: ${{ secrets.AWS_LAYERS_ROLE_ARN }}
162+
mask-aws-account-id: true
162163
- name: Setup Node.js
163164
uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0
164165
with:

.github/workflows/reusable_deploy_v3_sar.yml

+3-2
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,12 @@ jobs:
8686
artifact_name: ${{ inputs.source_code_artifact_name }}
8787

8888

89-
- name: AWS credentials
90-
uses: aws-actions/configure-aws-credentials@5fd3084fc36e372ff1fff382a39b10d03659f355 # v2.2.0
89+
- name: Configure AWS credentials
90+
uses: aws-actions/configure-aws-credentials@e3dd6a429d7300a6a4c196c26e071d42e0343502 # v4.0.2
9191
with:
9292
aws-region: ${{ env.AWS_REGION }}
9393
role-to-assume: ${{ secrets.AWS_LAYERS_ROLE_ARN }}
94+
mask-aws-account-id: true
9495

9596
# NOTE
9697
# We connect to Layers account to log our intent to publish a SAR Layer

.github/workflows/reusable_publish_docs.yml

+4-3
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ jobs:
4040
runs-on: ubuntu-latest
4141
environment: "Docs"
4242
permissions:
43-
contents: write # push to gh-pages
43+
contents: read # push to gh-pages
4444
id-token: write # trade JWT token for AWS credentials in AWS Docs account
45-
pages: write # uncomment if mike fails as we migrated to S3 hosting
45+
#pages: write # uncomment if mike fails as we migrated to S3 hosting
4646
steps:
4747
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
4848
with:
@@ -79,10 +79,11 @@ jobs:
7979
poetry run mike set-default --push latest
8080
8181
- name: Configure AWS credentials
82-
uses: aws-actions/configure-aws-credentials@5fd3084fc36e372ff1fff382a39b10d03659f355
82+
uses: aws-actions/configure-aws-credentials@e3dd6a429d7300a6a4c196c26e071d42e0343502 # v4.0.2
8383
with:
8484
aws-region: us-east-1
8585
role-to-assume: ${{ secrets.AWS_DOCS_ROLE_ARN }}
86+
mask-aws-account-id: true
8687
- name: Copy API Docs
8788
run: |
8889
cp -r api site/

.github/workflows/run-e2e-tests.yml

+3-2
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,12 @@ jobs:
7070
npm ci
7171
npx cdk --version
7272
- name: Install dependencies
73-
run: dev-quality-code
73+
run: make dev-quality-code
7474
- name: Configure AWS credentials
75-
uses: aws-actions/configure-aws-credentials@5fd3084fc36e372ff1fff382a39b10d03659f355 # v2.2.0
75+
uses: aws-actions/configure-aws-credentials@e3dd6a429d7300a6a4c196c26e071d42e0343502 # v4.0.2
7676
with:
7777
role-to-assume: ${{ secrets.AWS_TEST_ROLE_ARN }}
7878
aws-region: ${{ env.AWS_DEFAULT_REGION }}
79+
mask-aws-account-id: true
7980
- name: Test
8081
run: make e2e-test

.github/workflows/update_ssm.yml

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
name: SSM Parameters
2+
run-name: SSM Parameters - Python
3+
14
# SSM Parameters update
25
#
36
# PROCESS
@@ -38,9 +41,6 @@ on:
3841
type: string
3942
required: true
4043

41-
name: SSM Parameters
42-
run-name: SSM Parameters - Python
43-
4444
permissions:
4545
contents: read
4646

@@ -59,14 +59,14 @@ jobs:
5959
]
6060

6161
permissions:
62-
contents: write
62+
contents: read
6363
id-token: write
6464
steps:
6565
- id: transform
6666
run: |
6767
echo 'CONVERTED_REGION=${{ matrix.region }}' | tr 'a-z\-' 'A-Z_' >> "$GITHUB_OUTPUT"
6868
- id: creds
69-
uses: aws-actions/configure-aws-credentials@e3dd6a429d7300a6a4c196c26e071d42e0343502
69+
uses: aws-actions/configure-aws-credentials@e3dd6a429d7300a6a4c196c26e071d42e0343502 # v4.0.2
7070
with:
7171
aws-region: ${{ matrix.region }}
7272
role-to-assume: ${{ secrets[format('{0}', steps.transform.outputs.CONVERTED_REGION)] }}

0 commit comments

Comments
 (0)