Repository navigation
62 lines (53 loc) · 1.86 KB
/
Copy pathinvoke-lambda.yml
File metadata and controls
62 lines (53 loc) · 1.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
name: Invoke dummy Lambda
on:
push:
branches: [main]
workflow_dispatch:
inputs:
should_fail:
description: Request a Lambda execution failure (the workflow should fail)
type: boolean
default: false
permissions:
id-token: write
jobs:
invoke:
runs-on: ubuntu-latest
timeout-minutes: 5
env:
AWS_ROLE_ARN: ${{ secrets.AWS_ROLE_ARN }}
AWS_REGION: eu-north-1
FUNCTION_NAME: lambda-oidc-invoke-dummy
SHOULD_FAIL: ${{ toJSON(inputs.should_fail || false) }}
steps:
- name: Check configuration
run: |
if [[ -z "$AWS_ROLE_ARN" ]]; then
echo "::error::Set the AWS_ROLE_ARN repository secret to the GitHub OIDC role ARN."
exit 1
fi
- name: Authenticate to AWS with OIDC
uses: aws-actions/configure-aws-credentials@v6.3.0
with:
role-to-assume: ${{ env.AWS_ROLE_ARN }}
aws-region: ${{ env.AWS_REGION }}
role-session-name: github-lambda-${{ github.run_id }}
mask-aws-account-id: true
- name: Invoke dummy Lambda
run: |
payload=$(jq -nc --argjson shouldFail "$SHOULD_FAIL" \
'{hello: "github", shouldFail: $shouldFail}')
aws lambda invoke \
--function-name "$FUNCTION_NAME" \
--invocation-type RequestResponse \
--cli-binary-format raw-in-base64-out \
--payload "$payload" \
response.json > invocation.json
cat invocation.json
cat response.json
if ! jq -e '.StatusCode == 200 and (has("FunctionError") | not)' invocation.json; then
echo "::error::Lambda invocation or handler execution failed. See the response above."
exit 1
fi
jq -e --argjson expected "$payload" \
'. == {ok: true, payload: $expected}' response.json