@aws-sdk/client-lambda
Version:
AWS SDK for JavaScript Lambda Client for Node.js, Browser and React Native
327 lines (326 loc) • 16.1 kB
TypeScript
import { Command as $Command } from "@smithy/smithy-client";
import { MetadataBearer as __MetadataBearer } from "@smithy/types";
import { LambdaClientResolvedConfig, ServiceInputTypes, ServiceOutputTypes } from "../LambdaClient";
import { CreateEventSourceMappingRequest, EventSourceMappingConfiguration } from "../models/models_0";
/**
* @public
*/
export type { __MetadataBearer };
export { $Command };
/**
* @public
*
* The input for {@link CreateEventSourceMappingCommand}.
*/
export interface CreateEventSourceMappingCommandInput extends CreateEventSourceMappingRequest {
}
/**
* @public
*
* The output of {@link CreateEventSourceMappingCommand}.
*/
export interface CreateEventSourceMappingCommandOutput extends EventSourceMappingConfiguration, __MetadataBearer {
}
declare const CreateEventSourceMappingCommand_base: {
new (input: CreateEventSourceMappingCommandInput): import("@smithy/smithy-client").CommandImpl<CreateEventSourceMappingCommandInput, CreateEventSourceMappingCommandOutput, LambdaClientResolvedConfig, ServiceInputTypes, ServiceOutputTypes>;
new (input: CreateEventSourceMappingCommandInput): import("@smithy/smithy-client").CommandImpl<CreateEventSourceMappingCommandInput, CreateEventSourceMappingCommandOutput, LambdaClientResolvedConfig, ServiceInputTypes, ServiceOutputTypes>;
getEndpointParameterInstructions(): import("@smithy/middleware-endpoint").EndpointParameterInstructions;
};
/**
* <p>Creates a mapping between an event source and an Lambda function. Lambda reads items from the event source and invokes the function.</p> <p>For details about how to configure different event sources, see the following topics. </p> <ul> <li> <p> <a href="https://docs.aws.amazon.com/lambda/latest/dg/with-ddb.html#services-dynamodb-eventsourcemapping"> Amazon DynamoDB Streams</a> </p> </li> <li> <p> <a href="https://docs.aws.amazon.com/lambda/latest/dg/with-kinesis.html#services-kinesis-eventsourcemapping"> Amazon Kinesis</a> </p> </li> <li> <p> <a href="https://docs.aws.amazon.com/lambda/latest/dg/with-sqs.html#events-sqs-eventsource"> Amazon SQS</a> </p> </li> <li> <p> <a href="https://docs.aws.amazon.com/lambda/latest/dg/with-mq.html#services-mq-eventsourcemapping"> Amazon MQ and RabbitMQ</a> </p> </li> <li> <p> <a href="https://docs.aws.amazon.com/lambda/latest/dg/with-msk.html"> Amazon MSK</a> </p> </li> <li> <p> <a href="https://docs.aws.amazon.com/lambda/latest/dg/kafka-smaa.html"> Apache Kafka</a> </p> </li> <li> <p> <a href="https://docs.aws.amazon.com/lambda/latest/dg/with-documentdb.html"> Amazon DocumentDB</a> </p> </li> </ul> <p>The following error handling options are available only for DynamoDB and Kinesis event sources:</p> <ul> <li> <p> <code>BisectBatchOnFunctionError</code> – If the function returns an error, split the batch in two and retry.</p> </li> <li> <p> <code>MaximumRecordAgeInSeconds</code> – Discard records older than the specified age. The default value is infinite (-1). When set to infinite (-1), failed records are retried until the record expires</p> </li> <li> <p> <code>MaximumRetryAttempts</code> – Discard records after the specified number of retries. The default value is infinite (-1). When set to infinite (-1), failed records are retried until the record expires.</p> </li> <li> <p> <code>ParallelizationFactor</code> – Process multiple batches from each shard concurrently.</p> </li> </ul> <p>For stream sources (DynamoDB, Kinesis, Amazon MSK, and self-managed Apache Kafka), the following option is also available:</p> <ul> <li> <p> <code>OnFailure</code> – Send discarded records to an Amazon SQS queue, Amazon SNS topic, or Amazon S3 bucket. For more information, see <a href="https://docs.aws.amazon.com/lambda/latest/dg/invocation-async-retain-records.html#invocation-async-destinations">Adding a destination</a>.</p> </li> </ul> <p>For information about which configuration parameters apply to each event source, see the following topics.</p> <ul> <li> <p> <a href="https://docs.aws.amazon.com/lambda/latest/dg/with-ddb.html#services-ddb-params"> Amazon DynamoDB Streams</a> </p> </li> <li> <p> <a href="https://docs.aws.amazon.com/lambda/latest/dg/with-kinesis.html#services-kinesis-params"> Amazon Kinesis</a> </p> </li> <li> <p> <a href="https://docs.aws.amazon.com/lambda/latest/dg/with-sqs.html#services-sqs-params"> Amazon SQS</a> </p> </li> <li> <p> <a href="https://docs.aws.amazon.com/lambda/latest/dg/with-mq.html#services-mq-params"> Amazon MQ and RabbitMQ</a> </p> </li> <li> <p> <a href="https://docs.aws.amazon.com/lambda/latest/dg/with-msk.html#services-msk-parms"> Amazon MSK</a> </p> </li> <li> <p> <a href="https://docs.aws.amazon.com/lambda/latest/dg/with-kafka.html#services-kafka-parms"> Apache Kafka</a> </p> </li> <li> <p> <a href="https://docs.aws.amazon.com/lambda/latest/dg/with-documentdb.html#docdb-configuration"> Amazon DocumentDB</a> </p> </li> </ul>
* @example
* Use a bare-bones client and the command you need to make an API call.
* ```javascript
* import { LambdaClient, CreateEventSourceMappingCommand } from "@aws-sdk/client-lambda"; // ES Modules import
* // const { LambdaClient, CreateEventSourceMappingCommand } = require("@aws-sdk/client-lambda"); // CommonJS import
* const client = new LambdaClient(config);
* const input = { // CreateEventSourceMappingRequest
* EventSourceArn: "STRING_VALUE",
* FunctionName: "STRING_VALUE", // required
* Enabled: true || false,
* BatchSize: Number("int"),
* FilterCriteria: { // FilterCriteria
* Filters: [ // FilterList
* { // Filter
* Pattern: "STRING_VALUE",
* },
* ],
* },
* MaximumBatchingWindowInSeconds: Number("int"),
* ParallelizationFactor: Number("int"),
* StartingPosition: "TRIM_HORIZON" || "LATEST" || "AT_TIMESTAMP",
* StartingPositionTimestamp: new Date("TIMESTAMP"),
* DestinationConfig: { // DestinationConfig
* OnSuccess: { // OnSuccess
* Destination: "STRING_VALUE",
* },
* OnFailure: { // OnFailure
* Destination: "STRING_VALUE",
* },
* },
* MaximumRecordAgeInSeconds: Number("int"),
* BisectBatchOnFunctionError: true || false,
* MaximumRetryAttempts: Number("int"),
* Tags: { // Tags
* "<keys>": "STRING_VALUE",
* },
* TumblingWindowInSeconds: Number("int"),
* Topics: [ // Topics
* "STRING_VALUE",
* ],
* Queues: [ // Queues
* "STRING_VALUE",
* ],
* SourceAccessConfigurations: [ // SourceAccessConfigurations
* { // SourceAccessConfiguration
* Type: "BASIC_AUTH" || "VPC_SUBNET" || "VPC_SECURITY_GROUP" || "SASL_SCRAM_512_AUTH" || "SASL_SCRAM_256_AUTH" || "VIRTUAL_HOST" || "CLIENT_CERTIFICATE_TLS_AUTH" || "SERVER_ROOT_CA_CERTIFICATE",
* URI: "STRING_VALUE",
* },
* ],
* SelfManagedEventSource: { // SelfManagedEventSource
* Endpoints: { // Endpoints
* "<keys>": [ // EndpointLists
* "STRING_VALUE",
* ],
* },
* },
* FunctionResponseTypes: [ // FunctionResponseTypeList
* "ReportBatchItemFailures",
* ],
* AmazonManagedKafkaEventSourceConfig: { // AmazonManagedKafkaEventSourceConfig
* ConsumerGroupId: "STRING_VALUE",
* SchemaRegistryConfig: { // KafkaSchemaRegistryConfig
* SchemaRegistryURI: "STRING_VALUE",
* EventRecordFormat: "JSON" || "SOURCE",
* AccessConfigs: [ // KafkaSchemaRegistryAccessConfigList
* { // KafkaSchemaRegistryAccessConfig
* Type: "BASIC_AUTH" || "CLIENT_CERTIFICATE_TLS_AUTH" || "SERVER_ROOT_CA_CERTIFICATE",
* URI: "STRING_VALUE",
* },
* ],
* SchemaValidationConfigs: [ // KafkaSchemaValidationConfigList
* { // KafkaSchemaValidationConfig
* Attribute: "KEY" || "VALUE",
* },
* ],
* },
* },
* SelfManagedKafkaEventSourceConfig: { // SelfManagedKafkaEventSourceConfig
* ConsumerGroupId: "STRING_VALUE",
* SchemaRegistryConfig: {
* SchemaRegistryURI: "STRING_VALUE",
* EventRecordFormat: "JSON" || "SOURCE",
* AccessConfigs: [
* {
* Type: "BASIC_AUTH" || "CLIENT_CERTIFICATE_TLS_AUTH" || "SERVER_ROOT_CA_CERTIFICATE",
* URI: "STRING_VALUE",
* },
* ],
* SchemaValidationConfigs: [
* {
* Attribute: "KEY" || "VALUE",
* },
* ],
* },
* },
* ScalingConfig: { // ScalingConfig
* MaximumConcurrency: Number("int"),
* },
* DocumentDBEventSourceConfig: { // DocumentDBEventSourceConfig
* DatabaseName: "STRING_VALUE",
* CollectionName: "STRING_VALUE",
* FullDocument: "UpdateLookup" || "Default",
* },
* KMSKeyArn: "STRING_VALUE",
* MetricsConfig: { // EventSourceMappingMetricsConfig
* Metrics: [ // EventSourceMappingMetricList
* "EventCount",
* ],
* },
* ProvisionedPollerConfig: { // ProvisionedPollerConfig
* MinimumPollers: Number("int"),
* MaximumPollers: Number("int"),
* },
* };
* const command = new CreateEventSourceMappingCommand(input);
* const response = await client.send(command);
* // { // EventSourceMappingConfiguration
* // UUID: "STRING_VALUE",
* // StartingPosition: "TRIM_HORIZON" || "LATEST" || "AT_TIMESTAMP",
* // StartingPositionTimestamp: new Date("TIMESTAMP"),
* // BatchSize: Number("int"),
* // MaximumBatchingWindowInSeconds: Number("int"),
* // ParallelizationFactor: Number("int"),
* // EventSourceArn: "STRING_VALUE",
* // FilterCriteria: { // FilterCriteria
* // Filters: [ // FilterList
* // { // Filter
* // Pattern: "STRING_VALUE",
* // },
* // ],
* // },
* // FunctionArn: "STRING_VALUE",
* // LastModified: new Date("TIMESTAMP"),
* // LastProcessingResult: "STRING_VALUE",
* // State: "STRING_VALUE",
* // StateTransitionReason: "STRING_VALUE",
* // DestinationConfig: { // DestinationConfig
* // OnSuccess: { // OnSuccess
* // Destination: "STRING_VALUE",
* // },
* // OnFailure: { // OnFailure
* // Destination: "STRING_VALUE",
* // },
* // },
* // Topics: [ // Topics
* // "STRING_VALUE",
* // ],
* // Queues: [ // Queues
* // "STRING_VALUE",
* // ],
* // SourceAccessConfigurations: [ // SourceAccessConfigurations
* // { // SourceAccessConfiguration
* // Type: "BASIC_AUTH" || "VPC_SUBNET" || "VPC_SECURITY_GROUP" || "SASL_SCRAM_512_AUTH" || "SASL_SCRAM_256_AUTH" || "VIRTUAL_HOST" || "CLIENT_CERTIFICATE_TLS_AUTH" || "SERVER_ROOT_CA_CERTIFICATE",
* // URI: "STRING_VALUE",
* // },
* // ],
* // SelfManagedEventSource: { // SelfManagedEventSource
* // Endpoints: { // Endpoints
* // "<keys>": [ // EndpointLists
* // "STRING_VALUE",
* // ],
* // },
* // },
* // MaximumRecordAgeInSeconds: Number("int"),
* // BisectBatchOnFunctionError: true || false,
* // MaximumRetryAttempts: Number("int"),
* // TumblingWindowInSeconds: Number("int"),
* // FunctionResponseTypes: [ // FunctionResponseTypeList
* // "ReportBatchItemFailures",
* // ],
* // AmazonManagedKafkaEventSourceConfig: { // AmazonManagedKafkaEventSourceConfig
* // ConsumerGroupId: "STRING_VALUE",
* // SchemaRegistryConfig: { // KafkaSchemaRegistryConfig
* // SchemaRegistryURI: "STRING_VALUE",
* // EventRecordFormat: "JSON" || "SOURCE",
* // AccessConfigs: [ // KafkaSchemaRegistryAccessConfigList
* // { // KafkaSchemaRegistryAccessConfig
* // Type: "BASIC_AUTH" || "CLIENT_CERTIFICATE_TLS_AUTH" || "SERVER_ROOT_CA_CERTIFICATE",
* // URI: "STRING_VALUE",
* // },
* // ],
* // SchemaValidationConfigs: [ // KafkaSchemaValidationConfigList
* // { // KafkaSchemaValidationConfig
* // Attribute: "KEY" || "VALUE",
* // },
* // ],
* // },
* // },
* // SelfManagedKafkaEventSourceConfig: { // SelfManagedKafkaEventSourceConfig
* // ConsumerGroupId: "STRING_VALUE",
* // SchemaRegistryConfig: {
* // SchemaRegistryURI: "STRING_VALUE",
* // EventRecordFormat: "JSON" || "SOURCE",
* // AccessConfigs: [
* // {
* // Type: "BASIC_AUTH" || "CLIENT_CERTIFICATE_TLS_AUTH" || "SERVER_ROOT_CA_CERTIFICATE",
* // URI: "STRING_VALUE",
* // },
* // ],
* // SchemaValidationConfigs: [
* // {
* // Attribute: "KEY" || "VALUE",
* // },
* // ],
* // },
* // },
* // ScalingConfig: { // ScalingConfig
* // MaximumConcurrency: Number("int"),
* // },
* // DocumentDBEventSourceConfig: { // DocumentDBEventSourceConfig
* // DatabaseName: "STRING_VALUE",
* // CollectionName: "STRING_VALUE",
* // FullDocument: "UpdateLookup" || "Default",
* // },
* // KMSKeyArn: "STRING_VALUE",
* // FilterCriteriaError: { // FilterCriteriaError
* // ErrorCode: "STRING_VALUE",
* // Message: "STRING_VALUE",
* // },
* // EventSourceMappingArn: "STRING_VALUE",
* // MetricsConfig: { // EventSourceMappingMetricsConfig
* // Metrics: [ // EventSourceMappingMetricList
* // "EventCount",
* // ],
* // },
* // ProvisionedPollerConfig: { // ProvisionedPollerConfig
* // MinimumPollers: Number("int"),
* // MaximumPollers: Number("int"),
* // },
* // };
*
* ```
*
* @param CreateEventSourceMappingCommandInput - {@link CreateEventSourceMappingCommandInput}
* @returns {@link CreateEventSourceMappingCommandOutput}
* @see {@link CreateEventSourceMappingCommandInput} for command's `input` shape.
* @see {@link CreateEventSourceMappingCommandOutput} for command's `response` shape.
* @see {@link LambdaClientResolvedConfig | config} for LambdaClient's `config` shape.
*
* @throws {@link InvalidParameterValueException} (client fault)
* <p>One of the parameters in the request is not valid.</p>
*
* @throws {@link ResourceConflictException} (client fault)
* <p>The resource already exists, or another operation is in progress.</p>
*
* @throws {@link ResourceNotFoundException} (client fault)
* <p>The resource specified in the request does not exist.</p>
*
* @throws {@link ServiceException} (server fault)
* <p>The Lambda service encountered an internal error.</p>
*
* @throws {@link TooManyRequestsException} (client fault)
* <p>The request throughput limit was exceeded. For more information, see <a href="https://docs.aws.amazon.com/lambda/latest/dg/gettingstarted-limits.html#api-requests">Lambda quotas</a>.</p>
*
* @throws {@link LambdaServiceException}
* <p>Base exception class for all service exceptions from Lambda service.</p>
*
*
* @example To create a mapping between an event source and an AWS Lambda function
* ```javascript
* // The following example creates a mapping between an SQS queue and the my-function Lambda function.
* const input = {
* BatchSize: 5,
* EventSourceArn: "arn:aws:sqs:us-west-2:123456789012:my-queue",
* FunctionName: "my-function"
* };
* const command = new CreateEventSourceMappingCommand(input);
* const response = await client.send(command);
* /* response is
* {
* BatchSize: 5,
* EventSourceArn: "arn:aws:sqs:us-west-2:123456789012:my-queue",
* FunctionArn: "arn:aws:lambda:us-west-2:123456789012:function:my-function",
* LastModified: 1.569284520333E9,
* State: "Creating",
* StateTransitionReason: "USER_INITIATED",
* UUID: "a1b2c3d4-5678-90ab-cdef-11111EXAMPLE"
* }
* *\/
* ```
*
* @public
*/
export declare class CreateEventSourceMappingCommand extends CreateEventSourceMappingCommand_base {
/** @internal type navigation helper, not in runtime. */
protected static __types: {
api: {
input: CreateEventSourceMappingRequest;
output: EventSourceMappingConfiguration;
};
sdk: {
input: CreateEventSourceMappingCommandInput;
output: CreateEventSourceMappingCommandOutput;
};
};
}