@pulumi/aws
Version:
A Pulumi package for creating and managing Amazon Web Services (AWS) cloud resources.
186 lines • 7.82 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.LayerVersionPermission = void 0;
const pulumi = require("@pulumi/pulumi");
const utilities = require("../utilities");
/**
* Manages an AWS Lambda Layer Version Permission. Use this resource to share Lambda Layers with other AWS accounts, organizations, or make them publicly accessible.
*
* For information about Lambda Layer Permissions and how to use them, see [Using Resource-based Policies for AWS Lambda](https://docs.aws.amazon.com/lambda/latest/dg/access-control-resource-based.html#permissions-resource-xaccountlayer).
*
* > **Note:** Setting `skipDestroy` to `true` means that the AWS Provider will not destroy any layer version permission, even when running `pulumi destroy`. Layer version permissions are thus intentional dangling resources that are not managed by Pulumi and may incur extra expense in your AWS account.
*
* ## Example Usage
*
* ### Share Layer with Specific Account
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as aws from "@pulumi/aws";
*
* // Lambda layer to share
* const example = new aws.lambda.LayerVersion("example", {
* code: new pulumi.asset.FileArchive("layer.zip"),
* layerName: "shared_utilities",
* description: "Common utilities for Lambda functions",
* compatibleRuntimes: [
* "nodejs20.x",
* "python3.12",
* ],
* });
* // Grant permission to specific AWS account
* const exampleLayerVersionPermission = new aws.lambda.LayerVersionPermission("example", {
* layerName: example.layerName,
* versionNumber: example.version,
* principal: "123456789012",
* action: "lambda:GetLayerVersion",
* statementId: "dev-account-access",
* });
* ```
*
* ### Share Layer with Organization
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as aws from "@pulumi/aws";
*
* const example = new aws.lambda.LayerVersionPermission("example", {
* layerName: exampleAwsLambdaLayerVersion.layerName,
* versionNumber: exampleAwsLambdaLayerVersion.version,
* principal: "*",
* organizationId: "o-1234567890",
* action: "lambda:GetLayerVersion",
* statementId: "org-wide-access",
* });
* ```
*
* ### Share Layer Publicly
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as aws from "@pulumi/aws";
*
* const example = new aws.lambda.LayerVersionPermission("example", {
* layerName: exampleAwsLambdaLayerVersion.layerName,
* versionNumber: exampleAwsLambdaLayerVersion.version,
* principal: "*",
* action: "lambda:GetLayerVersion",
* statementId: "public-access",
* });
* ```
*
* ### Multiple Account Access
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as aws from "@pulumi/aws";
*
* // Share with multiple specific accounts
* const devAccount = new aws.lambda.LayerVersionPermission("dev_account", {
* layerName: example.layerName,
* versionNumber: example.version,
* principal: "111111111111",
* action: "lambda:GetLayerVersion",
* statementId: "dev-account",
* });
* const stagingAccount = new aws.lambda.LayerVersionPermission("staging_account", {
* layerName: example.layerName,
* versionNumber: example.version,
* principal: "222222222222",
* action: "lambda:GetLayerVersion",
* statementId: "staging-account",
* });
* const prodAccount = new aws.lambda.LayerVersionPermission("prod_account", {
* layerName: example.layerName,
* versionNumber: example.version,
* principal: "333333333333",
* action: "lambda:GetLayerVersion",
* statementId: "prod-account",
* });
* ```
*
* ## Import
*
* For backwards compatibility, the following legacy `pulumi import` command is also supported:
*
* ```sh
* $ pulumi import aws:lambda/layerVersionPermission:LayerVersionPermission example arn:aws:lambda:us-west-2:123456789012:layer:shared_utilities,1
* ```
*/
class LayerVersionPermission extends pulumi.CustomResource {
/**
* Get an existing LayerVersionPermission 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 LayerVersionPermission(name, state, { ...opts, id: id });
}
/**
* Returns true if the given object is an instance of LayerVersionPermission. 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'] === LayerVersionPermission.__pulumiType;
}
constructor(name, argsOrState, opts) {
let resourceInputs = {};
opts = opts || {};
if (opts.id) {
const state = argsOrState;
resourceInputs["action"] = state?.action;
resourceInputs["layerName"] = state?.layerName;
resourceInputs["organizationId"] = state?.organizationId;
resourceInputs["policy"] = state?.policy;
resourceInputs["principal"] = state?.principal;
resourceInputs["region"] = state?.region;
resourceInputs["revisionId"] = state?.revisionId;
resourceInputs["skipDestroy"] = state?.skipDestroy;
resourceInputs["statementId"] = state?.statementId;
resourceInputs["versionNumber"] = state?.versionNumber;
}
else {
const args = argsOrState;
if (args?.action === undefined && !opts.urn) {
throw new Error("Missing required property 'action'");
}
if (args?.layerName === undefined && !opts.urn) {
throw new Error("Missing required property 'layerName'");
}
if (args?.principal === undefined && !opts.urn) {
throw new Error("Missing required property 'principal'");
}
if (args?.statementId === undefined && !opts.urn) {
throw new Error("Missing required property 'statementId'");
}
if (args?.versionNumber === undefined && !opts.urn) {
throw new Error("Missing required property 'versionNumber'");
}
resourceInputs["action"] = args?.action;
resourceInputs["layerName"] = args?.layerName;
resourceInputs["organizationId"] = args?.organizationId;
resourceInputs["principal"] = args?.principal;
resourceInputs["region"] = args?.region;
resourceInputs["skipDestroy"] = args?.skipDestroy;
resourceInputs["statementId"] = args?.statementId;
resourceInputs["versionNumber"] = args?.versionNumber;
resourceInputs["policy"] = undefined /*out*/;
resourceInputs["revisionId"] = undefined /*out*/;
}
opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts);
super(LayerVersionPermission.__pulumiType, name, resourceInputs, opts);
}
}
exports.LayerVersionPermission = LayerVersionPermission;
/** @internal */
LayerVersionPermission.__pulumiType = 'aws:lambda/layerVersionPermission:LayerVersionPermission';
//# sourceMappingURL=layerVersionPermission.js.map
;