Skip to content

Commit 2ee4a2b

Browse files
authored
fix(ci): Permissions and depdendencies
fix(ci): Permissions and depdendencies
2 parents 67f43a3 + 0db71a3 commit 2ee4a2b

29 files changed

+1042
-230
lines changed

.github/workflows/build_changelog.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ name: Build changelog
44
on:
55
workflow_dispatch:
66

7+
permissions:
8+
contents: read
9+
710
jobs:
811
changelog:
912
uses: ./.github/workflows/reusable_publish_changelog.yml

.github/workflows/codeql-analysis.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ on:
1212
schedule:
1313
- cron: '42 8 * * 0'
1414

15+
permissions:
16+
contents: read
17+
1518
jobs:
1619
analyze:
1720
name: Analyze

.github/workflows/dispatch_analytics.yml

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,23 @@ on:
77
- cron: '0 * * * *'
88

99
permissions:
10-
id-token: write
11-
actions: read
12-
checks: read
1310
contents: read
14-
deployments: read
15-
issues: read
16-
discussions: read
17-
packages: read
18-
pages: read
19-
pull-requests: read
20-
repository-projects: read
21-
security-events: read
22-
statuses: read
2311

2412
jobs:
2513
dispatch_token:
14+
permissions:
15+
id-token: write
16+
actions: read
17+
checks: read
18+
deployments: read
19+
issues: read
20+
discussions: read
21+
packages: read
22+
pages: read
23+
pull-requests: read
24+
repository-projects: read
25+
security-events: read
26+
statuses: read
2627
if: github.repository == 'aws-powertools/powertools-lambda-dotnet'
2728
concurrency:
2829
group: analytics

.github/workflows/docs.yml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,13 @@ on:
77
workflow_dispatch: {}
88

99
permissions:
10-
id-token: write
11-
contents: write
12-
pages: write
10+
contents: read
1311

1412
jobs:
1513
docs:
14+
permissions:
15+
id-token: write
16+
contents: write
1617
# Force Github action to run only a single job at a time (based on the group name)
1718
# This is to prevent "race-condition" in publishing a new version of doc to `gh-pages`
1819
concurrency:
@@ -46,6 +47,9 @@ jobs:
4647
dist \
4748
s3://${{ secrets.AWS_DOCS_BUCKET }}/lambda-dotnet/
4849
apidocs:
50+
permissions:
51+
id-token: write
52+
contents: write
4953
# Force Github action to run only a single job at a time (based on the group name)
5054
# This is to prevent "race-condition" in publishing a new version of doc to `gh-pages`
5155
concurrency:

.github/workflows/e2e-tests.yml

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,12 @@ concurrency:
2222
group: e2e
2323

2424
permissions:
25-
id-token: write
2625
contents: read
2726

2827
jobs:
2928
deploy-stack:
29+
permissions:
30+
id-token: write
3031
runs-on: ubuntu-latest
3132
steps:
3233
- name: Checkout code
@@ -45,17 +46,19 @@ jobs:
4546
dotnet-version: '8.x'
4647

4748
- name: Install CDK
48-
run: npm install -g aws-cdk
49+
run: npm install
4950

5051
- name: Install AWS Lambda .NET CLI Tools
5152
run: dotnet tool install -g Amazon.Lambda.Tools
5253

5354
- name: Deploy Stack
5455
run: |
5556
cd libraries/tests/e2e/infra
56-
cdk deploy --all --require-approval never
57+
npx cdk deploy --all --require-approval never
5758
5859
deploy-aot-stack:
60+
permissions:
61+
id-token: write
5962
strategy:
6063
matrix:
6164
os: [ubuntu-24.04-arm, ubuntu-latest]
@@ -82,17 +85,19 @@ jobs:
8285
dotnet-version: '8.x'
8386

8487
- name: Install CDK
85-
run: npm install -g aws-cdk
88+
run: npm install
8689

8790
- name: Install AWS Lambda .NET CLI Tools
8891
run: dotnet tool install -g Amazon.Lambda.Tools
8992

9093
- name: Deploy AOT Stack
9194
run: |
9295
cd libraries/tests/e2e/infra-aot
93-
cdk deploy --all -c architecture=${{ matrix.arch }} --require-approval never
96+
npx cdk deploy --all -c architecture=${{ matrix.arch }} --require-approval never
9497
9598
run-tests:
99+
permissions:
100+
id-token: write
96101
strategy:
97102
matrix:
98103
utility: [core, idempotency]
@@ -126,6 +131,8 @@ jobs:
126131
dotnet test --filter Category=AOT
127132
128133
destroy-stack:
134+
permissions:
135+
id-token: write
129136
runs-on: ubuntu-latest
130137
needs: run-tests
131138
if: always()
@@ -141,17 +148,19 @@ jobs:
141148
mask-aws-account-id: true
142149

143150
- name: Install CDK
144-
run: npm install -g aws-cdk
151+
run: npm install
145152

146153
- name: Install AWS Lambda .NET CLI Tools
147154
run: dotnet tool install -g Amazon.Lambda.Tools
148155

149156
- name: Destroy Stack
150157
run: |
151158
cd libraries/tests/e2e/infra
152-
cdk destroy --all --force
159+
npx cdk destroy --all --force
153160
154161
destroy-aot-stack:
162+
permissions:
163+
id-token: write
155164
strategy:
156165
matrix:
157166
os: [ubuntu-24.04-arm, ubuntu-latest]
@@ -175,13 +184,13 @@ jobs:
175184
mask-aws-account-id: true
176185

177186
- name: Install CDK
178-
run: npm install -g aws-cdk
187+
run: npm install
179188

180189
- name: Install AWS Lambda .NET CLI Tools
181190
run: dotnet tool install -g Amazon.Lambda.Tools
182191

183192
- name: Destroy arm64 AOT Stack
184193
run: |
185194
cd libraries/tests/e2e/infra-aot
186-
cdk destroy --all -c architecture=${{ matrix.arch }} --force
195+
npox cdk destroy --all -c architecture=${{ matrix.arch }} --force
187196

.github/workflows/label_pr_on_title.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,13 @@ on:
66
types:
77
- completed
88

9+
permissions:
10+
contents: read
11+
912
jobs:
1013
get_pr_details:
14+
permissions:
15+
id-token: write
1116
# Guardrails to only ever run if PR recording workflow was indeed
1217
# run in a PR event and ran successfully
1318
if: ${{ github.event.workflow_run.conclusion == 'success' }}
@@ -18,6 +23,8 @@ jobs:
1823
secrets:
1924
token: ${{ secrets.GITHUB_TOKEN }}
2025
label_pr:
26+
permissions:
27+
id-token: write
2128
needs: get_pr_details
2229
runs-on: ubuntu-latest
2330
steps:

.github/workflows/on_label_added.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,13 @@ on:
66
types:
77
- completed
88

9+
permissions:
10+
contents: read
11+
912
jobs:
1013
get_pr_details:
14+
permissions:
15+
id-token: write
1116
if: ${{ github.event.workflow_run.conclusion == 'success' }}
1217
uses: ./.github/workflows/reusable_export_pr_details.yml
1318
with:
@@ -22,6 +27,7 @@ jobs:
2227
permissions:
2328
issues: write
2429
pull-requests: write
30+
id-token: write
2531
steps:
2632
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
2733
# Maintenance: Persist state per PR as an artifact to avoid spam on label add

.github/workflows/on_merged_pr.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,13 @@ on:
66
types:
77
- completed
88

9+
permissions:
10+
contents: read
11+
912
jobs:
1013
get_pr_details:
14+
permissions:
15+
id-token: write
1116
if: github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion == 'success'
1217
uses: ./.github/workflows/reusable_export_pr_details.yml
1318
with:
@@ -16,6 +21,8 @@ jobs:
1621
secrets:
1722
token: ${{ secrets.GITHUB_TOKEN }}
1823
release_label_on_merge:
24+
permissions:
25+
id-token: write
1926
needs: get_pr_details
2027
runs-on: ubuntu-latest
2128
if: needs.get_pr_details.outputs.prIsMerged == 'true'

.github/workflows/on_opened_pr.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,13 @@ on:
66
types:
77
- completed
88

9+
permissions:
10+
contents: read
11+
912
jobs:
1013
get_pr_details:
14+
permissions:
15+
id-token: write
1116
if: ${{ github.event.workflow_run.conclusion == 'success' }}
1217
uses: ./.github/workflows/reusable_export_pr_details.yml
1318
with:
@@ -16,6 +21,8 @@ jobs:
1621
secrets:
1722
token: ${{ secrets.GITHUB_TOKEN }}
1823
check_related_issue:
24+
permissions:
25+
id-token: write
1926
needs: get_pr_details
2027
runs-on: ubuntu-latest
2128
steps:

.github/workflows/rebuild_latest_docs.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ on:
1313
description: "Latest PyPi published version to rebuild latest docs for, e.g. 2.0.0"
1414
default: "2.0.0"
1515
required: true
16+
17+
permissions:
18+
contents: read
1619

1720
jobs:
1821
changelog:

.github/workflows/record_pr.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ on:
44
pull_request:
55
types: [opened, edited, closed]
66

7+
8+
permissions:
9+
contents: read
10+
711
jobs:
812
record_pr:
913
runs-on: ubuntu-latest

.github/workflows/release-drafter.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,13 @@ on:
66
- develop
77
workflow_dispatch:
88

9+
permissions:
10+
contents: read
11+
912
jobs:
1013
update_release_draft:
14+
permissions:
15+
id-token: write
1116
runs-on: ubuntu-latest
1217
steps:
1318
- uses: release-drafter/release-drafter@b1476f6e6eb133afa41ed8589daba6dc69b4d3f5 # v5.20.1

.github/workflows/reusable_export_pr_details.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,13 @@ on:
3636
description: "Whether PR is merged"
3737
value: ${{ jobs.export_pr_details.outputs.prIsMerged }}
3838

39+
permissions:
40+
contents: read
41+
3942
jobs:
4043
export_pr_details:
44+
permissions:
45+
id-token: write
4146
# see https://github.com/aws-powertools/powertools-lambda-python/issues/1349
4247
if: inputs.workflow_origin == 'aws-powertools/powertools-lambda-dotnet'
4348
runs-on: ubuntu-latest

.github/workflows/reusable_publish_changelog.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,15 @@ on:
44
workflow_call:
55

66
permissions:
7-
contents: write
7+
contents: read
88

99
env:
1010
BRANCH: develop
1111

1212
jobs:
1313
publish_changelog:
14+
permissions:
15+
contents: write
1416
# Force Github action to run only a single job at a time (based on the group name)
1517
# This is to prevent race-condition and inconsistencies with changelog push
1618
concurrency:

.github/workflows/reusable_publish_docs.yml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,13 @@ on:
2222
type: boolean
2323

2424
permissions:
25-
id-token: write
26-
contents: write
27-
pages: write
25+
contents: read
2826

2927
jobs:
3028
publish_docs:
29+
permissions:
30+
id-token: write
31+
contents: write
3132
# Force Github action to run only a single job at a time (based on the group name)
3233
# This is to prevent "race-condition" in publishing a new version of doc to `gh-pages`
3334
concurrency:
@@ -80,6 +81,9 @@ jobs:
8081
8182
8283
apidocs:
84+
permissions:
85+
id-token: write
86+
contents: write
8387
# Force Github action to run only a single job at a time (based on the group name)
8488
# This is to prevent "race-condition" in publishing a new version of doc to `gh-pages`
8589
concurrency:

.github/workflows/secure_workflows.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ on:
88
paths:
99
- ".github/workflows/**"
1010

11+
permissions:
12+
contents: read
13+
1114
jobs:
1215
enforce_pinned_workflows:
1316
name: Harden Security

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ deploy/**
1212
.vs/
1313
.aws-sam
1414

15+
node_modules/*
16+
1517
examples/SimpleLambda/.aws-sam
1618
examples/SimpleLambda/samconfig.toml
1719

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ WORKDIR $FUNCTION_DIR/examples/SimpleLambda/src/HelloWorld/
1919
RUN if [ "$SAM_BUILD_MODE" = "debug" ]; then dotnet lambda package --configuration Debug; else dotnet lambda package --configuration Release; fi
2020
RUN if [ "$SAM_BUILD_MODE" = "debug" ]; then cp -r /bin/Debug/net6.0/publish/* /build/build_artifacts; else cp -r bin/Release/net6.0/publish/* /build/build_artifacts; fi
2121

22-
FROM public.ecr.aws/lambda/dotnet:6
22+
FROM public.ecr.aws/lambda/dotnet@sha256:ec61a7f638e2a0c86d75204117cc7710bcdc70222ffc777e3fc1458287b09834
2323

2424
COPY --from=build-image /build/build_artifacts/ /var/task/
2525
# Command can be overwritten by providing a different command in the template directly.

0 commit comments

Comments
 (0)