aws-cdk-lib.aws_lambda.CfnEventSourceMapping

class CfnEventSourceMapping (construct)

LanguageType name
.NETAmazon.CDK.AWS.Lambda.CfnEventSourceMapping
Gogithub.com/aws/aws-cdk-go/awscdk/v2/awslambda#CfnEventSourceMapping
Javasoftware.amazon.awscdk.services.lambda.CfnEventSourceMapping
Pythonaws_cdk.aws_lambda.CfnEventSourceMapping
TypeScript aws-cdk-lib » aws_lambda » CfnEventSourceMapping

Implements IConstruct, IDependable, IInspectable

A CloudFormation AWS::Lambda::EventSourceMapping.

The AWS::Lambda::EventSourceMapping resource creates a mapping between an event source and an AWS Lambda function. Lambda reads items from the event source and triggers the function.

For details about each event source type, see the following topics. In particular, each of the topics describes the required and optional parameters for the specific event source.

  • Configuring a Dynamo DB stream as an event source
  • Configuring a Kinesis stream as an event source
  • Configuring an SQS queue as an event source
  • Configuring an MQ broker as an event source
  • Configuring MSK as an event source
  • Configuring Self-Managed Apache Kafka as an event source
  • Configuring Amazon DocumentDB as an event source

Example

// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import { aws_lambda as lambda } from 'aws-cdk-lib';
const cfnEventSourceMapping = new lambda.CfnEventSourceMapping(this, 'MyCfnEventSourceMapping', {
  functionName: 'functionName',

  // the properties below are optional
  amazonManagedKafkaEventSourceConfig: {
    consumerGroupId: 'consumerGroupId',
  },
  batchSize: 123,
  bisectBatchOnFunctionError: false,
  destinationConfig: {
    onFailure: {
      destination: 'destination',
    },
  },
  documentDbEventSourceConfig: {
    collectionName: 'collectionName',
    databaseName: 'databaseName',
    fullDocument: 'fullDocument',
  },
  enabled: false,
  eventSourceArn: 'eventSourceArn',
  filterCriteria: {
    filters: [{
      pattern: 'pattern',
    }],
  },
  functionResponseTypes: ['functionResponseTypes'],
  maximumBatchingWindowInSeconds: 123,
  maximumRecordAgeInSeconds: 123,
  maximumRetryAttempts: 123,
  parallelizationFactor: 123,
  queues: ['queues'],
  scalingConfig: {
    maximumConcurrency: 123,
  },
  selfManagedEventSource: {
    endpoints: {
      kafkaBootstrapServers: ['kafkaBootstrapServers'],
    },
  },
  selfManagedKafkaEventSourceConfig: {
    consumerGroupId: 'consumerGroupId',
  },
  sourceAccessConfigurations: [{
    type: 'type',
    uri: 'uri',
  }],
  startingPosition: 'startingPosition',
  startingPositionTimestamp: 123,
  topics: ['topics'],
  tumblingWindowInSeconds: 123,
});

Initializer

new CfnEventSourceMapping(scope: Construct, id: string, props: CfnEventSourceMappingProps)

Parameters

  • scope Construct — - scope in which this resource is defined.
  • id string — - scoped id of the resource.
  • props CfnEventSourceMappingProps — - resource properties.

Create a new AWS::Lambda::EventSourceMapping.

Construct Props

NameTypeDescription
functionNamestringThe name of the Lambda function.
amazonManagedKafkaEventSourceConfig?IResolvable | AmazonManagedKafkaEventSourceConfigPropertySpecific configuration settings for an Amazon Managed Streaming for Apache Kafka (Amazon MSK) event source.
batchSize?numberThe maximum number of records in each batch that Lambda pulls from your stream or queue and sends to your function.
bisectBatchOnFunctionError?boolean | IResolvable(Kinesis and DynamoDB Streams only) If the function returns an error, split the batch in two and retry.
destinationConfig?IResolvable | DestinationConfigProperty(Kinesis and DynamoDB Streams only) An Amazon SQS queue or Amazon SNS topic destination for discarded records.
documentDbEventSourceConfig?IResolvable | DocumentDBEventSourceConfigPropertySpecific configuration settings for a DocumentDB event source.
enabled?boolean | IResolvableWhen true, the event source mapping is active. When false, Lambda pauses polling and invocation.
eventSourceArn?stringThe Amazon Resource Name (ARN) of the event source.
filterCriteria?IResolvable | FilterCriteriaPropertyAn object that defines the filter criteria that determine whether Lambda should process an event.
functionResponseTypes?string[](Streams and SQS) A list of current response type enums applied to the event source mapping.
maximumBatchingWindowInSeconds?numberThe maximum amount of time, in seconds, that Lambda spends gathering records before invoking the function.
maximumRecordAgeInSeconds?number(Kinesis and DynamoDB Streams only) Discard records older than the specified age.
maximumRetryAttempts?number(Kinesis and DynamoDB Streams only) Discard records after the specified number of retries.
parallelizationFactor?number(Kinesis and DynamoDB Streams only) The number of batches to process concurrently from each shard.
queues?string[](Amazon MQ) The name of the Amazon MQ broker destination queue to consume.
scalingConfig?IResolvable | ScalingConfigProperty(Amazon SQS only) The scaling configuration for the event source.
selfManagedEventSource?IResolvable | SelfManagedEventSourcePropertyThe self-managed Apache Kafka cluster for your event source.
selfManagedKafkaEventSourceConfig?IResolvable | SelfManagedKafkaEventSourceConfigPropertySpecific configuration settings for a self-managed Apache Kafka event source.
sourceAccessConfigurations?IResolvable | IResolvable | SourceAccessConfigurationProperty[]An array of the authentication protocol, VPC components, or virtual host to secure and define your event source.
startingPosition?stringThe position in a stream from which to start reading. Required for Amazon Kinesis and Amazon DynamoDB.
startingPositionTimestamp?numberWith StartingPosition set to AT_TIMESTAMP , the time from which to start reading, in Unix time seconds.
topics?string[]The name of the Kafka topic.
tumblingWindowInSeconds?number(Kinesis and DynamoDB Streams only) The duration in seconds of a processing window for DynamoDB and Kinesis Streams event sources.

functionName

Type: string

The name of the Lambda function.

Name formats - Function name – MyFunction .

  • Function ARN – arn:aws:lambda:us-west-2:123456789012:function:MyFunction .
  • Version or Alias ARN – arn:aws:lambda:us-west-2:123456789012:function:MyFunction:PROD .
  • Partial ARN – 123456789012:function:MyFunction .

The length constraint applies only to the full ARN. If you specify only the function name, it's limited to 64 characters in length.


amazonManagedKafkaEventSourceConfig?

Type: IResolvable | AmazonManagedKafkaEventSourceConfigProperty (optional)

Specific configuration settings for an Amazon Managed Streaming for Apache Kafka (Amazon MSK) event source.


batchSize?

Type: number (optional)

The maximum number of records in each batch that Lambda pulls from your stream or queue and sends to your function.

Lambda passes all of the records in the batch to the function in a single call, up to the payload limit for synchronous invocation (6 MB).

  • Amazon Kinesis – Default 100. Max 10,000.
  • Amazon DynamoDB Streams – Default 100. Max 10,000.
  • Amazon Simple Queue Service – Default 10. For standard queues the max is 10,000. For FIFO queues the max is 10.
  • Amazon Managed Streaming for Apache Kafka – Default 100. Max 10,000.
  • Self-managed Apache Kafka – Default 100. Max 10,000.
  • Amazon MQ (ActiveMQ and RabbitMQ) – Default 100. Max 10,000.
  • DocumentDB – Default 100. Max 10,000.

bisectBatchOnFunctionError?

Type: boolean | IResolvable (optional)

(Kinesis and DynamoDB Streams only) If the function returns an error, split the batch in two and retry.

The default value is false.


destinationConfig?

Type: IResolvable | DestinationConfigProperty (optional)

(Kinesis and DynamoDB Streams only) An Amazon SQS queue or Amazon SNS topic destination for discarded records.


documentDbEventSourceConfig?

Type: IResolvable | DocumentDBEventSourceConfigProperty (optional)

Specific configuration settings for a DocumentDB event source.


enabled?

Type: boolean | IResolvable (optional)

When true, the event source mapping is active. When false, Lambda pauses polling and invocation.

Default: True


eventSourceArn?

Type: string (optional)

The Amazon Resource Name (ARN) of the event source.

  • Amazon Kinesis – The ARN of the data stream or a stream consumer.
  • Amazon DynamoDB Streams – The ARN of the stream.
  • Amazon Simple Queue Service – The ARN of the queue.
  • Amazon Managed Streaming for Apache Kafka – The ARN of the cluster.
  • Amazon MQ – The ARN of the broker.
  • Amazon DocumentDB – The ARN of the DocumentDB change stream.

filterCriteria?

Type: IResolvable | FilterCriteriaProperty (optional)

An object that defines the filter criteria that determine whether Lambda should process an event.

For more information, see Lambda event filtering .


functionResponseTypes?

Type: string[] (optional)

(Streams and SQS) A list of current response type enums applied to the event source mapping.

Valid Values: ReportBatchItemFailures


maximumBatchingWindowInSeconds?

Type: number (optional)

The maximum amount of time, in seconds, that Lambda spends gathering records before invoking the function.

Default ( Kinesis , DynamoDB , Amazon SQS event sources) : 0

Default ( Amazon MSK , Kafka, Amazon MQ , Amazon DocumentDB event sources) : 500 ms

Related setting: For Amazon SQS event sources, when you set BatchSize to a value greater than 10, you must set MaximumBatchingWindowInSeconds to at least 1.


maximumRecordAgeInSeconds?

Type: number (optional)

(Kinesis and DynamoDB Streams only) Discard records older than the specified age.

The default value is -1, which sets the maximum age to infinite. When the value is set to infinite, Lambda never discards old records.

The minimum valid value for maximum record age is 60s. Although values less than 60 and greater than -1 fall within the parameter's absolute range, they are not allowed


maximumRetryAttempts?

Type: number (optional)

(Kinesis and DynamoDB Streams only) Discard records after the specified number of retries.

The default value is -1, which sets the maximum number of retries to infinite. When MaximumRetryAttempts is infinite, Lambda retries failed records until the record expires in the event source.


parallelizationFactor?

Type: number (optional)

(Kinesis and DynamoDB Streams only) The number of batches to process concurrently from each shard.

The default value is 1.


queues?

Type: string[] (optional)

(Amazon MQ) The name of the Amazon MQ broker destination queue to consume.


scalingConfig?

Type: IResolvable | ScalingConfigProperty (optional)

(Amazon SQS only) The scaling configuration for the event source.

For more information, see Configuring maximum concurrency for Amazon SQS event sources .


selfManagedEventSource?

Type: IResolvable | SelfManagedEventSourceProperty (optional)

The self-managed Apache Kafka cluster for your event source.


selfManagedKafkaEventSourceConfig?

Type: IResolvable | SelfManagedKafkaEventSourceConfigProperty (optional)

Specific configuration settings for a self-managed Apache Kafka event source.


sourceAccessConfigurations?

Type: IResolvable | IResolvable | SourceAccessConfigurationProperty[] (optional)

An array of the authentication protocol, VPC components, or virtual host to secure and define your event source.


startingPosition?

Type: string (optional)

The position in a stream from which to start reading. Required for Amazon Kinesis and Amazon DynamoDB.

  • LATEST - Read only new records.
  • TRIM_HORIZON - Process all available records.
  • AT_TIMESTAMP - Specify a time from which to start reading records.

startingPositionTimestamp?

Type: number (optional)

With StartingPosition set to AT_TIMESTAMP , the time from which to start reading, in Unix time seconds.

StartingPositionTimestamp cannot be in the future.


topics?

Type: string[] (optional)

The name of the Kafka topic.


tumblingWindowInSeconds?

Type: number (optional)

(Kinesis and DynamoDB Streams only) The duration in seconds of a processing window for DynamoDB and Kinesis Streams event sources.

A value of 0 seconds indicates no tumbling window.

Properties

NameTypeDescription
attrIdstringThe event source mapping's ID.
cfnOptionsICfnResourceOptionsOptions for this resource, such as condition, update policy etc.
cfnProperties{ [string]: any }
cfnResourceTypestringAWS resource type.
creationStackstring[]
functionNamestringThe name of the Lambda function.
logicalIdstringThe logical ID for this CloudFormation stack element.
nodeNodeThe tree node.
refstringReturn a string that will be resolved to a CloudFormation { Ref } for this element.
stackStackThe stack in which this element is defined.
amazonManagedKafkaEventSourceConfig?IResolvable | AmazonManagedKafkaEventSourceConfigPropertySpecific configuration settings for an Amazon Managed Streaming for Apache Kafka (Amazon MSK) event source.
batchSize?numberThe maximum number of records in each batch that Lambda pulls from your stream or queue and sends to your function.
bisectBatchOnFunctionError?boolean | IResolvable(Kinesis and DynamoDB Streams only) If the function returns an error, split the batch in two and retry.
destinationConfig?IResolvable | DestinationConfigProperty(Kinesis and DynamoDB Streams only) An Amazon SQS queue or Amazon SNS topic destination for discarded records.
documentDbEventSourceConfig?IResolvable | DocumentDBEventSourceConfigPropertySpecific configuration settings for a DocumentDB event source.
enabled?boolean | IResolvableWhen true, the event source mapping is active. When false, Lambda pauses polling and invocation.
eventSourceArn?stringThe Amazon Resource Name (ARN) of the event source.
filterCriteria?IResolvable | FilterCriteriaPropertyAn object that defines the filter criteria that determine whether Lambda should process an event.
functionResponseTypes?string[](Streams and SQS) A list of current response type enums applied to the event source mapping.
maximumBatchingWindowInSeconds?numberThe maximum amount of time, in seconds, that Lambda spends gathering records before invoking the function.
maximumRecordAgeInSeconds?number(Kinesis and DynamoDB Streams only) Discard records older than the specified age.
maximumRetryAttempts?number(Kinesis and DynamoDB Streams only) Discard records after the specified number of retries.
parallelizationFactor?number(Kinesis and DynamoDB Streams only) The number of batches to process concurrently from each shard.
queues?string[](Amazon MQ) The name of the Amazon MQ broker destination queue to consume.
scalingConfig?IResolvable | ScalingConfigProperty(Amazon SQS only) The scaling configuration for the event source.
selfManagedEventSource?IResolvable | SelfManagedEventSourcePropertyThe self-managed Apache Kafka cluster for your event source.
selfManagedKafkaEventSourceConfig?IResolvable | SelfManagedKafkaEventSourceConfigPropertySpecific configuration settings for a self-managed Apache Kafka event source.
sourceAccessConfigurations?IResolvable | IResolvable | SourceAccessConfigurationProperty[]An array of the authentication protocol, VPC components, or virtual host to secure and define your event source.
startingPosition?stringThe position in a stream from which to start reading. Required for Amazon Kinesis and Amazon DynamoDB.
startingPositionTimestamp?numberWith StartingPosition set to AT_TIMESTAMP , the time from which to start reading, in Unix time seconds.
topics?string[]The name of the Kafka topic.
tumblingWindowInSeconds?number(Kinesis and DynamoDB Streams only) The duration in seconds of a processing window for DynamoDB and Kinesis Streams event sources.
static CFN_RESOURCE_TYPE_NAMEstringThe CloudFormation resource type name for this resource class.

attrId

Type: string

The event source mapping's ID.


cfnOptions

Type: ICfnResourceOptions

Options for this resource, such as condition, update policy etc.


cfnProperties

Type: { [string]: any }


cfnResourceType

Type: string

AWS resource type.


creationStack

Type: string[]


functionName

Type: string

The name of the Lambda function.

Name formats - Function name – MyFunction .

  • Function ARN – arn:aws:lambda:us-west-2:123456789012:function:MyFunction .
  • Version or Alias ARN – arn:aws:lambda:us-west-2:123456789012:function:MyFunction:PROD .
  • Partial ARN – 123456789012:function:MyFunction .

The length constraint applies only to the full ARN. If you specify only the function name, it's limited to 64 characters in length.


logicalId

Type: string

The logical ID for this CloudFormation stack element.

The logical ID of the element is calculated from the path of the resource node in the construct tree.

To override this value, use overrideLogicalId(newLogicalId).


node

Type: Node

The tree node.


ref

Type: string

Return a string that will be resolved to a CloudFormation { Ref } for this element.

If, by any chance, the intrinsic reference of a resource is not a string, you could coerce it to an IResolvable through Lazy.any({ produce: resource.ref }).


stack

Type: Stack

The stack in which this element is defined.

CfnElements must be defined within a stack scope (directly or indirectly).


amazonManagedKafkaEventSourceConfig?

Type: IResolvable | AmazonManagedKafkaEventSourceConfigProperty (optional)

Specific configuration settings for an Amazon Managed Streaming for Apache Kafka (Amazon MSK) event source.


batchSize?

Type: number (optional)

The maximum number of records in each batch that Lambda pulls from your stream or queue and sends to your function.

Lambda passes all of the records in the batch to the function in a single call, up to the payload limit for synchronous invocation (6 MB).

  • Amazon Kinesis – Default 100. Max 10,000.
  • Amazon DynamoDB Streams – Default 100. Max 10,000.
  • Amazon Simple Queue Service – Default 10. For standard queues the max is 10,000. For FIFO queues the max is 10.
  • Amazon Managed Streaming for Apache Kafka – Default 100. Max 10,000.
  • Self-managed Apache Kafka – Default 100. Max 10,000.
  • Amazon MQ (ActiveMQ and RabbitMQ) – Default 100. Max 10,000.
  • DocumentDB – Default 100. Max 10,000.

bisectBatchOnFunctionError?

Type: boolean | IResolvable (optional)

(Kinesis and DynamoDB Streams only) If the function returns an error, split the batch in two and retry.

The default value is false.


destinationConfig?

Type: IResolvable | DestinationConfigProperty (optional)

(Kinesis and DynamoDB Streams only) An Amazon SQS queue or Amazon SNS topic destination for discarded records.


documentDbEventSourceConfig?

Type: IResolvable | DocumentDBEventSourceConfigProperty (optional)

Specific configuration settings for a DocumentDB event source.


enabled?

Type: boolean | IResolvable (optional)

When true, the event source mapping is active. When false, Lambda pauses polling and invocation.

Default: True


eventSourceArn?

Type: string (optional)

The Amazon Resource Name (ARN) of the event source.

  • Amazon Kinesis – The ARN of the data stream or a stream consumer.
  • Amazon DynamoDB Streams – The ARN of the stream.
  • Amazon Simple Queue Service – The ARN of the queue.
  • Amazon Managed Streaming for Apache Kafka – The ARN of the cluster.
  • Amazon MQ – The ARN of the broker.
  • Amazon DocumentDB – The ARN of the DocumentDB change stream.

filterCriteria?

Type: IResolvable | FilterCriteriaProperty (optional)

An object that defines the filter criteria that determine whether Lambda should process an event.

For more information, see Lambda event filtering .


functionResponseTypes?

Type: string[] (optional)

(Streams and SQS) A list of current response type enums applied to the event source mapping.

Valid Values: ReportBatchItemFailures


maximumBatchingWindowInSeconds?

Type: number (optional)

The maximum amount of time, in seconds, that Lambda spends gathering records before invoking the function.

Default ( Kinesis , DynamoDB , Amazon SQS event sources) : 0

Default ( Amazon MSK , Kafka, Amazon MQ , Amazon DocumentDB event sources) : 500 ms

Related setting: For Amazon SQS event sources, when you set BatchSize to a value greater than 10, you must set MaximumBatchingWindowInSeconds to at least 1.


maximumRecordAgeInSeconds?

Type: number (optional)

(Kinesis and DynamoDB Streams only) Discard records older than the specified age.

The default value is -1, which sets the maximum age to infinite. When the value is set to infinite, Lambda never discards old records.

The minimum valid value for maximum record age is 60s. Although values less than 60 and greater than -1 fall within the parameter's absolute range, they are not allowed


maximumRetryAttempts?

Type: number (optional)

(Kinesis and DynamoDB Streams only) Discard records after the specified number of retries.

The default value is -1, which sets the maximum number of retries to infinite. When MaximumRetryAttempts is infinite, Lambda retries failed records until the record expires in the event source.


parallelizationFactor?

Type: number (optional)

(Kinesis and DynamoDB Streams only) The number of batches to process concurrently from each shard.

The default value is 1.


queues?

Type: string[] (optional)

(Amazon MQ) The name of the Amazon MQ broker destination queue to consume.


scalingConfig?

Type: IResolvable | ScalingConfigProperty (optional)

(Amazon SQS only) The scaling configuration for the event source.

For more information, see Configuring maximum concurrency for Amazon SQS event sources .


selfManagedEventSource?

Type: IResolvable | SelfManagedEventSourceProperty (optional)

The self-managed Apache Kafka cluster for your event source.


selfManagedKafkaEventSourceConfig?

Type: IResolvable | SelfManagedKafkaEventSourceConfigProperty (optional)

Specific configuration settings for a self-managed Apache Kafka event source.


sourceAccessConfigurations?

Type: IResolvable | IResolvable | SourceAccessConfigurationProperty[] (optional)

An array of the authentication protocol, VPC components, or virtual host to secure and define your event source.


startingPosition?

Type: string (optional)

The position in a stream from which to start reading. Required for Amazon Kinesis and Amazon DynamoDB.

  • LATEST - Read only new records.
  • TRIM_HORIZON - Process all available records.
  • AT_TIMESTAMP - Specify a time from which to start reading records.

startingPositionTimestamp?

Type: number (optional)

With StartingPosition set to AT_TIMESTAMP , the time from which to start reading, in Unix time seconds.

StartingPositionTimestamp cannot be in the future.


topics?

Type: string[] (optional)

The name of the Kafka topic.


tumblingWindowInSeconds?

Type: number (optional)

(Kinesis and DynamoDB Streams only) The duration in seconds of a processing window for DynamoDB and Kinesis Streams event sources.

A value of 0 seconds indicates no tumbling window.


static CFN_RESOURCE_TYPE_NAME

Type: string

The CloudFormation resource type name for this resource class.

Methods

NameDescription
addDeletionOverride(path)Syntactic sugar for addOverride(path, undefined).
addDependency(target)Indicates that this resource depends on another resource and cannot be provisioned unless the other resource has been successfully provisioned.
addDependsOn(target)⚠️Indicates that this resource depends on another resource and cannot be provisioned unless the other resource has been successfully provisioned.
addMetadata(key, value)Add a value to the CloudFormation Resource Metadata.
addOverride(path, value)Adds an override to the synthesized CloudFormation resource.
addPropertyDeletionOverride(propertyPath)Adds an override that deletes the value of a property from the resource definition.
addPropertyOverride(propertyPath, value)Adds an override to a resource property.
applyRemovalPolicy(policy?, options?)Sets the deletion policy of the resource based on the removal policy specified.
getAtt(attributeName, typeHint?)Returns a token for an runtime attribute of this resource.
getMetadata(key)Retrieve a value value from the CloudFormation Resource Metadata.
inspect(inspector)Examines the CloudFormation resource and discloses attributes.
obtainDependencies()Retrieves an array of resources this resource depends on.
obtainResourceDependencies()Get a shallow copy of dependencies between this resource and other resources in the same stack.
overrideLogicalId(newLogicalId)Overrides the auto-generated logical ID with a specific ID.
removeDependency(target)Indicates that this resource no longer depends on another resource.
replaceDependency(target, newTarget)Replaces one dependency with another.
toString()Returns a string representation of this construct.
protected renderProperties(props)

addDeletionOverride(path)

public addDeletionOverride(path: string): void

Parameters

  • path string — The path of the value to delete.

Syntactic sugar for addOverride(path, undefined).


addDependency(target)

public addDependency(target: CfnResource): void

Parameters

  • target CfnResource

Indicates that this resource depends on another resource and cannot be provisioned unless the other resource has been successfully provisioned.

This can be used for resources across stacks (or nested stack) boundaries and the dependency will automatically be transferred to the relevant scope.


addDependsOn(target)⚠️

public addDependsOn(target: CfnResource): void

⚠️ Deprecated: use addDependency

Parameters

  • target CfnResource

Indicates that this resource depends on another resource and cannot be provisioned unless the other resource has been successfully provisioned.


addMetadata(key, value)

public addMetadata(key: string, value: any): void

Parameters

  • key string
  • value any

Add a value to the CloudFormation Resource Metadata.

See also: [https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/metadata-section-structure.html

Note that this is a different set of metadata from CDK node metadata; this metadata ends up in the stack template under the resource, whereas CDK node metadata ends up in the Cloud Assembly.](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/metadata-section-structure.html

Note that this is a different set of metadata from CDK node metadata; this metadata ends up in the stack template under the resource, whereas CDK node metadata ends up in the Cloud Assembly.)


addOverride(path, value)

public addOverride(path: string, value: any): void

Parameters

  • path string — - The path of the property, you can use dot notation to override values in complex types.
  • value any — - The value.

Adds an override to the synthesized CloudFormation resource.

To add a property override, either use addPropertyOverride or prefix path with "Properties." (i.e. Properties.TopicName).

If the override is nested, separate each nested level using a dot (.) in the path parameter. If there is an array as part of the nesting, specify the index in the path.

To include a literal . in the property name, prefix with a \. In most programming languages you will need to write this as "\\." because the \ itself will need to be escaped.

For example,

cfnResource.addOverride('Properties.GlobalSecondaryIndexes.0.Projection.NonKeyAttributes', ['myattribute']);
cfnResource.addOverride('Properties.GlobalSecondaryIndexes.1.ProjectionType', 'INCLUDE');

would add the overrides

"Properties": {
  "GlobalSecondaryIndexes": [
    {
      "Projection": {
        "NonKeyAttributes": [ "myattribute" ]
        ...
      }
      ...
    },
    {
      "ProjectionType": "INCLUDE"
      ...
    },
  ]
  ...
}

The value argument to addOverride will not be processed or translated in any way. Pass raw JSON values in here with the correct capitalization for CloudFormation. If you pass CDK classes or structs, they will be rendered with lowercased key names, and CloudFormation will reject the template.


addPropertyDeletionOverride(propertyPath)

public addPropertyDeletionOverride(propertyPath: string): void

Parameters

  • propertyPath string — The path to the property.

Adds an override that deletes the value of a property from the resource definition.


addPropertyOverride(propertyPath, value)

public addPropertyOverride(propertyPath: string, value: any): void

Parameters

  • propertyPath string — The path of the property.
  • value any — The value.

Adds an override to a resource property.

Syntactic sugar for addOverride("Properties.<...>", value).


applyRemovalPolicy(policy?, options?)

public applyRemovalPolicy(policy?: RemovalPolicy, options?: RemovalPolicyOptions): void

Parameters

  • policy RemovalPolicy
  • options RemovalPolicyOptions

Sets the deletion policy of the resource based on the removal policy specified.

The Removal Policy controls what happens to this resource when it stops being managed by CloudFormation, either because you've removed it from the CDK application or because you've made a change that requires the resource to be replaced.

The resource can be deleted (RemovalPolicy.DESTROY), or left in your AWS account for data recovery and cleanup later (RemovalPolicy.RETAIN). In some cases, a snapshot can be taken of the resource prior to deletion (RemovalPolicy.SNAPSHOT). A list of resources that support this policy can be found in the following link:

See also: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-attribute-deletionpolicy.html#aws-attribute-deletionpolicy-options


getAtt(attributeName, typeHint?)

public getAtt(attributeName: string, typeHint?: ResolutionTypeHint): Reference

Parameters

  • attributeName string — The name of the attribute.
  • typeHint ResolutionTypeHint

Returns

  • Reference

Returns a token for an runtime attribute of this resource.

Ideally, use generated attribute accessors (e.g. resource.arn), but this can be used for future compatibility in case there is no generated attribute.


getMetadata(key)

public getMetadata(key: string): any

Parameters

  • key string

Returns

  • any

Retrieve a value value from the CloudFormation Resource Metadata.

See also: [https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/metadata-section-structure.html

Note that this is a different set of metadata from CDK node metadata; this metadata ends up in the stack template under the resource, whereas CDK node metadata ends up in the Cloud Assembly.](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/metadata-section-structure.html

Note that this is a different set of metadata from CDK node metadata; this metadata ends up in the stack template under the resource, whereas CDK node metadata ends up in the Cloud Assembly.)


inspect(inspector)

public inspect(inspector: TreeInspector): void

Parameters

  • inspector TreeInspector — - tree inspector to collect and process attributes.

Examines the CloudFormation resource and discloses attributes.


obtainDependencies()

public obtainDependencies(): Stack &#124; CfnResource[]

Returns

  • Stack | CfnResource[]

Retrieves an array of resources this resource depends on.

This assembles dependencies on resources across stacks (including nested stacks) automatically.


obtainResourceDependencies()

public obtainResourceDependencies(): CfnResource[]

Returns

  • CfnResource[]

Get a shallow copy of dependencies between this resource and other resources in the same stack.


overrideLogicalId(newLogicalId)

public overrideLogicalId(newLogicalId: string): void

Parameters

  • newLogicalId string — The new logical ID to use for this stack element.

Overrides the auto-generated logical ID with a specific ID.


removeDependency(target)

public removeDependency(target: CfnResource): void

Parameters

  • target CfnResource

Indicates that this resource no longer depends on another resource.

This can be used for resources across stacks (including nested stacks) and the dependency will automatically be removed from the relevant scope.


replaceDependency(target, newTarget)

public replaceDependency(target: CfnResource, newTarget: CfnResource): void

Parameters

  • target CfnResource — The dependency to replace.
  • newTarget CfnResource — The new dependency to add.

Replaces one dependency with another.


toString()

public toString(): string

Returns

  • string

Returns a string representation of this construct.


protected renderProperties(props)

protected renderProperties(props: { [string]: any }): { [string]: any }

Parameters

  • props { [string]: any }

Returns

  • { [string]: any }