@pulumi/aws-native
Version:
The Pulumi AWS Cloud Control Provider enables you to build, deploy, and manage [any AWS resource that's supported by the AWS Cloud Control API](https://github.com/pulumi/pulumi-aws-native/blob/master/provider/cmd/pulumi-gen-aws-native/supported-types.txt)
142 lines • 7.15 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.CustomResourceEmulator = void 0;
const pulumi = require("@pulumi/pulumi");
const utilities = require("../utilities");
/**
* The Custom Resource Emulator allows you to use AWS CloudFormation Custom Resources directly in your Pulumi programs. It provides a way to invoke AWS Lambda functions that implement custom provisioning logic following the CloudFormation Custom Resource protocol.
*
* > **Note**: Currently, only Lambda-backed Custom Resources are supported. SNS-backed Custom Resources are not supported at this time.
*
* ## Example Usage
*
* ```typescript
* import * as aws from "@pulumi/aws-native";
*
* const bucket = new aws.s3.Bucket('custom-resource-emulator');
*
* // Create a Custom Resource that invokes a Lambda function
* const cr = new aws.cloudformation.CustomResourceEmulator('cr', {
* bucketName: bucket.id,
* bucketKeyPrefix: 'custom-resource-emulator',
* customResourceProperties: {
* hello: "world"
* },
* serviceToken: "arn:aws:lambda:us-west-2:123456789012:function:my-custom-resource",
* resourceType: 'Custom::MyResource',
* }, { customTimeouts: { create: '5m', update: '5m', delete: '5m' } });
*
* // Access the response data
* export const customResourceData = customResource.data;
* ```
*
* A full example of creating a CloudFormation Custom Resource Lambda function and using it in Pulumi can be found [here](https://github.com/pulumi/pulumi-aws-native/tree/master/examples/cfn-custom-resource).
*
* ## About CloudFormation Custom Resources
*
* CloudFormation Custom Resources allow you to write custom provisioning logic for resources that aren't directly available as AWS CloudFormation resource types. Common use cases include:
*
* - Implementing complex provisioning logic
* - Performing custom validations or transformations
* - Integrating with third-party services
* - Implementing organization-specific infrastructure patterns
*
* For more information about CloudFormation Custom Resources, see [Custom Resources](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/template-custom-resources.html) in the AWS CloudFormation User Guide.
*
* ## Permissions
*
* The IAM principal used by your Pulumi program must have the following permissions:
*
* 1. `lambda:InvokeFunction` on the Lambda function specified in `serviceToken`
* 2. S3 permissions on the bucket specified in `bucketName`:
* - `s3:PutObject`
* - `s3:GetObject`
* - `s3:HeadObject`
*
* ## Lambda Function Requirements
*
* The Lambda function specified in `serviceToken` must implement the CloudFormation Custom Resource lifecycle.
* For detailed information about implementing Lambda-backed Custom Resources, see [AWS Lambda-backed Custom Resources](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/template-custom-resources-lambda.html) in the AWS CloudFormation User Guide.
*
* ## Timeouts
*
* Custom Resources have a default timeout of 60 minutes, matching the CloudFormation timeout for custom resource operations. You can customize it using the [`customTimeouts`](https://www.pulumi.com/docs/iac/concepts/options/customtimeouts/) resource option.
*/
class CustomResourceEmulator extends pulumi.CustomResource {
/**
* Get an existing CustomResourceEmulator 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 opts Optional settings to control the behavior of the CustomResource.
*/
static get(name, id, opts) {
return new CustomResourceEmulator(name, undefined, { ...opts, id: id });
}
/**
* Returns true if the given object is an instance of CustomResourceEmulator. 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'] === CustomResourceEmulator.__pulumiType;
}
/**
* Create a CustomResourceEmulator resource with the given unique name, arguments, and options.
*
* @param name The _unique_ name of the resource.
* @param args The arguments to use to populate this resource's properties.
* @param opts A bag of options that control this resource's behavior.
*/
constructor(name, args, opts) {
let resourceInputs = {};
opts = opts || {};
if (!opts.id) {
if (args?.bucketKeyPrefix === undefined && !opts.urn) {
throw new Error("Missing required property 'bucketKeyPrefix'");
}
if (args?.bucketName === undefined && !opts.urn) {
throw new Error("Missing required property 'bucketName'");
}
if (args?.customResourceProperties === undefined && !opts.urn) {
throw new Error("Missing required property 'customResourceProperties'");
}
if (args?.resourceType === undefined && !opts.urn) {
throw new Error("Missing required property 'resourceType'");
}
if (args?.serviceToken === undefined && !opts.urn) {
throw new Error("Missing required property 'serviceToken'");
}
resourceInputs["bucketKeyPrefix"] = args?.bucketKeyPrefix;
resourceInputs["bucketName"] = args?.bucketName;
resourceInputs["customResourceProperties"] = args?.customResourceProperties;
resourceInputs["resourceType"] = args?.resourceType;
resourceInputs["serviceToken"] = args?.serviceToken;
resourceInputs["stackId"] = args?.stackId;
resourceInputs["bucket"] = undefined /*out*/;
resourceInputs["data"] = undefined /*out*/;
resourceInputs["noEcho"] = undefined /*out*/;
resourceInputs["physicalResourceId"] = undefined /*out*/;
}
else {
resourceInputs["bucket"] = undefined /*out*/;
resourceInputs["data"] = undefined /*out*/;
resourceInputs["noEcho"] = undefined /*out*/;
resourceInputs["physicalResourceId"] = undefined /*out*/;
resourceInputs["resourceType"] = undefined /*out*/;
resourceInputs["serviceToken"] = undefined /*out*/;
resourceInputs["stackId"] = undefined /*out*/;
}
opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts);
super(CustomResourceEmulator.__pulumiType, name, resourceInputs, opts);
}
}
exports.CustomResourceEmulator = CustomResourceEmulator;
/** @internal */
CustomResourceEmulator.__pulumiType = 'aws-native:cloudformation:CustomResourceEmulator';
//# sourceMappingURL=customResourceEmulator.js.map