Package com.pulumi.aws.lambda
Class LayerVersion
- java.lang.Object
-
- com.pulumi.resources.Resource
-
- com.pulumi.resources.CustomResource
-
- com.pulumi.aws.lambda.LayerVersion
-
public class LayerVersion extends com.pulumi.resources.CustomResourceManages an AWS Lambda Layer Version. Use this resource to share code and dependencies across multiple Lambda functions. For information about Lambda Layers and how to use them, see [AWS Lambda Layers](https://docs.aws.amazon.com/lambda/latest/dg/configuration-layers.html). > **Note:** Setting `skipDestroy` to `true` means that the AWS Provider will not destroy any layer version, even when running `pulumi destroy`. Layer versions are thus intentional dangling resources that are not managed by Pulumi and may incur extra expense in your AWS account. ## Example Usage ### Basic Layer
### Layer with S3 Sourcepackage 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.ArrayList; import java.util.Arrays; 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 example = new LayerVersion("example", LayerVersionArgs.builder() .code(new FileArchive("lambda_layer_payload.zip")) .layerName("lambda_layer_name") .compatibleRuntimes("nodejs24.x") .build()); } }
### Layer with Multiple Runtimes and Architecturespackage 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 java.util.ArrayList; import java.util.Arrays; 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 example = new LayerVersion("example", LayerVersionArgs.builder() .s3Bucket(lambdaLayerZip.bucket()) .s3Key(lambdaLayerZip.key()) .layerName("lambda_layer_name") .compatibleRuntimes( "nodejs24.x", "python3.12") .compatibleArchitectures( "x86_64", "arm64") .build()); } }
AWS Lambda Layers expect source code to be provided as a deployment package whose structure varies depending on which `compatibleRuntimes` this layer specifies. See [Runtimes](https://docs.aws.amazon.com/lambda/latest/dg/API_PublishLayerVersion.html#SSS-PublishLayerVersion-request-CompatibleRuntimes) for the valid values of `compatibleRuntimes`. 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 `s3Bucket`, `s3Key` and `s3ObjectVersion` 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 ### Identity Schema #### Required * `layerName` (String) Unique name for the Lambda Layer. * `version` (String) Lambda Layer version number. #### Optional * `accountId` (String) AWS Account where this resource is managed. * `region` (String) Region where this resource is managed. Using `pulumi import`, import Lambda Layer Versions using the `arn`. For example: ```sh $ pulumi import aws:lambda/layerVersion:LayerVersion example arn:aws:lambda:us-west-2:123456789012:layer:example:1 ```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.std.StdFunctions; import com.pulumi.std.inputs.Filebase64sha256Args; import com.pulumi.asset.FileArchive; import java.util.ArrayList; import java.util.Arrays; 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 example = new LayerVersion("example", LayerVersionArgs.builder() .code(new FileArchive("lambda_layer_payload.zip")) .layerName("multi_runtime_layer") .description("Shared utilities for Lambda functions") .licenseInfo("MIT") .sourceCodeHash(StdFunctions.filebase64sha256(Filebase64sha256Args.builder() .input("lambda_layer_payload.zip") .build()).result()) .compatibleRuntimes( "nodejs22.x", "nodejs24.x", "python3.11", "python3.12") .compatibleArchitectures( "x86_64", "arm64") .build()); } }
-
-
Constructor Summary
Constructors Constructor Description LayerVersion(java.lang.String name)LayerVersion(java.lang.String name, LayerVersionArgs args)LayerVersion(java.lang.String name, LayerVersionArgs args, com.pulumi.resources.CustomResourceOptions options)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description com.pulumi.core.Output<java.lang.String>arn()com.pulumi.core.Output<java.util.Optional<com.pulumi.asset.Archive>>code()com.pulumi.core.Output<java.lang.String>codeSha256()com.pulumi.core.Output<java.util.Optional<java.util.List<java.lang.String>>>compatibleArchitectures()com.pulumi.core.Output<java.util.Optional<java.util.List<java.lang.String>>>compatibleRuntimes()com.pulumi.core.Output<java.lang.String>createdDate()com.pulumi.core.Output<java.util.Optional<java.lang.String>>description()static LayerVersionget(java.lang.String name, com.pulumi.core.Output<java.lang.String> id, LayerVersionState state, com.pulumi.resources.CustomResourceOptions options)Get an existing Host resource's state with the given name, ID, and optional extra properties used to qualify the lookup.com.pulumi.core.Output<java.lang.String>layerArn()com.pulumi.core.Output<java.lang.String>layerName()com.pulumi.core.Output<java.util.Optional<java.lang.String>>licenseInfo()com.pulumi.core.Output<java.lang.String>region()com.pulumi.core.Output<java.util.Optional<java.lang.String>>s3Bucket()com.pulumi.core.Output<java.util.Optional<java.lang.String>>s3Key()com.pulumi.core.Output<java.util.Optional<java.lang.String>>s3ObjectVersion()com.pulumi.core.Output<java.lang.String>signingJobArn()com.pulumi.core.Output<java.lang.String>signingProfileVersionArn()com.pulumi.core.Output<java.util.Optional<java.lang.Boolean>>skipDestroy()com.pulumi.core.Output<java.lang.String>sourceCodeHash()com.pulumi.core.Output<java.lang.Integer>sourceCodeSize()com.pulumi.core.Output<java.lang.String>version()
-
-
-
Constructor Detail
-
LayerVersion
public LayerVersion(java.lang.String name)
- Parameters:
name- The _unique_ name of the resulting resource.
-
LayerVersion
public LayerVersion(java.lang.String name, LayerVersionArgs args)- Parameters:
name- The _unique_ name of the resulting resource.args- The arguments to use to populate this resource's properties.
-
LayerVersion
public LayerVersion(java.lang.String name, LayerVersionArgs args, @Nullable com.pulumi.resources.CustomResourceOptions options)- Parameters:
name- The _unique_ name of the resulting resource.args- The arguments to use to populate this resource's properties.options- A bag of options that control this resource's behavior.
-
-
Method Detail
-
arn
public com.pulumi.core.Output<java.lang.String> arn()
- Returns:
- ARN of the Lambda Layer with version.
-
code
public com.pulumi.core.Output<java.util.Optional<com.pulumi.asset.Archive>> code()
- Returns:
- Path to the function's deployment package within the local filesystem. If defined, The `s3_`-prefixed options cannot be used.
-
codeSha256
public com.pulumi.core.Output<java.lang.String> codeSha256()
- Returns:
- Base64-encoded representation of raw SHA-256 sum of the zip file.
-
compatibleArchitectures
public com.pulumi.core.Output<java.util.Optional<java.util.List<java.lang.String>>> compatibleArchitectures()
- Returns:
- List of [Architectures](https://docs.aws.amazon.com/lambda/latest/dg/API_PublishLayerVersion.html#SSS-PublishLayerVersion-request-CompatibleArchitectures) this layer is compatible with. Currently `x8664` and `arm64` can be specified.
-
compatibleRuntimes
public com.pulumi.core.Output<java.util.Optional<java.util.List<java.lang.String>>> compatibleRuntimes()
- Returns:
- List of [Runtimes](https://docs.aws.amazon.com/lambda/latest/dg/API_PublishLayerVersion.html#SSS-PublishLayerVersion-request-CompatibleRuntimes) this layer is compatible with. Up to 15 runtimes can be specified.
-
createdDate
public com.pulumi.core.Output<java.lang.String> createdDate()
- Returns:
- Date this resource was created.
-
description
public com.pulumi.core.Output<java.util.Optional<java.lang.String>> description()
- Returns:
- Description of what your Lambda Layer does.
-
layerArn
public com.pulumi.core.Output<java.lang.String> layerArn()
- Returns:
- ARN of the Lambda Layer without version.
-
layerName
public com.pulumi.core.Output<java.lang.String> layerName()
- Returns:
- Unique name for your Lambda Layer. The following arguments are optional:
-
licenseInfo
public com.pulumi.core.Output<java.util.Optional<java.lang.String>> licenseInfo()
- Returns:
- License info for your Lambda Layer. See [License Info](https://docs.aws.amazon.com/lambda/latest/dg/API_PublishLayerVersion.html#SSS-PublishLayerVersion-request-LicenseInfo).
-
region
public com.pulumi.core.Output<java.lang.String> region()
- Returns:
- Region where this resource will be [managed](https://docs.aws.amazon.com/general/latest/gr/rande.html#regional-endpoints). Defaults to the Region set in the provider configuration.
-
s3Bucket
public com.pulumi.core.Output<java.util.Optional<java.lang.String>> s3Bucket()
- Returns:
- S3 bucket location containing the function's deployment package. Conflicts with `filename`. This bucket must reside in the same AWS region where you are creating the Lambda function.
-
s3Key
public com.pulumi.core.Output<java.util.Optional<java.lang.String>> s3Key()
- Returns:
- S3 key of an object containing the function's deployment package. Conflicts with `filename`.
-
s3ObjectVersion
public com.pulumi.core.Output<java.util.Optional<java.lang.String>> s3ObjectVersion()
- Returns:
- Object version containing the function's deployment package. Conflicts with `filename`.
-
signingJobArn
public com.pulumi.core.Output<java.lang.String> signingJobArn()
- Returns:
- ARN of a signing job.
-
signingProfileVersionArn
public com.pulumi.core.Output<java.lang.String> signingProfileVersionArn()
- Returns:
- ARN for a signing profile version.
-
skipDestroy
public com.pulumi.core.Output<java.util.Optional<java.lang.Boolean>> skipDestroy()
- Returns:
- 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 `compatibleArchitectures`, `compatibleRuntimes`, `description`, `filename`, `layerName`, `licenseInfo`, `s3Bucket`, `s3Key`, `s3ObjectVersion`, or `sourceCodeHash` forces deletion of the existing layer version and creation of a new layer version.
-
sourceCodeHash
public com.pulumi.core.Output<java.lang.String> sourceCodeHash()
- Returns:
- 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 `s3Key`. The usual way to set this is `filebase64sha256("file.zip")` or `base64sha256(file("file.zip"))`, where "file.zip" is the local filename of the lambda layer source archive.
-
sourceCodeSize
public com.pulumi.core.Output<java.lang.Integer> sourceCodeSize()
- Returns:
- Size in bytes of the function .zip file.
-
version
public com.pulumi.core.Output<java.lang.String> version()
- Returns:
- Lambda Layer version.
-
get
public static LayerVersion get(java.lang.String name, com.pulumi.core.Output<java.lang.String> id, @Nullable LayerVersionState state, @Nullable com.pulumi.resources.CustomResourceOptions options)
Get an existing Host resource's state with the given name, ID, and optional extra properties used to qualify the lookup.- Parameters:
name- The _unique_ name of the resulting resource.id- The _unique_ provider ID of the resource to lookup.state-options- Optional settings to control the behavior of the CustomResource.
-
-