@pulumi/aws
Version:
A Pulumi package for creating and managing Amazon Web Services (AWS) cloud resources.
120 lines • 4.8 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.FunctionRecursionConfig = void 0;
const pulumi = require("@pulumi/pulumi");
const utilities = require("../utilities");
/**
* Manages an AWS Lambda Function Recursion Config. Use this resource to control how Lambda handles recursive function invocations to prevent infinite loops.
*
* > **Note:** Destruction of this resource will return the `recursiveLoop` configuration back to the default value of `Terminate`.
*
* ## Example Usage
*
* ### Allow Recursive Invocations
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as aws from "@pulumi/aws";
*
* // Lambda function that may need to call itself
* const example = new aws.lambda.Function("example", {
* code: new pulumi.asset.FileArchive("function.zip"),
* name: "recursive_processor",
* role: lambdaRole.arn,
* handler: "index.handler",
* runtime: aws.lambda.Runtime.Python3d12,
* });
* // Allow the function to invoke itself recursively
* const exampleFunctionRecursionConfig = new aws.lambda.FunctionRecursionConfig("example", {
* functionName: example.name,
* recursiveLoop: "Allow",
* });
* ```
*
* ### Production Safety Configuration
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as aws from "@pulumi/aws";
*
* // Production function with recursion protection
* const productionProcessor = new aws.lambda.Function("production_processor", {
* code: new pulumi.asset.FileArchive("processor.zip"),
* name: "production-data-processor",
* role: lambdaRole.arn,
* handler: "app.handler",
* runtime: aws.lambda.Runtime.NodeJS20dX,
* tags: {
* Environment: "production",
* Purpose: "data-processing",
* },
* });
* // Prevent infinite loops in production
* const example = new aws.lambda.FunctionRecursionConfig("example", {
* functionName: productionProcessor.name,
* recursiveLoop: "Terminate",
* });
* ```
*
* ## Import
*
* For backwards compatibility, the following legacy `pulumi import` command is also supported:
*
* ```sh
* $ pulumi import aws:lambda/functionRecursionConfig:FunctionRecursionConfig example recursive_processor
* ```
*/
class FunctionRecursionConfig extends pulumi.CustomResource {
/**
* Get an existing FunctionRecursionConfig 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 FunctionRecursionConfig(name, state, { ...opts, id: id });
}
/**
* Returns true if the given object is an instance of FunctionRecursionConfig. 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'] === FunctionRecursionConfig.__pulumiType;
}
constructor(name, argsOrState, opts) {
let resourceInputs = {};
opts = opts || {};
if (opts.id) {
const state = argsOrState;
resourceInputs["functionName"] = state?.functionName;
resourceInputs["recursiveLoop"] = state?.recursiveLoop;
resourceInputs["region"] = state?.region;
}
else {
const args = argsOrState;
if (args?.functionName === undefined && !opts.urn) {
throw new Error("Missing required property 'functionName'");
}
if (args?.recursiveLoop === undefined && !opts.urn) {
throw new Error("Missing required property 'recursiveLoop'");
}
resourceInputs["functionName"] = args?.functionName;
resourceInputs["recursiveLoop"] = args?.recursiveLoop;
resourceInputs["region"] = args?.region;
}
opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts);
super(FunctionRecursionConfig.__pulumiType, name, resourceInputs, opts);
}
}
exports.FunctionRecursionConfig = FunctionRecursionConfig;
/** @internal */
FunctionRecursionConfig.__pulumiType = 'aws:lambda/functionRecursionConfig:FunctionRecursionConfig';
//# sourceMappingURL=functionRecursionConfig.js.map