AWS Lambda Plugin

The plugin provides functionality to interact with AWS Lambda.

Installation

  1. Copy the below line to dependencies section of the project build.gradle file

    Example 1. build.gradle
    implementation(group: 'org.vividus', name: 'vividus-plugin-aws-lambda', version: '0.5.1')
  2. If the project was imported to the IDE before adding new plugin, re-generate the configuration files for the used IDE and then refresh the project in the used IDE.

Configuration

Authentication

The plugin attempts to find AWS credentials by using the default credential provider chain. The provider chain looks for credentials using the provided below options one by one starting from the top. If credentials are found at some point, the search stops and further options are not evaluated.

  1. Environment variables: AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY (the optional variable for session token is AWS_SESSION_TOKEN).

  2. The properties: system.aws.accessKeyId and system.aws.secretKey (the optional property for session token is system.aws.sessionToken).

  3. Web Identity Token credentials from the environment or container.

  4. In the default credentials file (the location of this file varies by platform).

  5. Credentials delivered through the Amazon EC2 container service if the AWS_CONTAINER_CREDENTIALS_RELATIVE_URI environment variable is set and security manager has permission to access the variable.

  6. In the instance profile credentials, which exist within the instance metadata associated with the IAM role for the EC2 instance. This step is available only when running your application on an Amazon EC2 instance, but provides the greatest ease of use and best security when working with Amazon EC2 instances.

  7. If the plugin still hasn’t found credentials by this point, client creation fails with an exception.

See the official "Working with AWS Credentials" guide to get more details.

Region Selection

The plugin attempts to find AWS region by using the default region provider chain. The provider chain looks for a region using the provided below options one by one starting from the top. If region is found at some point, the search stops and further options are not evaluated.

  1. Environment variable: AWS_REGION.

  2. The property: system.aws.region.

  3. AWS shared configuration file (usually located at ~/.aws/config).

  4. Use the Amazon EC2 instance metadata service to determine the region of the currently running Amazon EC2 instance.

  5. If the plugin still hasn’t found a region by this point, client creation fails with an exception.

See the official "AWS Region Selection" guide to get more details.

Steps

Invoke AWS Lambda function

Invoke AWS Lambda function by providing the function name and the payload to pass to the Lambda function.

When I invoke AWS Lambda function `$functionName` with payload `$payload` and save result to $scopes variable `$variableName`
  • $functionName - The name of AWS Lambda function, version, or alias. The value can be retrieved by looking at the function in the AWS Console. Supported name formats:

    • Function name: my-function (name-only), my-function:v1 (with alias).

    • Function ARN: arn:aws:lambda:us-west-2:123456789012:function:my-function.

    • Partial ARN: 123456789012:function:my-function.

      It’s allowed to append a version number or alias to any of the formats. The length constraint applies only to the full ARN. If only the function name is specified, it is limited to 64 characters in length.

  • $payload - The JSON that to provide to AWS Lambda function as input. Vividus performs a Base64 encoding on this field before sending this request to the AWS service. Users should not perform Base64 encoding on this field.

  • $scopes - The comma-separated set of the variables scopes.

  • $variableName - The variable name to store results. If the variable name is my-var, the following variables will be created:

    • ${my-var.payload} - the response from the function, or an error object

    • ${my-var.status-code} - the HTTP status code is in the 200 range for a successful request

    • ${my-var.log-result} - the last 4 KB of the execution log

    • ${my-var.executed-version} - the version of the function that executed, when it’s invoked a function with an alias, this indicates which version the alias resolved to

    • ${my-var.function-error} - if present, indicates that an error occurred during function execution, details about the error are included in the response payload

Example 2. Invoke AWS Lambda
When I invoke AWS Lambda function `arn:aws:lambda:us-west-2:123456789012:function:my-function` with payload `
{
  "Hello ": "Paris",
  "countryCode": "FR"
}
` and save result to scenario variable `my-function-result`