Giter Site home page Giter Site logo

invoke-aws-lambda's Introduction

GitHub Marketplace Workflow codecov MIT 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

Key Type Required Description
AWS_ACCESS_KEY_ID string Yes Access Key ID
AWS_SECRET_ACCESS_KEY string Yes Secret Access Key
AWS_SESSION_TOKEN string No Session Token
REGION string No Default us-east-1. Region where the Lambda function has been created.

AWS Security Credentials reference
AWS Temporary Credentials reference

Invocation

Key Type Required Description
FunctionName string Yes Name of the Lambda function to be invoked.
InvocationType RequestResponse|
Event|
DryRun
No Default RequestResponse. See the AWS Javascript SDK docs for more info.
LogType Tail|None No Default None. Set to Tail to include the execution log in the response.
Payload string No JSON that you want to provide to your Lambda function as input.
Qualifier string No Version or alias of the function to be invoked.
ClientContext string No Base64-encoded data about the invoking client to pass to the function.
HTTP_TIMEOUT number No Sets the socket to timeout after timeout milliseconds of inactivity on the socket. Defaults to two minutes (120000). See the AWS Javascript SDK docs
MAX_RETRIES number No Returns 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_FAILURE boolean No Set 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:

Property Type Description
StatusCode integer HTTP status code - 200 if successful
ExecutedVersion string Version or alias of function that was executed
Payload string JSON returned by the function invocation, or error object
LogResult string Base64-encoded last 4KB of execution log, if LogType was set to Tail
FunctionError string If present, indicates that an error has occured, with more information in Payload

Note that you will have to parse the output using the fromJSON function 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 Lambda
  uses: gagoar/invoke-aws-lambda@master
  with:
    AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
    AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
    FunctionName: foobarFunction
    Payload: '{ "myParameter": false }'

Using output

These steps process the response payload by using step outputs:

- name: Invoke foobarFunction Lambda
  id: foobar
  uses: gagoar/invoke-aws-lambda@master
  with:
    AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
    AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
    FunctionName: foobarFunction
    Payload: '{ "myParameter": false }'
- name: Store response payload to file
  run: 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 Lambda
  uses: gagoar/invoke-aws-lambda@master
  with:
    AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
    AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
    FunctionName: foobarFunction
    Payload: '{ "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 Lambda
  id: foobar
  uses: gagoar/invoke-aws-lambda@master
  with:
    AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
    AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
    FunctionName: foobarFunction
    LogType: Tail
    Payload: '{ "myParameter": false }'
- name: Store tail logs to file
  run: echo "${{ fromJSON(steps.foobar.outputs.response).LogResult }}" > invocation-logs.json

invoke-aws-lambda's People

Contributors

cyamonide avatar dependabot[bot] avatar gagoar avatar renovate[bot] avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.