Layer Version
Provides a Lambda Layer Version resource. Lambda Layers allow you to reuse shared bits of code across multiple lambda functions. For information about Lambda Layers and how to use them, see AWS Lambda Layers.
NOTE: Setting
skip_destroy
totrue
means that the AWS Provider will not destroy any layer version, even when running destroy. Layer versions are thus intentional dangling resources that are not managed by the provider and may incur extra expense in your AWS account.
Example Usage
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
const lambdaLayer = new aws.lambda.LayerVersion("lambda_layer", {
code: new pulumi.asset.FileArchive("lambda_layer_payload.zip"),
layerName: "lambda_layer_name",
compatibleRuntimes: ["nodejs20.x"],
});
import pulumi
import pulumi_aws as aws
lambda_layer = aws.lambda_.LayerVersion("lambda_layer",
code=pulumi.FileArchive("lambda_layer_payload.zip"),
layer_name="lambda_layer_name",
compatible_runtimes=["nodejs20.x"])
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Aws = Pulumi.Aws;
return await Deployment.RunAsync(() =>
{
var lambdaLayer = new Aws.Lambda.LayerVersion("lambda_layer", new()
{
Code = new FileArchive("lambda_layer_payload.zip"),
LayerName = "lambda_layer_name",
CompatibleRuntimes = new[]
{
"nodejs20.x",
},
});
});
package main
import (
"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/lambda"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
_, err := lambda.NewLayerVersion(ctx, "lambda_layer", &lambda.LayerVersionArgs{
Code: pulumi.NewFileArchive("lambda_layer_payload.zip"),
LayerName: pulumi.String("lambda_layer_name"),
CompatibleRuntimes: pulumi.StringArray{
pulumi.String("nodejs20.x"),
},
})
if err != nil {
return err
}
return nil
})
}
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.lambda.LayerVersion;
import com.pulumi.aws.lambda.LayerVersionArgs;
import com.pulumi.asset.FileArchive;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
var lambdaLayer = new LayerVersion("lambdaLayer", LayerVersionArgs.builder()
.code(new FileArchive("lambda_layer_payload.zip"))
.layerName("lambda_layer_name")
.compatibleRuntimes("nodejs20.x")
.build());
}
}
resources:
lambdaLayer:
type: aws:lambda:LayerVersion
name: lambda_layer
properties:
code:
fn::FileArchive: lambda_layer_payload.zip
layerName: lambda_layer_name
compatibleRuntimes:
- nodejs20.x
Specifying the Deployment Package
AWS Lambda Layers expect source code to be provided as a deployment package whose structure varies depending on which compatible_runtimes
this layer specifies. See Runtimes for the valid values of compatible_runtimes
. Once you have created your deployment package you can specify it either directly as a local file (using the filename
argument) or indirectly via Amazon S3 (using the s3_bucket
, s3_key
and s3_object_version
arguments). When providing the deployment package via S3 it may be useful to use the aws.s3.BucketObjectv2
resource to upload it. For larger deployment packages it is recommended by Amazon to upload via S3, since the S3 API has better support for uploading large files efficiently.
Import
Using pulumi import
, import Lambda Layers using arn
. For example:
$ pulumi import aws:lambda/layerVersion:LayerVersion test_layer arn:aws:lambda:_REGION_:_ACCOUNT_ID_:layer:_LAYER_NAME_:_LAYER_VERSION_
Properties
Base64-encoded representation of raw SHA-256 sum of the zip file.
List of Architectures this layer is compatible with. Currently x86_64
and arm64
can be specified.
List of Runtimes this layer is compatible with. Up to 15 runtimes can be specified.
Date this resource was created.
Description of what your Lambda Layer does.
License info for your Lambda Layer. See License Info.
Object version containing the function's deployment package. Conflicts with filename
.
ARN of a signing job.
ARN for a signing profile version.
Whether to retain the old version of a previously deployed Lambda Layer. Default is false
. When this is not set to true
, changing any of compatible_architectures
, compatible_runtimes
, description
, filename
, layer_name
, license_info
, s3_bucket
, s3_key
, s3_object_version
, or source_code_hash
forces deletion of the existing layer version and creation of a new layer version.
Virtual attribute used to trigger replacement when source code changes. Must be set to a base64-encoded SHA256 hash of the package file specified with either filename
or s3_key
.
Size in bytes of the function .zip file.