CloudBees action: Create or update an AWS Lambda function

3 minute read

Use this action to create or update a function in the Amazon Web Services (AWS) Lambda serverless architecture. Run code in AWS Lambda without provisioning or managing servers.

Prerequisites

Make sure to initialize the connection using your AWS credentials, by adding the following to your YAML file:

- name: Configure AWS credentials uses: cloudbees-io/configure-aws-credentials@v1 with: aws-access-key-id: ${{ secrets.MY_KEY_ID }} aws-secret-access-key: ${{ secrets.MY_SECRET_KEY }} aws-region: eu-west-3

Refer to CloudBees action: Configure AWS credentials for more information.

All CloudBees action repositories are listed at CloudBees, Inc. on GitHub.

Inputs

Table 1. Input details
Input name Data type Required? Description

architectures

JSON string

No

The instruction set architecture that the function supports.

code-image

String

Required only if using an image (package-type: Image).

The code image resource, such as the Amazon ECR repository URI.

code-signing-config-arn

String

No

The Amazon Resource Name (ARN) for a code-signing configuration.

code-zip

String

Required only if using a ZIP file (package-type: Zip).

The path to the ZIP file of the code to be uploaded.

dead-letter-config

JSON string

No

The location where the Lambda function sends asynchronous events that fail to process.

desc

String

No

The Lambda function description.

dry-run

Boolean

No

Default is false. Enables preview of changes to AWS CLI operations before applying the changes.

environment

JSON string

No

The environment variables accessible from the function code during execution.

ephemeral-storage

JSON string

No

The size of the Lambda function /tmp directory.

file-system-configs

JSON string

No

The Amazon EFS file system connection settings.

function-name

String

Yes

The AWS Lambda function name.

handler

String

Required only if using a ZIP file (package-type: Zip).

The method name in uploaded code that Lambda calls to run the function.

iam-role-arn

String

Yes

The Identity and Access Management (IAM) name of the function’s execution role, in ARN format.

image-config

JSON string

No

The container image configuration values that override the container image Dockerfile values.

kms-key-arn

String

No

The ARN of the AWS Key Management Service (KMS) customer-managed key used to encrypt your function’s environment variables.

layers

JSON string

No

The list of function layers to add to the Lambda functions execution environment.

memory-size

Integer

No

The amount of memory available to the Lambda function at runtime.

package-type

String

No

The type of build input artifact. Options are Zip (ZIP file) and Image (container image).

publish

Boolean

No

Default is true. Enables the first created version of the Lambda function.

revision-id

String

No

The latest updated revision ID. If specified, the Lambda function is only updated if the revision ID matches the latest updated revision ID. Use this option to avoid publishing a version if the function configuration has changed since you last updated it.

runtime

String

Required only if using a ZIP file (package-type: Zip).

The Lambda function runtime.

s3-bucket

String

Required only if using an Amazon S3 bucket.

The Amazon S3 bucket name.

s3-key

String

Required only if using an Amazon S3 bucket.

The Amazon S3 bucket object name.

s3-object-version

String

No

The Amazon S3 bucket object version.

snap-start

JSON string

No

The SnapStart configuration to run the Lambda function with a pre-initialized snapshot.

tags

JSON string

No

The Lambda function tag list.

timeout

Integer

No

The allowed amount of time, in seconds, that a Lambda function runs before it is stopped.

tracing-config

JSON string

No

The AWS X-Ray tracing configuration in the Lambda function. To sample and record incoming requests, enable X-ray Active tracing in the Lambda functions console.

vpc-config

JSON string

No

The VPC security groups and subnets for network connectivity to AWS resources.

Usage examples

Create/update an AWS Lambda function using an ECR image

In your YAML file, add:

- name: Create or update AWS lambda function with ECR id: createOrUpdateLambdaFunctionWithECR uses: cloudbees-io/lambda-create-function@v1 with: iam-role-arn: arn:aws:iam::123456789012:role/my-lambda-actions function-name: my-function package-type: Image code-image: 123456789012.dkr.ecr.us-west-2.amazonaws.com/hello-world-lambda:v1 architectures: '["x86_64"]'

Create or update an AWS Lambda function using an Amazon S3 bucket

In your YAML file, add:

- name: Create or update an AWS lambda function with S3 id: createOrUpdateLambdaFunctionWithS3 uses: cloudbees-io/lambda-create-function@v1 with: iam-role-arn: arn:aws:iam::123456789012:role/my-lambda-actions function-name: my-function package-type: Zip handler: bootstrap s3-bucket: my-lambda-actions s3-key: hello-lambda/bootstrap.zip s3-object-version: "" architectures: '["x86_64"]' runtime: provided.al2

Create or update an AWS Lambda function using a local ZIP file

In your YAML file, add:

- name: Create or update AWS lambda function with ZIP file id: createOrUpdateLambdaFunctionWithZip uses: cloudbees-io/lambda-create-function@v1 with: iam-role-arn: arn:aws:iam::123456789012:role/my-lambda-actions function-name: my-function package-type: Zip handler: bootstrap code-zip: ${{ cloudbees.workspace }}/bootstrap.zip architectures: '["x86_64", "arm64"]' runtime: provided.al2