Skip to content

Repository files navigation

GitHub MarketplaceWorkflowcodecovMIT license

Invoke AWS Lambda

This action allows you to synchronously invoke a Lambda function and get the response (if desired)..

Table of contents


Input parameters

Credentials

KeyTypeRequiredDescription
AWS_ACCESS_KEY_IDstringYesAccess Key ID
AWS_SECRET_ACCESS_KEYstringYesSecret Access Key
AWS_SESSION_TOKENstringNoSession Token
REGIONstringNoDefault us-east-1. Region where the Lambda function has been created.

AWS Security Credentials reference
AWS Temporary Credentials reference

Invocation

KeyTypeRequiredDescription
FunctionNamestringYesName of the Lambda function to be invoked.
InvocationTypeRequestResponse|
Event|
DryRun
NoDefault RequestResponse. See the AWS Javascript SDK docs for more info.
LogTypeTail|NoneNoDefault None. Set to Tail to include the execution log in the response.
PayloadstringNoJSON that you want to provide to your Lambda function as input.
QualifierstringNoVersion or alias of the function to be invoked.
ClientContextstringNoBase64-encoded data about the invoking client to pass to the function.
HTTP_TIMEOUTnumberNoSets the socket to timeout after timeout milliseconds of inactivity on the socket. Defaults to two minutes (120000). See the AWS Javascript SDK docs
MAX_RETRIESnumberNoReturns the maximum amount of retries to perform for a service request. By default this value is calculated by the specific service object that the request is being made to. AWS Javascript SDK docs
SUCCEED_ON_FUNCTION_FAILUREbooleanNoSet to true if this action should succeed when the Lambda function executed returns an error

For more details on the parameters accepted by Lambda.invoke(), see the AWS Javascript SDK docs


Output

This step will store the JSON response from the Lambda function invocation in outputs.response, with the following properties:

PropertyTypeDescription
StatusCodeintegerHTTP status code - 200 if successful
ExecutedVersionstringVersion or alias of function that was executed
PayloadstringJSON returned by the function invocation, or error object
LogResultstringBase64-encoded last 4KB of execution log, if LogType was set to Tail
FunctionErrorstringIf present, indicates that an error has occured, with more information in Payload

Note that you will have to parse the output using the fromJSONfunction before accessing individual properties.
See the Using Output example for more details.


Examples

Basic example

This step invokes a Lambda function without regard for the invocation output:

- name: Invoke foobarFunction Lambdauses: gagoar/invoke-aws-lambda@masterwith:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}FunctionName: foobarFunctionPayload: '{ "myParameter": false }'

Using output

These steps process the response payload by using step outputs:

- name: Invoke foobarFunction Lambdaid: foobaruses: gagoar/invoke-aws-lambda@masterwith:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}FunctionName: foobarFunctionPayload: '{ "myParameter": false }'
- name: Store response payload to filerun: echo '${{ fromJSON(steps.foobar.outputs.response).Payload }}' > invocation-response.json

Notice the addition of the id field to the invocation step.
For more information for Github Actions outputs, see their reference.

Specifying alias/version

This step invokes a Lambda function with the someAlias alias:

- name: Invoke foobarFunction Lambdauses: gagoar/invoke-aws-lambda@masterwith:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}FunctionName: foobarFunctionPayload: '{ "myParameter": false }'Qualifier: someAlias

Similarly, if we wanted to invoke version 53 in particular, we would use:

...
with:
...Qualifier: 53

Handling logs

These steps process logs returned from the invocation:

- name: Invoke foobarFunction Lambdaid: foobaruses: gagoar/invoke-aws-lambda@masterwith:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}FunctionName: foobarFunctionLogType: TailPayload: '{ "myParameter": false }'
- name: Store tail logs to filerun: echo "${{ fromJSON(steps.foobar.outputs.response).LogResult }}" > invocation-logs.json

About

github action to invoke aws lambda

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages