UNPKG

@pulumi/aws

Version:

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

343 lines • 14 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.EventSourceMapping = void 0; const pulumi = require("@pulumi/pulumi"); const utilities = require("../utilities"); /** * Manages an AWS Lambda Event Source Mapping. Use this resource to connect Lambda functions to event sources like Kinesis, DynamoDB, SQS, Amazon MQ, and Managed Streaming for Apache Kafka (MSK). * * For information about Lambda and how to use it, see [What is AWS Lambda?](http://docs.aws.amazon.com/lambda/latest/dg/welcome.html). For information about event source mappings, see [CreateEventSourceMapping](http://docs.aws.amazon.com/lambda/latest/dg/API_CreateEventSourceMapping.html) in the API docs. * * ## Example Usage * * ### DynamoDB Stream * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as aws from "@pulumi/aws"; * * const example = new aws.lambda.EventSourceMapping("example", { * eventSourceArn: exampleAwsDynamodbTable.streamArn, * functionName: exampleAwsLambdaFunction.arn, * startingPosition: "LATEST", * tags: { * Name: "dynamodb-stream-mapping", * }, * }); * ``` * * ### Kinesis Stream * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as aws from "@pulumi/aws"; * * const example = new aws.lambda.EventSourceMapping("example", { * eventSourceArn: exampleAwsKinesisStream.arn, * functionName: exampleAwsLambdaFunction.arn, * startingPosition: "LATEST", * batchSize: 100, * maximumBatchingWindowInSeconds: 5, * parallelizationFactor: 2, * destinationConfig: { * onFailure: { * destinationArn: dlq.arn, * }, * }, * }); * ``` * * ### SQS Queue * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as aws from "@pulumi/aws"; * * const example = new aws.lambda.EventSourceMapping("example", { * eventSourceArn: exampleAwsSqsQueue.arn, * functionName: exampleAwsLambdaFunction.arn, * batchSize: 10, * scalingConfig: { * maximumConcurrency: 100, * }, * }); * ``` * * ### SQS with Event Filtering * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as aws from "@pulumi/aws"; * * const example = new aws.lambda.EventSourceMapping("example", { * eventSourceArn: exampleAwsSqsQueue.arn, * functionName: exampleAwsLambdaFunction.arn, * filterCriteria: { * filters: [{ * pattern: JSON.stringify({ * body: { * Temperature: [{ * numeric: [ * ">", * 0, * "<=", * 100, * ], * }], * Location: ["New York"], * }, * }), * }], * }, * }); * ``` * * ### Amazon MSK * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as aws from "@pulumi/aws"; * * const example = new aws.lambda.EventSourceMapping("example", { * eventSourceArn: exampleAwsMskCluster.arn, * functionName: exampleAwsLambdaFunction.arn, * topics: [ * "orders", * "inventory", * ], * startingPosition: "TRIM_HORIZON", * batchSize: 100, * amazonManagedKafkaEventSourceConfig: { * consumerGroupId: "lambda-consumer-group", * }, * }); * ``` * * ### Self-Managed Apache Kafka * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as aws from "@pulumi/aws"; * * const example = new aws.lambda.EventSourceMapping("example", { * functionName: exampleAwsLambdaFunction.arn, * topics: ["orders"], * startingPosition: "TRIM_HORIZON", * selfManagedEventSource: { * endpoints: { * KAFKA_BOOTSTRAP_SERVERS: "kafka1.example.com:9092,kafka2.example.com:9092", * }, * }, * selfManagedKafkaEventSourceConfig: { * consumerGroupId: "lambda-consumer-group", * }, * sourceAccessConfigurations: [ * { * type: "VPC_SUBNET", * uri: `subnet:${example1.id}`, * }, * { * type: "VPC_SUBNET", * uri: `subnet:${example2.id}`, * }, * { * type: "VPC_SECURITY_GROUP", * uri: `security_group:${exampleAwsSecurityGroup.id}`, * }, * ], * provisionedPollerConfig: { * maximumPollers: 100, * minimumPollers: 10, * }, * }); * ``` * * ### Amazon MQ (ActiveMQ) * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as aws from "@pulumi/aws"; * * const example = new aws.lambda.EventSourceMapping("example", { * eventSourceArn: exampleAwsMqBroker.arn, * functionName: exampleAwsLambdaFunction.arn, * queues: "orders", * batchSize: 10, * sourceAccessConfigurations: [{ * type: "BASIC_AUTH", * uri: exampleAwsSecretsmanagerSecretVersion.arn, * }], * }); * ``` * * ### Amazon MQ (RabbitMQ) * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as aws from "@pulumi/aws"; * * const example = new aws.lambda.EventSourceMapping("example", { * eventSourceArn: exampleAwsMqBroker.arn, * functionName: exampleAwsLambdaFunction.arn, * queues: "orders", * batchSize: 1, * sourceAccessConfigurations: [ * { * type: "VIRTUAL_HOST", * uri: "/production", * }, * { * type: "BASIC_AUTH", * uri: exampleAwsSecretsmanagerSecretVersion.arn, * }, * ], * }); * ``` * * ### DocumentDB Change Stream * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as aws from "@pulumi/aws"; * * const example = new aws.lambda.EventSourceMapping("example", { * eventSourceArn: exampleAwsDocdbCluster.arn, * functionName: exampleAwsLambdaFunction.arn, * startingPosition: "LATEST", * documentDbEventSourceConfig: { * databaseName: "orders", * collectionName: "transactions", * fullDocument: "UpdateLookup", * }, * sourceAccessConfigurations: [{ * type: "BASIC_AUTH", * uri: exampleAwsSecretsmanagerSecretVersion.arn, * }], * }); * ``` * * ## Import * * Using `pulumi import`, import Lambda event source mappings using the `UUID` (event source mapping identifier). For example: * * ```sh * $ pulumi import aws:lambda/eventSourceMapping:EventSourceMapping example 12345kxodurf3443 * ``` */ class EventSourceMapping extends pulumi.CustomResource { /** * Get an existing EventSourceMapping 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 EventSourceMapping(name, state, { ...opts, id: id }); } /** * Returns true if the given object is an instance of EventSourceMapping. 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'] === EventSourceMapping.__pulumiType; } constructor(name, argsOrState, opts) { let resourceInputs = {}; opts = opts || {}; if (opts.id) { const state = argsOrState; resourceInputs["amazonManagedKafkaEventSourceConfig"] = state?.amazonManagedKafkaEventSourceConfig; resourceInputs["arn"] = state?.arn; resourceInputs["batchSize"] = state?.batchSize; resourceInputs["bisectBatchOnFunctionError"] = state?.bisectBatchOnFunctionError; resourceInputs["destinationConfig"] = state?.destinationConfig; resourceInputs["documentDbEventSourceConfig"] = state?.documentDbEventSourceConfig; resourceInputs["enabled"] = state?.enabled; resourceInputs["eventSourceArn"] = state?.eventSourceArn; resourceInputs["filterCriteria"] = state?.filterCriteria; resourceInputs["functionArn"] = state?.functionArn; resourceInputs["functionName"] = state?.functionName; resourceInputs["functionResponseTypes"] = state?.functionResponseTypes; resourceInputs["kmsKeyArn"] = state?.kmsKeyArn; resourceInputs["lastModified"] = state?.lastModified; resourceInputs["lastProcessingResult"] = state?.lastProcessingResult; resourceInputs["maximumBatchingWindowInSeconds"] = state?.maximumBatchingWindowInSeconds; resourceInputs["maximumRecordAgeInSeconds"] = state?.maximumRecordAgeInSeconds; resourceInputs["maximumRetryAttempts"] = state?.maximumRetryAttempts; resourceInputs["metricsConfig"] = state?.metricsConfig; resourceInputs["parallelizationFactor"] = state?.parallelizationFactor; resourceInputs["provisionedPollerConfig"] = state?.provisionedPollerConfig; resourceInputs["queues"] = state?.queues; resourceInputs["region"] = state?.region; resourceInputs["scalingConfig"] = state?.scalingConfig; resourceInputs["selfManagedEventSource"] = state?.selfManagedEventSource; resourceInputs["selfManagedKafkaEventSourceConfig"] = state?.selfManagedKafkaEventSourceConfig; resourceInputs["sourceAccessConfigurations"] = state?.sourceAccessConfigurations; resourceInputs["startingPosition"] = state?.startingPosition; resourceInputs["startingPositionTimestamp"] = state?.startingPositionTimestamp; resourceInputs["state"] = state?.state; resourceInputs["stateTransitionReason"] = state?.stateTransitionReason; resourceInputs["tags"] = state?.tags; resourceInputs["tagsAll"] = state?.tagsAll; resourceInputs["topics"] = state?.topics; resourceInputs["tumblingWindowInSeconds"] = state?.tumblingWindowInSeconds; resourceInputs["uuid"] = state?.uuid; } else { const args = argsOrState; if (args?.functionName === undefined && !opts.urn) { throw new Error("Missing required property 'functionName'"); } resourceInputs["amazonManagedKafkaEventSourceConfig"] = args?.amazonManagedKafkaEventSourceConfig; resourceInputs["batchSize"] = args?.batchSize; resourceInputs["bisectBatchOnFunctionError"] = args?.bisectBatchOnFunctionError; resourceInputs["destinationConfig"] = args?.destinationConfig; resourceInputs["documentDbEventSourceConfig"] = args?.documentDbEventSourceConfig; resourceInputs["enabled"] = args?.enabled; resourceInputs["eventSourceArn"] = args?.eventSourceArn; resourceInputs["filterCriteria"] = args?.filterCriteria; resourceInputs["functionName"] = args?.functionName; resourceInputs["functionResponseTypes"] = args?.functionResponseTypes; resourceInputs["kmsKeyArn"] = args?.kmsKeyArn; resourceInputs["maximumBatchingWindowInSeconds"] = args?.maximumBatchingWindowInSeconds; resourceInputs["maximumRecordAgeInSeconds"] = args?.maximumRecordAgeInSeconds; resourceInputs["maximumRetryAttempts"] = args?.maximumRetryAttempts; resourceInputs["metricsConfig"] = args?.metricsConfig; resourceInputs["parallelizationFactor"] = args?.parallelizationFactor; resourceInputs["provisionedPollerConfig"] = args?.provisionedPollerConfig; resourceInputs["queues"] = args?.queues; resourceInputs["region"] = args?.region; resourceInputs["scalingConfig"] = args?.scalingConfig; resourceInputs["selfManagedEventSource"] = args?.selfManagedEventSource; resourceInputs["selfManagedKafkaEventSourceConfig"] = args?.selfManagedKafkaEventSourceConfig; resourceInputs["sourceAccessConfigurations"] = args?.sourceAccessConfigurations; resourceInputs["startingPosition"] = args?.startingPosition; resourceInputs["startingPositionTimestamp"] = args?.startingPositionTimestamp; resourceInputs["tags"] = args?.tags; resourceInputs["topics"] = args?.topics; resourceInputs["tumblingWindowInSeconds"] = args?.tumblingWindowInSeconds; resourceInputs["arn"] = undefined /*out*/; resourceInputs["functionArn"] = undefined /*out*/; resourceInputs["lastModified"] = undefined /*out*/; resourceInputs["lastProcessingResult"] = undefined /*out*/; resourceInputs["state"] = undefined /*out*/; resourceInputs["stateTransitionReason"] = undefined /*out*/; resourceInputs["tagsAll"] = undefined /*out*/; resourceInputs["uuid"] = undefined /*out*/; } opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts); super(EventSourceMapping.__pulumiType, name, resourceInputs, opts); } } exports.EventSourceMapping = EventSourceMapping; /** @internal */ EventSourceMapping.__pulumiType = 'aws:lambda/eventSourceMapping:EventSourceMapping'; //# sourceMappingURL=eventSourceMapping.js.map