@pulumi/aws
Version:
A Pulumi package for creating and managing Amazon Web Services (AWS) cloud resources.
177 lines • 8.03 kB
JavaScript
;
// *** WARNING: this file was generated by pulumi-language-nodejs. ***
// *** Do not edit by hand unless you're certain you know what you are doing! ***
Object.defineProperty(exports, "__esModule", { value: true });
exports.LayerVersion = void 0;
const pulumi = require("@pulumi/pulumi");
const utilities = require("../utilities");
/**
* Manages 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
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as aws from "@pulumi/aws";
*
* const example = new aws.lambda.LayerVersion("example", {
* code: new pulumi.asset.FileArchive("lambda_layer_payload.zip"),
* layerName: "lambda_layer_name",
* compatibleRuntimes: ["nodejs20.x"],
* });
* ```
*
* ### Layer with S3 Source
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as aws from "@pulumi/aws";
*
* const example = new aws.lambda.LayerVersion("example", {
* s3Bucket: lambdaLayerZip.bucket,
* s3Key: lambdaLayerZip.key,
* layerName: "lambda_layer_name",
* compatibleRuntimes: [
* "nodejs20.x",
* "python3.12",
* ],
* compatibleArchitectures: [
* "x86_64",
* "arm64",
* ],
* });
* ```
*
* ### Layer with Multiple Runtimes and Architectures
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as aws from "@pulumi/aws";
* import * as std from "@pulumi/std";
*
* const example = new aws.lambda.LayerVersion("example", {
* code: new pulumi.asset.FileArchive("lambda_layer_payload.zip"),
* layerName: "multi_runtime_layer",
* description: "Shared utilities for Lambda functions",
* licenseInfo: "MIT",
* sourceCodeHash: std.filebase64sha256({
* input: "lambda_layer_payload.zip",
* }).then(invoke => invoke.result),
* compatibleRuntimes: [
* "nodejs18.x",
* "nodejs20.x",
* "python3.11",
* "python3.12",
* ],
* compatibleArchitectures: [
* "x86_64",
* "arm64",
* ],
* });
* ```
*
* ## Specifying the Deployment Package
*
* 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
*
* Using `pulumi import`, import Lambda Layers using `arn`. For example:
*
* ```sh
* $ pulumi import aws:lambda/layerVersion:LayerVersion example arn:aws:lambda:us-west-2:123456789012:layer:example:1
* ```
*/
class LayerVersion extends pulumi.CustomResource {
/**
* Get an existing LayerVersion resource's state with the given name, ID, and optional extra
* properties used to qualify the lookup.
*
* @param name The _unique_ name of the resulting resource.
* @param id The _unique_ provider ID of the resource to lookup.
* @param state Any extra arguments used during the lookup.
* @param opts Optional settings to control the behavior of the CustomResource.
*/
static get(name, id, state, opts) {
return new LayerVersion(name, state, { ...opts, id: id });
}
/**
* Returns true if the given object is an instance of LayerVersion. This is designed to work even
* when multiple copies of the Pulumi SDK have been loaded into the same process.
*/
static isInstance(obj) {
if (obj === undefined || obj === null) {
return false;
}
return obj['__pulumiType'] === LayerVersion.__pulumiType;
}
constructor(name, argsOrState, opts) {
let resourceInputs = {};
opts = opts || {};
if (opts.id) {
const state = argsOrState;
resourceInputs["arn"] = state?.arn;
resourceInputs["code"] = state?.code;
resourceInputs["codeSha256"] = state?.codeSha256;
resourceInputs["compatibleArchitectures"] = state?.compatibleArchitectures;
resourceInputs["compatibleRuntimes"] = state?.compatibleRuntimes;
resourceInputs["createdDate"] = state?.createdDate;
resourceInputs["description"] = state?.description;
resourceInputs["layerArn"] = state?.layerArn;
resourceInputs["layerName"] = state?.layerName;
resourceInputs["licenseInfo"] = state?.licenseInfo;
resourceInputs["region"] = state?.region;
resourceInputs["s3Bucket"] = state?.s3Bucket;
resourceInputs["s3Key"] = state?.s3Key;
resourceInputs["s3ObjectVersion"] = state?.s3ObjectVersion;
resourceInputs["signingJobArn"] = state?.signingJobArn;
resourceInputs["signingProfileVersionArn"] = state?.signingProfileVersionArn;
resourceInputs["skipDestroy"] = state?.skipDestroy;
resourceInputs["sourceCodeHash"] = state?.sourceCodeHash;
resourceInputs["sourceCodeSize"] = state?.sourceCodeSize;
resourceInputs["version"] = state?.version;
}
else {
const args = argsOrState;
if (args?.layerName === undefined && !opts.urn) {
throw new Error("Missing required property 'layerName'");
}
resourceInputs["code"] = args?.code;
resourceInputs["compatibleArchitectures"] = args?.compatibleArchitectures;
resourceInputs["compatibleRuntimes"] = args?.compatibleRuntimes;
resourceInputs["description"] = args?.description;
resourceInputs["layerName"] = args?.layerName;
resourceInputs["licenseInfo"] = args?.licenseInfo;
resourceInputs["region"] = args?.region;
resourceInputs["s3Bucket"] = args?.s3Bucket;
resourceInputs["s3Key"] = args?.s3Key;
resourceInputs["s3ObjectVersion"] = args?.s3ObjectVersion;
resourceInputs["skipDestroy"] = args?.skipDestroy;
resourceInputs["sourceCodeHash"] = args?.sourceCodeHash;
resourceInputs["arn"] = undefined /*out*/;
resourceInputs["codeSha256"] = undefined /*out*/;
resourceInputs["createdDate"] = undefined /*out*/;
resourceInputs["layerArn"] = undefined /*out*/;
resourceInputs["signingJobArn"] = undefined /*out*/;
resourceInputs["signingProfileVersionArn"] = undefined /*out*/;
resourceInputs["sourceCodeSize"] = undefined /*out*/;
resourceInputs["version"] = undefined /*out*/;
}
opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts);
super(LayerVersion.__pulumiType, name, resourceInputs, opts);
}
}
exports.LayerVersion = LayerVersion;
/** @internal */
LayerVersion.__pulumiType = 'aws:lambda/layerVersion:LayerVersion';
//# sourceMappingURL=layerVersion.js.map