GithubHelp home page GithubHelp 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

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

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

invoke-aws-lambda's Issues

AWS Secrets should be treated as GitHub Workflow secrets

Currently both AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY are not treated as secrets within the GitHub workflow ecosystem. This is a security risk that could lead to these being leaked in logs/etc.

This is probably going to be hard to change since existing users probably are not using a specific version of the workflow but rather following the README example and using gagoar/invoke-aws-lambda@master.

File not found: '/home/runner/work/_actions/gagoar/invoke-aws-lambda/master/dist/index.js'

We using this action:

steps:
      - name: Invoke foobarFunction Lambda
        uses: gagoar/invoke-aws-lambda@master
        with:
          AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
          InvocationType: 'Event'
          AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
          FunctionName: my-trigger
          Payload: ${{ toJson(github) }}

And it works perfect almost for a year.
Just right now we got an error: File not found: '/home/runner/work/_actions/gagoar/invoke-aws-lambda/master/dist/index.js'

Error: read ECONNRESET

Hello,
I have some tests running on aws lambda and lately they've been failing with the following message:

Run gagoar/[email protected] with: FunctionName: BackendTests REGION: eu-west-1 AWS_ACCESS_KEY_ID: *** AWS_SECRET_ACCESS_KEY: *** SUCCEED_ON_FUNCTION_FAILURE: false MAX_RETRIES: 0 HTTP_TIMEOUT: 12000000 LogType: Tail Payload: [{"suite": "shipments","verbose": true},{"suite": "shipment-list","verbose": true},{"suite": "shipment-api","verbose": true}] InvocationType: RequestResponse Error: read ECONNRESET
This error seems to happen after around 4-5 minutes even though I set HTTP_TIMEOUT to a very high number and my tests are passing.

Action Required: Fix Renovate Configuration

There is an error with this repository's Renovate configuration that needs to be fixed. As a precaution, Renovate will stop PRs until it is resolved.

Location: renovate.json
Error type: The renovate configuration file contains some invalid settings
Message: matchPackagePrefixes: matchPackagePrefixes should be inside a 'packageRule' only

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Rate-Limited

These updates are currently rate-limited. Click on a checkbox below to force their creation now.

  • Update dependency utf-8-validate to v5.0.10
  • Update actions/setup-node action to v3.8.2
  • Update dependency aws-sdk to v2.1663.0
  • Update dependency node to v16.20.2 (node, @types/node)
  • Update dependency pretty-quick to v3.3.1
  • Update dependency tslib to v2.6.3
  • Update eslint packages (eslint, eslint-config-prettier)
  • Update actions/checkout action to v4
  • Update actions/setup-node action to v4
  • Update codecov/codecov-action action to v4
  • Update dependency husky to v9
  • Update dependency lint-staged to v15
  • Update dependency node to v20 (node, @types/node)
  • Update dependency prettier to v3
  • Update dependency prettier-eslint to v16
  • Update dependency prettier-eslint-cli to v8
  • Update dependency pretty-quick to v4
  • Update dependency typescript to v5
  • Update dependency utf-8-validate to v6
  • Update eslint packages (major) (eslint, eslint-config-prettier, eslint-plugin-prettier)
  • Update jest monorepo to v29 (major) (@types/jest, jest, ts-jest)
  • Update typescript-eslint monorepo to v7 (major) (@typescript-eslint/eslint-plugin, @typescript-eslint/parser)
  • ๐Ÿ” Create all rate-limited PRs at once ๐Ÿ”

Edited/Blocked

These updates have been manually edited so Renovate will no longer make changes. To discard all commits and start over, click on a checkbox.

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Ignored or Blocked

These are blocked by an existing closed PR and will not be recreated unless you click a checkbox below.

Detected dependencies

github-actions
.github/workflows/build_project.yml
  • actions/setup-node v3
.github/workflows/lint.yml
  • actions/setup-node v3
.github/workflows/rebuild_dist.yml
  • actions/checkout v3
  • actions/setup-node v3.5.1
  • jnwng/github-app-installation-token-action v2
.github/workflows/release.yml
  • actions/checkout v3
  • actions/create-release v1
.github/workflows/renovate.yml
.github/workflows/unit-tests.yml
  • actions/setup-node v3
  • codecov/codecov-action v3
npm
package.json
  • @actions/core ^1.10.0
  • aws-sdk ^2.681.0
  • @types/jest 27.5.2
  • @types/node 16.11.57
  • @typescript-eslint/eslint-plugin 5.23.0
  • @typescript-eslint/parser 5.23.0
  • ajv-keywords 5.1.0
  • bufferutil 4.0.6
  • esbuild 0.14.44
  • eslint 8.23.0
  • eslint-config-prettier 8.5.0
  • eslint-plugin-prettier 4.2.1
  • husky 7.0.4
  • jest 28.1.1
  • lint-staged 10.5.3
  • prettier 2.6.2
  • prettier-eslint 13.0.0
  • prettier-eslint-cli 5.0.1
  • pretty-quick 3.1.3
  • ts-jest 28.0.5
  • ts-node 10.7.0
  • tslib 2.4.0
  • typescript 4.6.4
  • utf-8-validate 5.0.9
  • ws 7.5.7
  • node >12.0.0
nvm
.nvmrc
  • node 16.17.0

  • Check this box to trigger a request for Renovate to run again on this repository

OpenID Credential Configuration

Currently when utilizing OpenID instead of the standard Key_ID/Access_key workflow fails with

Missing credentials in config, if using AWS_CONFIG_FILE, set AWS_SDK_LOAD_CONFIG=1

would be nice to be able to grab credentials from "aws-actions/configure-aws-credentials@v1" if not using id/key in aws configuration.

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.