UNPKG

@pulumi/aws

Version:

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

242 lines • 8.95 kB
"use strict"; // *** 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.FunctionEventInvokeConfig = void 0; const pulumi = require("@pulumi/pulumi"); const utilities = require("../utilities"); /** * Manages an AWS Lambda Function Event Invoke Config. Use this resource to configure error handling and destinations for asynchronous Lambda function invocations. * * More information about asynchronous invocations and the configurable values can be found in the [Lambda Developer Guide](https://docs.aws.amazon.com/lambda/latest/dg/invocation-async.html). * * ## Example Usage * * ### Complete Error Handling and Destinations * * > **Note:** Ensure the Lambda Function IAM Role has necessary permissions for the destination, such as `sqs:SendMessage` or `sns:Publish`, otherwise the API will return a generic `InvalidParameterValueException: The destination ARN arn:PARTITION:SERVICE:REGION:ACCOUNT:RESOURCE is invalid.` error. * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as aws from "@pulumi/aws"; * * // SQS queue for failed invocations * const dlq = new aws.sqs.Queue("dlq", { * name: "lambda-dlq", * tags: { * Environment: "production", * Purpose: "lambda-error-handling", * }, * }); * // SNS topic for successful invocations * const success = new aws.sns.Topic("success", { * name: "lambda-success-notifications", * tags: { * Environment: "production", * Purpose: "lambda-success-notifications", * }, * }); * // Complete event invoke configuration * const example = new aws.lambda.FunctionEventInvokeConfig("example", { * functionName: exampleAwsLambdaFunction.functionName, * maximumEventAgeInSeconds: 300, * maximumRetryAttempts: 1, * destinationConfig: { * onFailure: { * destination: dlq.arn, * }, * onSuccess: { * destination: success.arn, * }, * }, * }); * ``` * * ### Error Handling Only * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as aws from "@pulumi/aws"; * * const example = new aws.lambda.FunctionEventInvokeConfig("example", { * functionName: exampleAwsLambdaFunction.functionName, * maximumEventAgeInSeconds: 60, * maximumRetryAttempts: 0, * }); * ``` * * ### Configuration for Lambda Alias * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as aws from "@pulumi/aws"; * * const example = new aws.lambda.Alias("example", { * name: "production", * description: "Production alias", * functionName: exampleAwsLambdaFunction.functionName, * functionVersion: exampleAwsLambdaFunction.version, * }); * const exampleFunctionEventInvokeConfig = new aws.lambda.FunctionEventInvokeConfig("example", { * functionName: exampleAwsLambdaFunction.functionName, * qualifier: example.name, * maximumEventAgeInSeconds: 1800, * maximumRetryAttempts: 2, * destinationConfig: { * onFailure: { * destination: productionDlq.arn, * }, * }, * }); * ``` * * ### Configuration for Published Version * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as aws from "@pulumi/aws"; * * const example = new aws.lambda.FunctionEventInvokeConfig("example", { * functionName: exampleAwsLambdaFunction.functionName, * qualifier: exampleAwsLambdaFunction.version, * maximumEventAgeInSeconds: 21600, * maximumRetryAttempts: 2, * destinationConfig: { * onFailure: { * destination: versionDlq.arn, * }, * onSuccess: { * destination: versionSuccess.arn, * }, * }, * }); * ``` * * ### Configuration for Latest Version * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as aws from "@pulumi/aws"; * * const example = new aws.lambda.FunctionEventInvokeConfig("example", { * functionName: exampleAwsLambdaFunction.functionName, * qualifier: "$LATEST", * maximumEventAgeInSeconds: 120, * maximumRetryAttempts: 0, * destinationConfig: { * onFailure: { * destination: devDlq.arn, * }, * }, * }); * ``` * * ### Multiple Destination Types * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as aws from "@pulumi/aws"; * * // S3 bucket for archiving successful events * const lambdaSuccessArchive = new aws.s3.Bucket("lambda_success_archive", {bucket: `lambda-success-archive-${bucketSuffix.hex}`}); * // EventBridge custom bus for failed events * const lambdaFailures = new aws.cloudwatch.EventBus("lambda_failures", {name: "lambda-failure-events"}); * const example = new aws.lambda.FunctionEventInvokeConfig("example", { * functionName: exampleAwsLambdaFunction.functionName, * destinationConfig: { * onFailure: { * destination: lambdaFailures.arn, * }, * onSuccess: { * destination: lambdaSuccessArchive.arn, * }, * }, * }); * ``` * * ## Import * * ARN with qualifier: * * Name without qualifier (all versions and aliases): * * Name with qualifier: * * For backwards compatibility, the following legacy `pulumi import` commands are also supported: * * Using ARN without qualifier: * * ```sh * $ pulumi import aws:lambda/functionEventInvokeConfig:FunctionEventInvokeConfig example arn:aws:lambda:us-east-1:123456789012:function:example * ``` * Using ARN with qualifier: * * ```sh * $ pulumi import aws:lambda/functionEventInvokeConfig:FunctionEventInvokeConfig example arn:aws:lambda:us-east-1:123456789012:function:example:production * ``` * Name without qualifier (all versions and aliases): * * ```sh * $ pulumi import aws:lambda/functionEventInvokeConfig:FunctionEventInvokeConfig example example * ``` * Name with qualifier: * * ```sh * $ pulumi import aws:lambda/functionEventInvokeConfig:FunctionEventInvokeConfig example example:production * ``` */ class FunctionEventInvokeConfig extends pulumi.CustomResource { /** * Get an existing FunctionEventInvokeConfig 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 FunctionEventInvokeConfig(name, state, { ...opts, id: id }); } /** * Returns true if the given object is an instance of FunctionEventInvokeConfig. 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'] === FunctionEventInvokeConfig.__pulumiType; } constructor(name, argsOrState, opts) { let resourceInputs = {}; opts = opts || {}; if (opts.id) { const state = argsOrState; resourceInputs["destinationConfig"] = state?.destinationConfig; resourceInputs["functionName"] = state?.functionName; resourceInputs["maximumEventAgeInSeconds"] = state?.maximumEventAgeInSeconds; resourceInputs["maximumRetryAttempts"] = state?.maximumRetryAttempts; resourceInputs["qualifier"] = state?.qualifier; resourceInputs["region"] = state?.region; } else { const args = argsOrState; if (args?.functionName === undefined && !opts.urn) { throw new Error("Missing required property 'functionName'"); } resourceInputs["destinationConfig"] = args?.destinationConfig; resourceInputs["functionName"] = args?.functionName; resourceInputs["maximumEventAgeInSeconds"] = args?.maximumEventAgeInSeconds; resourceInputs["maximumRetryAttempts"] = args?.maximumRetryAttempts; resourceInputs["qualifier"] = args?.qualifier; resourceInputs["region"] = args?.region; } opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts); super(FunctionEventInvokeConfig.__pulumiType, name, resourceInputs, opts); } } exports.FunctionEventInvokeConfig = FunctionEventInvokeConfig; /** @internal */ FunctionEventInvokeConfig.__pulumiType = 'aws:lambda/functionEventInvokeConfig:FunctionEventInvokeConfig'; //# sourceMappingURL=functionEventInvokeConfig.js.map