@aws-cdk/aws-events-targets

  • Version 1.204.0
  • Published
  • 687 kB
  • 20 dependencies
  • Apache-2.0 license

Install

npm i @aws-cdk/aws-events-targets
yarn add @aws-cdk/aws-events-targets
pnpm add @aws-cdk/aws-events-targets

Overview

Event targets for Amazon EventBridge

Index

Classes

class ApiDestination

class ApiDestination implements events.IRuleTarget {}
  • Use an API Destination rule target.

constructor

constructor(apiDestination: events.IApiDestination, props?: ApiDestinationProps);

    method bind

    bind: (_rule: events.IRule, _id?: string) => events.RuleTargetConfig;
    • Returns a RuleTarget that can be used to trigger API destinations from an EventBridge event.

    class ApiGateway

    class ApiGateway implements events.IRuleTarget {}
    • Use an API Gateway REST APIs as a target for Amazon EventBridge rules.

    constructor

    constructor(restApi: api.RestApi, props?: ApiGatewayProps);

      property restApi

      readonly restApi: api.RestApi;

        method bind

        bind: (rule: events.IRule, _id?: string) => events.RuleTargetConfig;
        • Returns a RuleTarget that can be used to trigger this API Gateway REST APIs as a result from an EventBridge event.

          See Also

          • https://docs.aws.amazon.com/eventbridge/latest/userguide/resource-based-policies-eventbridge.html#sqs-permissions

        class AwsApi

        class AwsApi implements events.IRuleTarget {}
        • Use an AWS Lambda function that makes API calls as an event rule target.

        constructor

        constructor(props: AwsApiProps);

          method bind

          bind: (rule: events.IRule, id?: string) => events.RuleTargetConfig;
          • Returns a RuleTarget that can be used to trigger this AwsApi as a result from an EventBridge event.

          class BatchJob

          class BatchJob implements events.IRuleTarget {}
          • Use an AWS Batch Job / Queue as an event rule target. Most likely the code will look something like this: new BatchJob(jobQueue.jobQueueArn, jobQueue, jobDefinition.jobDefinitionArn, jobDefinition)

            In the future this API will be improved to be fully typed

          constructor

          constructor(
          jobQueueArn: string,
          jobQueueScope: IConstruct,
          jobDefinitionArn: string,
          jobDefinitionScope: IConstruct,
          props?: BatchJobProps
          );

            method bind

            bind: (rule: events.IRule, _id?: string) => events.RuleTargetConfig;
            • Returns a RuleTarget that can be used to trigger queue this batch job as a result from an EventBridge event.

            class CloudWatchLogGroup

            class CloudWatchLogGroup implements events.IRuleTarget {}
            • Use an AWS CloudWatch LogGroup as an event rule target.

            constructor

            constructor(logGroup: logs.ILogGroup, props?: LogGroupProps);

              method bind

              bind: (_rule: events.IRule, _id?: string) => events.RuleTargetConfig;
              • Returns a RuleTarget that can be used to log an event into a CloudWatch LogGroup

              class CodeBuildProject

              class CodeBuildProject implements events.IRuleTarget {}
              • Start a CodeBuild build when an Amazon EventBridge rule is triggered.

              constructor

              constructor(project: codebuild.IProject, props?: CodeBuildProjectProps);

                method bind

                bind: (_rule: events.IRule, _id?: string) => events.RuleTargetConfig;
                • Allows using build projects as event rule targets.

                class CodePipeline

                class CodePipeline implements events.IRuleTarget {}
                • Allows the pipeline to be used as an EventBridge rule target.

                constructor

                constructor(
                pipeline: codepipeline.IPipeline,
                options?: CodePipelineTargetOptions
                );

                  method bind

                  bind: (_rule: events.IRule, _id?: string) => events.RuleTargetConfig;

                    class EcsTask

                    class EcsTask implements events.IRuleTarget {}
                    • Start a task on an ECS cluster

                    constructor

                    constructor(props: EcsTaskProps);

                      property securityGroup

                      readonly securityGroup?: ec2.ISecurityGroup;
                      • The security group associated with the task. Only applicable with awsvpc network mode.

                        - A new security group is created.

                        Deprecated

                        use securityGroups instead.

                      property securityGroups

                      readonly securityGroups?: ec2.ISecurityGroup[];
                      • The security groups associated with the task. Only applicable with awsvpc network mode.

                        - A new security group is created.

                      method bind

                      bind: (_rule: events.IRule, _id?: string) => events.RuleTargetConfig;
                      • Allows using tasks as target of EventBridge events

                      class EventBus

                      class EventBus implements events.IRuleTarget {}
                      • Notify an existing Event Bus of an event

                      constructor

                      constructor(eventBus: events.IEventBus, props?: EventBusProps);

                        method bind

                        bind: (rule: events.IRule, _id?: string) => events.RuleTargetConfig;

                          class KinesisFirehoseStream

                          class KinesisFirehoseStream implements events.IRuleTarget {}
                          • Customize the Firehose Stream Event Target

                          constructor

                          constructor(
                          stream: firehose.CfnDeliveryStream,
                          props?: KinesisFirehoseStreamProps
                          );

                            method bind

                            bind: (_rule: events.IRule, _id?: string) => events.RuleTargetConfig;
                            • Returns a RuleTarget that can be used to trigger this Firehose Stream as a result from a Event Bridge event.

                            class KinesisStream

                            class KinesisStream implements events.IRuleTarget {}
                            • Use a Kinesis Stream as a target for AWS CloudWatch event rules.

                              Example 1

                              /// fixture=withRepoAndKinesisStream // put to a Kinesis stream every time code is committed // to a CodeCommit repository repository.onCommit('onCommit', { target: new targets.KinesisStream(stream) });

                            constructor

                            constructor(stream: kinesis.IStream, props?: KinesisStreamProps);

                              method bind

                              bind: (_rule: events.IRule, _id?: string) => events.RuleTargetConfig;
                              • Returns a RuleTarget that can be used to trigger this Kinesis Stream as a result from a CloudWatch event.

                              class LambdaFunction

                              class LambdaFunction implements events.IRuleTarget {}
                              • Use an AWS Lambda function as an event rule target.

                              constructor

                              constructor(handler: lambda.IFunction, props?: LambdaFunctionProps);

                                method bind

                                bind: (rule: events.IRule, _id?: string) => events.RuleTargetConfig;
                                • Returns a RuleTarget that can be used to trigger this Lambda as a result from an EventBridge event.

                                class SfnStateMachine

                                class SfnStateMachine implements events.IRuleTarget {}
                                • Use a StepFunctions state machine as a target for Amazon EventBridge rules.

                                constructor

                                constructor(machine: sfn.IStateMachine, props?: SfnStateMachineProps);

                                  property machine

                                  readonly machine: sfn.IStateMachine;

                                    method bind

                                    bind: (_rule: events.IRule, _id?: string) => events.RuleTargetConfig;
                                    • Returns a properties that are used in an Rule to trigger this State Machine

                                      See Also

                                      • https://docs.aws.amazon.com/eventbridge/latest/userguide/resource-based-policies-eventbridge.html#sns-permissions

                                    class SnsTopic

                                    class SnsTopic implements events.IRuleTarget {}
                                    • Use an SNS topic as a target for Amazon EventBridge rules.

                                      Example 1

                                      /// fixture=withRepoAndTopic // publish to an SNS topic every time code is committed // to a CodeCommit repository repository.onCommit('onCommit', { target: new targets.SnsTopic(topic) });

                                    constructor

                                    constructor(topic: sns.ITopic, props?: SnsTopicProps);

                                      property topic

                                      readonly topic: sns.ITopic;

                                        method bind

                                        bind: (_rule: events.IRule, _id?: string) => events.RuleTargetConfig;
                                        • Returns a RuleTarget that can be used to trigger this SNS topic as a result from an EventBridge event.

                                          See Also

                                          • https://docs.aws.amazon.com/eventbridge/latest/userguide/resource-based-policies-eventbridge.html#sns-permissions

                                        class SqsQueue

                                        class SqsQueue implements events.IRuleTarget {}
                                        • Use an SQS Queue as a target for Amazon EventBridge rules.

                                          Example 1

                                          /// fixture=withRepoAndSqsQueue // publish to an SQS queue every time code is committed // to a CodeCommit repository repository.onCommit('onCommit', { target: new targets.SqsQueue(queue) });

                                        constructor

                                        constructor(queue: sqs.IQueue, props?: SqsQueueProps);

                                          property queue

                                          readonly queue: sqs.IQueue;

                                            method bind

                                            bind: (rule: events.IRule, _id?: string) => events.RuleTargetConfig;
                                            • Returns a RuleTarget that can be used to trigger this SQS queue as a result from an EventBridge event.

                                              See Also

                                              • https://docs.aws.amazon.com/eventbridge/latest/userguide/resource-based-policies-eventbridge.html#sqs-permissions

                                            Interfaces

                                            interface ApiDestinationProps

                                            interface ApiDestinationProps extends TargetBaseProps {}
                                            • Customize the EventBridge Api Destinations Target

                                            property event

                                            readonly event?: events.RuleTargetInput;
                                            • The event to send

                                              - the entire EventBridge event

                                            property eventRole

                                            readonly eventRole?: iam.IRole;
                                            • The role to assume before invoking the target

                                              - a new role will be created

                                            property headerParameters

                                            readonly headerParameters?: Record<string, string>;
                                            • Additional headers sent to the API Destination

                                              These are merged with headers specified on the Connection, with the headers on the Connection taking precedence.

                                              You can only specify secret values on the Connection.

                                              - none

                                            property pathParameterValues

                                            readonly pathParameterValues?: string[];
                                            • Path parameters to insert in place of path wildcards (*).

                                              If the API destination has a wilcard in the path, these path parts will be inserted in that place.

                                              - none

                                            property queryStringParameters

                                            readonly queryStringParameters?: Record<string, string>;
                                            • Additional query string parameters sent to the API Destination

                                              These are merged with headers specified on the Connection, with the headers on the Connection taking precedence.

                                              You can only specify secret values on the Connection.

                                              - none

                                            interface ApiGatewayProps

                                            interface ApiGatewayProps extends TargetBaseProps {}
                                            • Customize the API Gateway Event Target

                                            property eventRole

                                            readonly eventRole?: iam.IRole;
                                            • The role to assume before invoking the target (i.e., the pipeline) when the given rule is triggered.

                                              - a new role will be created

                                            property headerParameters

                                            readonly headerParameters?: {
                                            [key: string]: string;
                                            };
                                            • The headers to be set when requesting API

                                              no header parameters

                                            property method

                                            readonly method?: string;
                                            • The method for api resource invoked by the rule.

                                              '*' that treated as ANY

                                            property path

                                            readonly path?: string;
                                            • The api resource invoked by the rule. We can use wildcards('*') to specify the path. In that case, an equal number of real values must be specified for pathParameterValues.

                                              '/'

                                            property pathParameterValues

                                            readonly pathParameterValues?: string[];
                                            • The path parameter values to be used to populate to wildcards("*") of requesting api path

                                              no path parameters

                                            property postBody

                                            readonly postBody?: events.RuleTargetInput;
                                            • This will be the post request body send to the API.

                                              the entire EventBridge event

                                            property queryStringParameters

                                            readonly queryStringParameters?: {
                                            [key: string]: string;
                                            };
                                            • The query parameters to be set when requesting API.

                                              no querystring parameters

                                            property stage

                                            readonly stage?: string;
                                            • The deploy stage of api gateway invoked by the rule.

                                              the value of deploymentStage.stageName of target api gateway.

                                            interface AwsApiInput

                                            interface AwsApiInput {}
                                            • Rule target input for an AwsApi target.

                                            property action

                                            readonly action: string;
                                            • The service action to call

                                              See Also

                                              • https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/index.html

                                            property apiVersion

                                            readonly apiVersion?: string;
                                            • API version to use for the service

                                              See Also

                                              • https://docs.aws.amazon.com/sdk-for-javascript/v2/developer-guide/locking-api-versions.html - use latest available API version

                                            property catchErrorPattern

                                            readonly catchErrorPattern?: string;
                                            • The regex pattern to use to catch API errors. The code property of the Error object will be tested against this pattern. If there is a match an error will not be thrown.

                                              - do not catch errors

                                            property parameters

                                            readonly parameters?: any;
                                            • The parameters for the service action

                                              See Also

                                              • https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/index.html

                                                - no parameters

                                            property service

                                            readonly service: string;
                                            • The service to call

                                              See Also

                                              • https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/index.html

                                            interface AwsApiProps

                                            interface AwsApiProps extends AwsApiInput {}
                                            • Properties for an AwsApi target.

                                            property policyStatement

                                            readonly policyStatement?: iam.PolicyStatement;
                                            • The IAM policy statement to allow the API call. Use only if resource restriction is needed.

                                              - extract the permission from the API call

                                            interface BatchJobProps

                                            interface BatchJobProps extends TargetBaseProps {}
                                            • Customize the Batch Job Event Target

                                            property attempts

                                            readonly attempts?: number;
                                            • The number of times to attempt to retry, if the job fails. Valid values are 1–10.

                                              no retryStrategy is set

                                            property event

                                            readonly event?: events.RuleTargetInput;
                                            • The event to send to the Lambda

                                              This will be the payload sent to the Lambda Function.

                                              the entire EventBridge event

                                            property jobName

                                            readonly jobName?: string;
                                            • The name of the submitted job

                                              - Automatically generated

                                            property size

                                            readonly size?: number;
                                            • The size of the array, if this is an array batch job.

                                              Valid values are integers between 2 and 10,000.

                                              no arrayProperties are set

                                            interface CodeBuildProjectProps

                                            interface CodeBuildProjectProps extends TargetBaseProps {}
                                            • Customize the CodeBuild Event Target

                                            property event

                                            readonly event?: events.RuleTargetInput;
                                            • The event to send to CodeBuild

                                              This will be the payload for the StartBuild API.

                                              - the entire EventBridge event

                                            property eventRole

                                            readonly eventRole?: iam.IRole;
                                            • The role to assume before invoking the target (i.e., the codebuild) when the given rule is triggered.

                                              - a new role will be created

                                            interface CodePipelineTargetOptions

                                            interface CodePipelineTargetOptions extends TargetBaseProps {}
                                            • Customization options when creating a CodePipeline event target.

                                            property eventRole

                                            readonly eventRole?: iam.IRole;
                                            • The role to assume before invoking the target (i.e., the pipeline) when the given rule is triggered.

                                              - a new role will be created

                                            interface ContainerOverride

                                            interface ContainerOverride {}

                                              property command

                                              readonly command?: string[];
                                              • Command to run inside the container

                                                Default command

                                              property containerName

                                              readonly containerName: string;
                                              • Name of the container inside the task definition

                                              property cpu

                                              readonly cpu?: number;
                                              • The number of cpu units reserved for the container

                                                The default value from the task definition.

                                              property environment

                                              readonly environment?: TaskEnvironmentVariable[];
                                              • Variables to set in the container's environment

                                              property memoryLimit

                                              readonly memoryLimit?: number;
                                              • Hard memory limit on the container

                                                The default value from the task definition.

                                              property memoryReservation

                                              readonly memoryReservation?: number;
                                              • Soft memory limit on the container

                                                The default value from the task definition.

                                              interface EcsTaskProps

                                              interface EcsTaskProps {}
                                              • Properties to define an ECS Event Task

                                              property cluster

                                              readonly cluster: ecs.ICluster;
                                              • Cluster where service will be deployed

                                              property containerOverrides

                                              readonly containerOverrides?: ContainerOverride[];
                                              • Container setting overrides

                                                Key is the name of the container to override, value is the values you want to override.

                                              property platformVersion

                                              readonly platformVersion?: ecs.FargatePlatformVersion;
                                              • The platform version on which to run your task

                                                Unless you have specific compatibility requirements, you don't need to specify this.

                                                See Also

                                                • https://docs.aws.amazon.com/AmazonECS/latest/developerguide/platform_versions.html

                                                  - ECS will set the Fargate platform version to 'LATEST'

                                              property role

                                              readonly role?: iam.IRole;
                                              • Existing IAM role to run the ECS task

                                                A new IAM role is created

                                              property securityGroup

                                              readonly securityGroup?: ec2.ISecurityGroup;
                                              • Existing security group to use for the task's ENIs

                                                (Only applicable in case the TaskDefinition is configured for AwsVpc networking)

                                                A new security group is created

                                                Deprecated

                                                use securityGroups instead

                                              property securityGroups

                                              readonly securityGroups?: ec2.ISecurityGroup[];
                                              • Existing security groups to use for the task's ENIs

                                                (Only applicable in case the TaskDefinition is configured for AwsVpc networking)

                                                A new security group is created

                                              property subnetSelection

                                              readonly subnetSelection?: ec2.SubnetSelection;
                                              • In what subnets to place the task's ENIs

                                                (Only applicable in case the TaskDefinition is configured for AwsVpc networking)

                                                Private subnets

                                              property taskCount

                                              readonly taskCount?: number;
                                              • How many tasks should be started when this event is triggered

                                                1

                                              property taskDefinition

                                              readonly taskDefinition: ecs.ITaskDefinition;
                                              • Task Definition of the task that should be started

                                              interface EventBusProps

                                              interface EventBusProps {}
                                              • Configuration properties of an Event Bus event

                                                Cannot extend TargetBaseProps. Retry policy is not supported for Event bus targets.

                                              property deadLetterQueue

                                              readonly deadLetterQueue?: sqs.IQueue;
                                              • The SQS queue to be used as deadLetterQueue. Check out the [considerations for using a dead-letter queue](https://docs.aws.amazon.com/eventbridge/latest/userguide/rule-dlq.html#dlq-considerations).

                                                The events not successfully delivered are automatically retried for a specified period of time, depending on the retry policy of the target. If an event is not delivered before all retry attempts are exhausted, it will be sent to the dead letter queue.

                                                - no dead-letter queue

                                              property role

                                              readonly role?: iam.IRole;
                                              • Role to be used to publish the event

                                                a new role is created.

                                              interface KinesisFirehoseStreamProps

                                              interface KinesisFirehoseStreamProps {}
                                              • Customize the Firehose Stream Event Target

                                              property message

                                              readonly message?: events.RuleTargetInput;
                                              • The message to send to the stream.

                                                Must be a valid JSON text passed to the target stream.

                                                - the entire Event Bridge event

                                              interface KinesisStreamProps

                                              interface KinesisStreamProps {}
                                              • Customize the Kinesis Stream Event Target

                                              property message

                                              readonly message?: events.RuleTargetInput;
                                              • The message to send to the stream.

                                                Must be a valid JSON text passed to the target stream.

                                                - the entire CloudWatch event

                                              property partitionKeyPath

                                              readonly partitionKeyPath?: string;
                                              • Partition Key Path for records sent to this stream

                                                - eventId as the partition key

                                              interface LambdaFunctionProps

                                              interface LambdaFunctionProps extends TargetBaseProps {}
                                              • Customize the Lambda Event Target

                                              property event

                                              readonly event?: events.RuleTargetInput;
                                              • The event to send to the Lambda

                                                This will be the payload sent to the Lambda Function.

                                                the entire EventBridge event

                                              interface LogGroupProps

                                              interface LogGroupProps extends TargetBaseProps {}
                                              • Customize the CloudWatch LogGroup Event Target

                                              property event

                                              readonly event?: events.RuleTargetInput;
                                              • The event to send to the CloudWatch LogGroup

                                                This will be the event logged into the CloudWatch LogGroup

                                                - the entire EventBridge event

                                              interface SfnStateMachineProps

                                              interface SfnStateMachineProps extends TargetBaseProps {}
                                              • Customize the Step Functions State Machine target

                                              property input

                                              readonly input?: events.RuleTargetInput;
                                              • The input to the state machine execution

                                                the entire EventBridge event

                                              property role

                                              readonly role?: iam.IRole;
                                              • The IAM role to be assumed to execute the State Machine

                                                - a new role will be created

                                              interface SnsTopicProps

                                              interface SnsTopicProps {}
                                              • Customize the SNS Topic Event Target

                                              property message

                                              readonly message?: events.RuleTargetInput;
                                              • The message to send to the topic

                                                the entire EventBridge event

                                              interface SqsQueueProps

                                              interface SqsQueueProps extends TargetBaseProps {}
                                              • Customize the SQS Queue Event Target

                                              property message

                                              readonly message?: events.RuleTargetInput;
                                              • The message to send to the queue.

                                                Must be a valid JSON text passed to the target queue.

                                                the entire EventBridge event

                                              property messageGroupId

                                              readonly messageGroupId?: string;
                                              • Message Group ID for messages sent to this queue

                                                Required for FIFO queues, leave empty for regular queues.

                                                - no message group ID (regular queue)

                                              interface TargetBaseProps

                                              interface TargetBaseProps {}
                                              • The generic properties for an RuleTarget

                                              property deadLetterQueue

                                              readonly deadLetterQueue?: sqs.IQueue;
                                              • The SQS queue to be used as deadLetterQueue. Check out the [considerations for using a dead-letter queue](https://docs.aws.amazon.com/eventbridge/latest/userguide/rule-dlq.html#dlq-considerations).

                                                The events not successfully delivered are automatically retried for a specified period of time, depending on the retry policy of the target. If an event is not delivered before all retry attempts are exhausted, it will be sent to the dead letter queue.

                                                - no dead-letter queue

                                              property maxEventAge

                                              readonly maxEventAge?: Duration;
                                              • The maximum age of a request that Lambda sends to a function for processing.

                                                Minimum value of 60. Maximum value of 86400.

                                                Duration.hours(24)

                                              property retryAttempts

                                              readonly retryAttempts?: number;
                                              • The maximum number of times to retry when the function returns an error.

                                                Minimum value of 0. Maximum value of 185.

                                                185

                                              interface TaskEnvironmentVariable

                                              interface TaskEnvironmentVariable {}
                                              • An environment variable to be set in the container run as a task

                                              property name

                                              readonly name: string;
                                              • Name for the environment variable

                                                Exactly one of name and namePath must be specified.

                                              property value

                                              readonly value: string;
                                              • Value of the environment variable

                                                Exactly one of value and valuePath must be specified.

                                              Type Aliases

                                              type AwsSdkMetadata

                                              type AwsSdkMetadata = {
                                              [key: string]: any;
                                              };
                                              • AWS SDK service metadata.

                                              Package Files (18)

                                              Dependencies (20)

                                              Dev Dependencies (11)

                                              Peer Dependencies (20)

                                              Badge

                                              To add a badge like this onejsDocs.io badgeto your package's README, use the codes available below.

                                              You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/@aws-cdk/aws-events-targets.

                                              • Markdown
                                                [![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/@aws-cdk/aws-events-targets)
                                              • HTML
                                                <a href="https://www.jsdocs.io/package/@aws-cdk/aws-events-targets"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>