AWS::Events::Rule Target - Amazon CloudFormation
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China (PDF).

AWS::Events::Rule Target

Targets are the resources to be invoked when a rule is triggered. For a complete list of services and resources that can be set as a target, see PutTargets.

If you are setting the event bus of another account as the target, and that account granted permission to your account through an organization instead of directly by the account ID, then you must specify a RoleArn with proper permissions in the Target structure. For more information, see Sending and Receiving Events Between Amazon Accounts in the Amazon EventBridge User Guide.

Syntax

To declare this entity in your Amazon CloudFormation template, use the following syntax:

Properties

AppSyncParameters

Contains the GraphQL operation to be parsed and executed, if the event target is an Amazon AppSync API.

Required: No

Type: AppSyncParameters

Update requires: No interruption

Arn

The Amazon Resource Name (ARN) of the target.

Required: Yes

Type: String

Minimum: 1

Maximum: 1600

Update requires: No interruption

BatchParameters

If the event target is an Amazon Batch job, this contains the job definition, job name, and other parameters. For more information, see Jobs in the Amazon Batch User Guide.

Required: No

Type: BatchParameters

Update requires: No interruption

DeadLetterConfig

The DeadLetterConfig that defines the target queue to send dead-letter queue events to.

Required: No

Type: DeadLetterConfig

Update requires: No interruption

EcsParameters

Contains the Amazon ECS task definition and task count to be used, if the event target is an Amazon ECS task. For more information about Amazon ECS tasks, see Task Definitions in the Amazon EC2 Container Service Developer Guide.

Required: No

Type: EcsParameters

Update requires: No interruption

HttpParameters

Contains the HTTP parameters to use when the target is a API Gateway endpoint or EventBridge ApiDestination.

If you specify an API Gateway API or EventBridge ApiDestination as a target, you can use this parameter to specify headers, path parameters, and query string keys/values as part of your target invoking request. If you're using ApiDestinations, the corresponding Connection can also have these values configured. In case of any conflicting keys, values from the Connection take precedence.

Required: No

Type: HttpParameters

Update requires: No interruption

Id

The ID of the target within the specified rule. Use this ID to reference the target when updating the rule. We recommend using a memorable and unique string.

Required: Yes

Type: String

Pattern: [\.\-_A-Za-z0-9]+

Minimum: 1

Maximum: 64

Update requires: No interruption

Input

Valid JSON text passed to the target. In this case, nothing from the event itself is passed to the target. For more information, see The JavaScript Object Notation (JSON) Data Interchange Format.

Required: No

Type: String

Maximum: 8192

Update requires: No interruption

InputPath

The value of the JSONPath that is used for extracting part of the matched event when passing it to the target. You may use JSON dot notation or bracket notation. For more information about JSON paths, see JSONPath.

Required: No

Type: String

Maximum: 256

Update requires: No interruption

InputTransformer

Settings to enable you to provide custom input to a target based on certain event data. You can extract one or more key-value pairs from the event and then use that data to send customized input to the target.

Required: No

Type: InputTransformer

Update requires: No interruption

KinesisParameters

The custom parameter you can use to control the shard assignment, when the target is a Kinesis data stream. If you do not include this parameter, the default is to use the eventId as the partition key.

Required: No

Type: KinesisParameters

Update requires: No interruption

RedshiftDataParameters

Contains the Amazon Redshift Data API parameters to use when the target is a Amazon Redshift cluster.

If you specify a Amazon Redshift Cluster as a Target, you can use this to specify parameters to invoke the Amazon Redshift Data API ExecuteStatement based on EventBridge events.

Required: No

Type: RedshiftDataParameters

Update requires: No interruption

RetryPolicy

The RetryPolicy object that contains the retry policy configuration to use for the dead-letter queue.

Required: No

Type: RetryPolicy

Update requires: No interruption

RoleArn

The Amazon Resource Name (ARN) of the IAM role to be used for this target when the rule is triggered. If one rule triggers multiple targets, you can use a different IAM role for each target.

Required: Conditional

Type: String

Minimum: 1

Maximum: 1600

Update requires: No interruption

RunCommandParameters

Parameters used when you are using the rule to invoke Amazon EC2 Run Command.

Required: No

Type: RunCommandParameters

Update requires: No interruption

SageMakerPipelineParameters

Contains the SageMaker Model Building Pipeline parameters to start execution of a SageMaker Model Building Pipeline.

If you specify a SageMaker Model Building Pipeline as a target, you can use this to specify parameters to start a pipeline execution based on EventBridge events.

Required: No

Type: SageMakerPipelineParameters

Update requires: No interruption

SqsParameters

Contains the message group ID to use when the target is a FIFO queue.

If you specify an SQS FIFO queue as a target, the queue must have content-based deduplication enabled.

Required: No

Type: SqsParameters

Update requires: No interruption

Examples

Target with KinesisParameters

The following snippet creates a Kinesis data stream target.

JSON

"MyEventsRule": { "Type": "AWS::Events::Rule", "Properties": { "Description": "Events Rule with KinesisParameters", "EventPattern": { "source": [ "aws.ec2" ] }, "RoleArn": { "Fn::GetAtt": [ "EventsInvokeKinesisTargetRole", "Arn" ] }, "ScheduleExpression": "rate(5 minutes)", "State": "ENABLED", "Targets": [ { "Arn": { "Fn::GetAtt": [ "MyFirstStream", "Arn" ] }, "Id": "Id123", "RoleArn": { "Fn::GetAtt": [ "EventsInvokeKinesisTargetRole", "Arn" ] }, "KinesisParameters": { "PartitionKeyPath": "$" } } ] } }

YAML

MyEventsRule: Type: AWS::Events::Rule Properties: Description: Events Rule with KinesisParameters EventPattern: source: - aws.ec2 RoleArn: !GetAtt - EventsInvokeKinesisTargetRole - Arn ScheduleExpression: rate(5 minutes) State: ENABLED Targets: - Arn: !GetAtt - MyFirstStream - Arn Id: Id123 RoleArn: !GetAtt - EventsInvokeKinesisTargetRole - Arn KinesisParameters: PartitionKeyPath: $

Target with EcsParameters

The following snippet creates an Amazon ECS task target.

JSON

"MyEventsRule": { "Type": "AWS::Events::Rule", "Properties": { "Description": "Events Rule with EcsParameters", "EventPattern": { "source": [ "aws.ec2" ], "detail-type": [ "EC2 Instance State-change Notification" ], "detail": { "state": [ "stopping" ] } }, "ScheduleExpression": "rate(15 minutes)", "State": "DISABLED", "Targets": [ { "Arn": { "Fn::GetAtt": [ "MyCluster", "Arn" ] }, "RoleArn": { "Fn::GetAtt": [ "ECSTaskRole", "Arn" ] }, "Id": "Id345", "EcsParameters": { "TaskCount": 1, "TaskDefinitionArn": { "Ref": "MyECSTask" } } } ] } }

YAML

MyEventsRule: Type: AWS::Events::Rule Properties: Description: Events Rule with EcsParameters EventPattern: source: - aws.ec2 detail-type: - EC2 Instance State-change Notification detail: state: - stopping ScheduleExpression: rate(15 minutes) State: DISABLED Targets: - Arn: !GetAtt - MyCluster - Arn RoleArn: !GetAtt - ECSTaskRole - Arn Id: Id345 EcsParameters: TaskCount: 1 TaskDefinitionArn: !Ref MyECSTask