UNPKG

@pulumi/aws

Version:

A Pulumi package for creating and managing Amazon Web Services (AWS) cloud resources.

311 lines (310 loc) • 11 kB
import * as pulumi from "@pulumi/pulumi"; /** * Provides details about an AWS Lambda Layer Version. Use this data source to retrieve information about a specific layer version or find the latest version compatible with your runtime and architecture requirements. * * ## Example Usage * * ### Get Latest Layer Version * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as aws from "@pulumi/aws"; * * const example = aws.lambda.getLayerVersion({ * layerName: "my-shared-utilities", * }); * // Use the layer in a Lambda function * const exampleFunction = new aws.lambda.Function("example", { * code: new pulumi.asset.FileArchive("function.zip"), * name: "example_function", * role: lambdaRole.arn, * handler: "index.handler", * runtime: aws.lambda.Runtime.NodeJS20dX, * layers: [example.then(example => example.arn)], * }); * ``` * * ### Get Specific Layer Version * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as aws from "@pulumi/aws"; * * const example = aws.lambda.getLayerVersion({ * layerName: "production-utilities", * version: 5, * }); * export const layerInfo = { * arn: example.then(example => example.arn), * version: example.then(example => example.version), * description: example.then(example => example.description), * }; * ``` * * ### Get Latest Compatible Layer Version * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as aws from "@pulumi/aws"; * * // Find latest layer version compatible with Python 3.12 * const pythonLayer = aws.lambda.getLayerVersion({ * layerName: "python-dependencies", * compatibleRuntime: "python3.12", * }); * // Find latest layer version compatible with ARM64 architecture * const armLayer = aws.lambda.getLayerVersion({ * layerName: "optimized-libraries", * compatibleArchitecture: "arm64", * }); * // Use both layers in a function * const example = new aws.lambda.Function("example", { * code: new pulumi.asset.FileArchive("function.zip"), * name: "multi_layer_function", * role: lambdaRole.arn, * handler: "app.handler", * runtime: aws.lambda.Runtime.Python3d12, * architectures: ["arm64"], * layers: [ * pythonLayer.then(pythonLayer => pythonLayer.arn), * armLayer.then(armLayer => armLayer.arn), * ], * }); * ``` * * ### Compare Layer Versions * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as aws from "@pulumi/aws"; * * // Get latest version * const latest = aws.lambda.getLayerVersion({ * layerName: "shared-layer", * }); * // Get specific version for comparison * const stable = aws.lambda.getLayerVersion({ * layerName: "shared-layer", * version: 3, * }); * const useLatestLayer = latest.then(latest => latest.version > 5); * const selectedLayer = useLatestLayer ? latest.then(latest => latest.arn) : stable.then(stable => stable.arn); * export const selectedLayerVersion = useLatestLayer ? latest.then(latest => latest.version) : stable.then(stable => stable.version); * ``` */ export declare function getLayerVersion(args: GetLayerVersionArgs, opts?: pulumi.InvokeOptions): Promise<GetLayerVersionResult>; /** * A collection of arguments for invoking getLayerVersion. */ export interface GetLayerVersionArgs { /** * Specific architecture the layer version must support. Conflicts with `version`. If specified, the latest available layer version supporting the provided architecture will be used. */ compatibleArchitecture?: string; /** * Specific runtime the layer version must support. Conflicts with `version`. If specified, the latest available layer version supporting the provided runtime will be used. */ compatibleRuntime?: string; /** * Name of the Lambda layer. * * The following arguments are optional: */ layerName: string; /** * 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. */ region?: string; /** * Specific layer version. Conflicts with `compatibleRuntime` and `compatibleArchitecture`. If omitted, the latest available layer version will be used. */ version?: number; } /** * A collection of values returned by getLayerVersion. */ export interface GetLayerVersionResult { /** * ARN of the Lambda Layer with version. */ readonly arn: string; /** * Base64-encoded representation of raw SHA-256 sum of the zip file. */ readonly codeSha256: string; readonly compatibleArchitecture?: string; /** * List of [Architectures](https://docs.aws.amazon.com/lambda/latest/dg/API_GetLayerVersion.html#SSS-GetLayerVersion-response-CompatibleArchitectures) the specific Lambda Layer version is compatible with. */ readonly compatibleArchitectures: string[]; readonly compatibleRuntime?: string; /** * List of [Runtimes](https://docs.aws.amazon.com/lambda/latest/dg/API_GetLayerVersion.html#SSS-GetLayerVersion-response-CompatibleRuntimes) the specific Lambda Layer version is compatible with. */ readonly compatibleRuntimes: string[]; /** * Date this resource was created. */ readonly createdDate: string; /** * Description of the specific Lambda Layer version. */ readonly description: string; /** * The provider-assigned unique ID for this managed resource. */ readonly id: string; /** * ARN of the Lambda Layer without version. */ readonly layerArn: string; readonly layerName: string; /** * License info associated with the specific Lambda Layer version. */ readonly licenseInfo: string; readonly region: string; /** * ARN of a signing job. */ readonly signingJobArn: string; /** * ARN for a signing profile version. */ readonly signingProfileVersionArn: string; /** * (**Deprecated** use `codeSha256` instead) Base64-encoded representation of raw SHA-256 sum of the zip file. * * @deprecated source_code_hash is deprecated. Use codeSha256 instead. */ readonly sourceCodeHash: string; /** * Size in bytes of the function .zip file. */ readonly sourceCodeSize: number; /** * Lambda Layer version. */ readonly version: number; } /** * Provides details about an AWS Lambda Layer Version. Use this data source to retrieve information about a specific layer version or find the latest version compatible with your runtime and architecture requirements. * * ## Example Usage * * ### Get Latest Layer Version * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as aws from "@pulumi/aws"; * * const example = aws.lambda.getLayerVersion({ * layerName: "my-shared-utilities", * }); * // Use the layer in a Lambda function * const exampleFunction = new aws.lambda.Function("example", { * code: new pulumi.asset.FileArchive("function.zip"), * name: "example_function", * role: lambdaRole.arn, * handler: "index.handler", * runtime: aws.lambda.Runtime.NodeJS20dX, * layers: [example.then(example => example.arn)], * }); * ``` * * ### Get Specific Layer Version * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as aws from "@pulumi/aws"; * * const example = aws.lambda.getLayerVersion({ * layerName: "production-utilities", * version: 5, * }); * export const layerInfo = { * arn: example.then(example => example.arn), * version: example.then(example => example.version), * description: example.then(example => example.description), * }; * ``` * * ### Get Latest Compatible Layer Version * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as aws from "@pulumi/aws"; * * // Find latest layer version compatible with Python 3.12 * const pythonLayer = aws.lambda.getLayerVersion({ * layerName: "python-dependencies", * compatibleRuntime: "python3.12", * }); * // Find latest layer version compatible with ARM64 architecture * const armLayer = aws.lambda.getLayerVersion({ * layerName: "optimized-libraries", * compatibleArchitecture: "arm64", * }); * // Use both layers in a function * const example = new aws.lambda.Function("example", { * code: new pulumi.asset.FileArchive("function.zip"), * name: "multi_layer_function", * role: lambdaRole.arn, * handler: "app.handler", * runtime: aws.lambda.Runtime.Python3d12, * architectures: ["arm64"], * layers: [ * pythonLayer.then(pythonLayer => pythonLayer.arn), * armLayer.then(armLayer => armLayer.arn), * ], * }); * ``` * * ### Compare Layer Versions * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as aws from "@pulumi/aws"; * * // Get latest version * const latest = aws.lambda.getLayerVersion({ * layerName: "shared-layer", * }); * // Get specific version for comparison * const stable = aws.lambda.getLayerVersion({ * layerName: "shared-layer", * version: 3, * }); * const useLatestLayer = latest.then(latest => latest.version > 5); * const selectedLayer = useLatestLayer ? latest.then(latest => latest.arn) : stable.then(stable => stable.arn); * export const selectedLayerVersion = useLatestLayer ? latest.then(latest => latest.version) : stable.then(stable => stable.version); * ``` */ export declare function getLayerVersionOutput(args: GetLayerVersionOutputArgs, opts?: pulumi.InvokeOutputOptions): pulumi.Output<GetLayerVersionResult>; /** * A collection of arguments for invoking getLayerVersion. */ export interface GetLayerVersionOutputArgs { /** * Specific architecture the layer version must support. Conflicts with `version`. If specified, the latest available layer version supporting the provided architecture will be used. */ compatibleArchitecture?: pulumi.Input<string>; /** * Specific runtime the layer version must support. Conflicts with `version`. If specified, the latest available layer version supporting the provided runtime will be used. */ compatibleRuntime?: pulumi.Input<string>; /** * Name of the Lambda layer. * * The following arguments are optional: */ layerName: pulumi.Input<string>; /** * 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. */ region?: pulumi.Input<string>; /** * Specific layer version. Conflicts with `compatibleRuntime` and `compatibleArchitecture`. If omitted, the latest available layer version will be used. */ version?: pulumi.Input<number>; }