Monitoring CodePipeline events - AWS CodePipeline

Monitoring CodePipeline events

You can monitor CodePipeline events in EventBridge, which delivers a stream of real-time data from your own applications, software-as-a-service (SaaS) applications, and AWS services. EventBridge routes that data to targets such as AWS Lambda and Amazon Simple Notification Service. These events are the same as those that appear in Amazon CloudWatch Events, which delivers a near real-time stream of system events that describe changes in AWS resources. For more information, see What Is Amazon EventBridge? in the Amazon EventBridge User Guide.

Note

Amazon EventBridge is the preferred way to manage your events. Amazon CloudWatch Events and EventBridge are the same underlying service and API, but EventBridge provides more features. Changes you make in either CloudWatch Events or EventBridge will appear in each console.

Events are composed of rules. A rule is configured by choosing the following:

  • Event Pattern. Each rule is expressed as an event pattern with the source and type of events to monitor, and event targets. To monitor events, you create a rule with the service you are monitoring as the event source, such as CodePipeline. For example, you can create a rule with an event pattern that that uses CodePipeline as an event source to trigger the rule when there are changes in the state of a pipeline, stage, or action.

  • Targets. The new rule receives a selected service as the event target. You might want to set up a target service to send notifications, capture state information, take corrective action, initiate events, or take other actions. When you add your target, you must also grant permissions to Amazon CloudWatch Events to allow it to invoke the selected target service.

Each type of execution state change event emits notifications with specific message content, where:

  • The initial version entry shows the version number for the event.

  • The version entry under pipeline detail shows the pipeline structure version number.

  • The execution-id entry under pipeline detail shows the execution ID for the pipeline execution that caused the state change. Refer to the GetPipelineExecution API call in the AWS CodePipeline API Reference.

CodePipeline reports an event to Amazon CloudWatch Events whenever the state of a resource in your AWS account changes. Events are emitted on a guaranteed, at-least-once basis for the following resources:

  • Pipeline executions

  • Stage executions

  • Action executions

Events are emitted by EventBridge with the event pattern and schema detailed above. For processed events, such as events you receive through notifications you have configured in the Developer Tools console, the event message includes event pattern fields with some variation. For example, the detail-type field is converted to detailType. For more information, refer to the PutEvents API call in the Amazon EventBridge API Reference.

The following examples show events for CodePipeline. Where possible, each example shows the schema for an emitted event along with the schema for a processed event.

Detail types

When you set up events to monitor, you can choose the detail type for the event.

You can configure notifications to be sent when the state changes for:

  • Specified pipelines or all your pipelines. You control this by using "detail-type": "CodePipeline Pipeline Execution State Change".

  • Specified stages or all your stages, within a specified pipeline or all your pipelines. You control this by using "detail-type": "CodePipeline Stage Execution State Change".

  • Specified actions or all actions, within a specified stage or all stages, within a specified pipeline or all your pipelines. You control this by using "detail-type": "CodePipeline Action Execution State Change".

Note

Events emitted by EventBridge contain the detail-type parameter, which is converted to detailType when events are processed.

Detail type State Description
CodePipeline Pipeline Execution State Change CANCELED The pipeline execution was canceled because the pipeline structure was updated.
FAILED The pipeline execution was not completed successfully.
RESUMED A failed pipeline execution has been retried in response to the RetryStageExecution API call.
STARTED The pipeline execution is currently running.
STOPPED The stopping process is complete, and the pipeline execution is stopped.
STOPPING The pipeline execution is stopping due to a request to either stop and wait or stop and abandon the pipeline execution.
SUCCEEDED The pipeline execution was completed successfully.
SUPERSEDED

While this pipeline execution was waiting for the next stage to be completed, a newer pipeline execution advanced and continued through the pipeline instead.

CodePipeline Stage Execution State Change CANCELED The stage was canceled because the pipeline structure was updated.
FAILED The stage was not completed successfully.
RESUMED A failed stage has been retried in response to the RetryStageExecution API call.
STARTED The stage is currently running.
STOPPED The stopping process is complete, and the stage execution is stopped.
STOPPING The stage execution is stopping due to a request to either stop and wait or stop and abandon the pipeline execution.
SUCCEEDED The stage was completed successfully.
CodePipeline Action Execution State Change ABANDONED The action is abandoned due to a request to stop and abandon the pipeline execution.
CANCELED The action was canceled because the pipeline structure was updated.
FAILED For approval actions, the FAILED state means the action was either rejected by the reviewer or failed due to an incorrect action configuration.
STARTED The action is currently running.
SUCCEEDED The action was completed successfully.

Pipeline-level events

Pipeline-level events are emitted when there is a state change for a pipeline execution.

Pipeline STARTED event

When a pipeline execution starts, it emits an event that sends notifications with the following content. This example is for the pipeline named "myPipeline" in the us-east-1 Region. The id field represents the event ID, and the account field represents the account ID where the pipeline is created.

Emitted event
{ "version": "0", "id": "01234567-EXAMPLE", "detail-type": "CodePipeline Pipeline Execution State Change", "source": "aws.codepipeline", "account": "123456789012", "time": "2020-01-24T22:03:07Z", "region": "us-east-1", "resources": [ "arn:aws:codepipeline:us-east-1:123456789012:myPipeline" ], "detail": { "pipeline": "myPipeline", "execution-id": "12345678-1234-5678-abcd-12345678abcd", "execution-trigger": { "trigger-type": "StartPipelineExecution", "trigger-detail": "arn:aws:sts::123456789012:assumed-role/Admin/my-user" }, "state": "STARTED", "version": 1 } }
Processed event
{ "account": "123456789012", "detailType": "CodePipeline Pipeline Execution State Change", "region": "us-east-1", "source": "aws.codepipeline", "time": "2021-06-24T00:44:50Z", "notificationRuleArn": "arn:aws:codestar-notifications:us-east-1:123456789012:notificationrule/a69c62c21EXAMPLE", "detail": { "pipeline": "myPipeline", "execution-id": "12345678-1234-5678-abcd-12345678abcd", "execution-trigger": { "trigger-type": "StartPipelineExecution", "trigger-detail": "arn:aws:sts::123456789012:assumed-role/Admin/my-user" }, "state": "STARTED", "version": 1, "pipeline-execution-attempt": 1 }, "resources": [ "arn:aws:codepipeline:us-east-1:123456789012:myPipeline" ], "additionalAttributes": {} }

Pipeline STOPPING event

When a pipeline execution is stopping, it emits an event that sends notifications with the following content. This example is for the pipeline named myPipeline in the us-west-2 Region.

{ "version": "0", "id": "01234567-EXAMPLE", "detail-type": "CodePipeline Pipeline Execution State Change", "source": "aws.codepipeline", "account": "123456789012", "time": "2020-01-24T22:02:20Z", "region": "us-west-2", "resources": [ "arn:aws:codepipeline:us-west-2:123456789012:myPipeline" ], "detail": { "pipeline": "myPipeline", "execution-id": "12345678-1234-5678-abcd-12345678abcd", "state": "STOPPING", "version": 3, "stop-execution-comments": "Stopping the pipeline for an update" } }

Pipeline SUCCEEDED event

When a pipeline execution succeeds, it emits an event that sends notifications with the following content. This example is for the pipeline named myPipeline in the us-east-1 Region.

Emitted event
{ "version": "0", "id": "01234567-EXAMPLE", "detail-type": "CodePipeline Pipeline Execution State Change", "source": "aws.codepipeline", "account": "123456789012", "time": "2020-01-24T22:03:44Z", "region": "us-east-1", "resources": [ "arn:aws:codepipeline:us-east-1:123456789012:myPipeline" ], "detail": { "pipeline": "myPipeline", "execution-id": "12345678-1234-5678-abcd-12345678abcd", "state": "SUCCEEDED", "version": 3 } }
Processed event
{ "account": "123456789012", "detailType": "CodePipeline Pipeline Execution State Change", "region": "us-east-1", "source": "aws.codepipeline", "time": "2021-06-30T22:13:51Z", "notificationRuleArn": "arn:aws:codestar-notifications:us-west-2:123456789012:notificationrule/a69c62c21EXAMPLE", "detail": { "pipeline": "myPipeline", "execution-id": "12345678-1234-5678-abcd-12345678abcd", "state": "SUCCEEDED", "version": 1, "pipeline-execution-attempt": 1 }, "resources": [ "arn:aws:codepipeline:us-west-2:123456789012:myPipeline" ], "additionalAttributes": {} }

Pipeline FAILED event

When a pipeline execution fails, it emits an event that sends notifications with the following content. This example is for the pipeline named "myPipeline" in the us-west-2 Region.

Emitted event
{ "version": "0", "id": "01234567-EXAMPLE", "detail-type": "CodePipeline Pipeline Execution State Change", "source": "aws.codepipeline", "account": "123456789012", "time": "2020-01-31T18:55:43Z", "region": "us-west-2", "resources": [ "arn:aws:codepipeline:us-west-2:123456789012:myPipeline" ], "detail": { "pipeline": "myPipeline", "execution-id": "12345678-1234-5678-abcd-12345678abcd", "state": "FAILED", "version": 4 } }
Processed event
{ "account": "123456789012", "detailType": "CodePipeline Pipeline Execution State Change", "region": "us-west-2", "source": "aws.codepipeline", "time": "2021-06-24T00:46:16Z", "notificationRuleArn": "arn:aws:codestar-notifications:us-west-2:123456789012:notificationrule/a69c62c21EXAMPLE", "detail": { "pipeline": "myPipeline", "execution-id": "12345678-1234-5678-abcd-12345678abcd", "state": "FAILED", "version": 1, "pipeline-execution-attempt": 1 }, "resources": [ "arn:aws:codepipeline:us-west-2:123456789012:myPipeline" ], "additionalAttributes": { "failedActionCount": 1, "failedActions": [ { "action": "Deploy", "additionalInformation": "Deployment <ID> failed" } ], "failedStage": "Deploy" }

Stage-level events

Stage-level events are emitted when there is a state change for a stage execution.

Stage STARTED event

When a stage execution starts, it emits an event that sends notifications with the following content. This example is for the pipeline named "myPipeline" in the us-east-1 Region, for the stage Prod.

Emitted event
{ "version": "0", "id": 01234567-EXAMPLE, "detail-type": "CodePipeline Stage Execution State Change", "source": "aws.codepipeline", "account": 123456789012, "time": "2020-01-24T22:03:07Z", "region": "us-east-1", "resources": [ "arn:aws:codepipeline:us-east-1:123456789012:myPipeline" ], "detail": { "pipeline": "myPipeline", "version": "1", "execution-id": 12345678-1234-5678-abcd-12345678abcd, "stage": "Prod", "state": "STARTED" } }
Processed event
{ "account": "123456789012", "detailType": "CodePipeline Stage Execution State Change", "region": "us-east-1", "source": "aws.codepipeline", "time": "2021-06-24T00:45:40Z", "notificationRuleArn": "arn:aws:codestar-notifications:us-west-2:123456789012:notificationrule/a69c62c21EXAMPLE", "detail": { "pipeline": "myPipeline", "execution-id": "12345678-1234-5678-abcd-12345678abcd", "stage": "Source", "state": "STARTED", "version": 1, "pipeline-execution-attempt": 0 }, "resources": [ "arn:aws:codepipeline:us-east-1:123456789012:myPipeline" ], "additionalAttributes": { "sourceActions": [ { "sourceActionName": "Source", "sourceActionProvider": "CodeCommit", "sourceActionVariables": { "BranchName": "main", "CommitId": "<ID>", "RepositoryName": "my-repo" } } ] } }

Stage STOPPING event

When a stage execution is stopping, it emits an event that sends notifications with the following content. This example is for the pipeline named myPipeline in the us-west-2 Region, for the stage Deploy.

{ "version": "0", "id": "01234567-EXAMPLE", "detail-type": "CodePipeline Stage Execution State Change", "source": "aws.codepipeline", "account": "123456789012", "time": "2020-01-24T22:02:20Z", "region": "us-west-2", "resources": [ "arn:aws:codepipeline:us-west-2:123456789012:myPipeline" ], "detail": { "pipeline": "myPipeline", "execution-id": "12345678-1234-5678-abcd-12345678abcd", "stage": "Deploy", "state": "STOPPING", "version": 3 } }

Stage STOPPED event

When a stage execution is stopped, it emits an event that sends notifications with the following content. This example is for the pipeline named myPipeline in the us-west-2 Region, for the stage Deploy.

{ "version": "0", "id": "01234567-EXAMPLE", "detail-type": "CodePipeline Stage Execution State Change", "source": "aws.codepipeline", "account": "123456789012", "time": "2020-01-31T18:21:39Z", "region": "us-west-2", "resources": [ "arn:aws:codepipeline:us-west-2:123456789012:myPipeline" ], "detail": { "pipeline": "myPipeline", "execution-id": "12345678-1234-5678-abcd-12345678abcd", "stage": "Deploy", "state": "STOPPED", "version": 3 } }

Action-level events

Action-level events are emitted when there is a state change for an action execution.

Action STARTED event

When an action execution starts, it emits an event that sends notifications with the following content. This example is for the pipeline named myPipeline in the us-east-1 Region, for the deployment action myAction.

Emitted event
{ "version": "0", "id": 01234567-EXAMPLE, "detail-type": "CodePipeline Action Execution State Change", "source": "aws.codepipeline", "account": 123456789012, "time": "2020-01-24T22:03:07Z", "region": "us-east-1", "resources": [ "arn:aws:codepipeline:us-east-1:123456789012:myPipeline" ], "detail": { "pipeline": "myPipeline", "execution-id": 12345678-1234-5678-abcd-12345678abcd, "stage": "Prod", "action": "myAction", "state": "STARTED", "type": { "owner": "AWS", "category": "Deploy", "provider": "CodeDeploy", "version": 1 }, "input-artifacts": [ { "name": "SourceArtifact", "s3location": { "bucket": "codepipeline-us-east-1-BUCKETEXAMPLE", "key": "myPipeline/SourceArti/KEYEXAMPLE" } } ] } }
Processed event
{ "account": "123456789012", "detailType": "CodePipeline Action Execution State Change", "region": "us-west-2", "source": "aws.codepipeline", "time": "2021-06-24T00:45:44Z", "notificationRuleArn": "arn:aws:codestar-notifications:us-west-2:123456789012:notificationrule/a69c62c21EXAMPLE", "detail": { "pipeline": "myPipeline", "execution-id": "12345678-1234-5678-abcd-12345678abcd", "stage": "Deploy", "action": "Deploy", "input-artifacts": [ { "name": "SourceArtifact", "s3location": { "bucket": "codepipeline-us-east-1-EXAMPLE", "key": "myPipeline/SourceArti/EXAMPLE" } } ], "state": "STARTED", "region": "us-east-1", "type": { "owner": "AWS", "provider": "CodeDeploy", "category": "Deploy", "version": "1" }, "version": 1, "pipeline-execution-attempt": 1 }, "resources": [ "arn:aws:codepipeline:us-east-1:123456789012:myPipeline" ], "additionalAttributes": {} }

Action SUCCEEDED event

When an action execution succeeds, it emits an event that sends notifications with the following content. This example is for the pipeline named "myPipeline" in the us-west-2 Region, for the source action "Source". For this event type, there are two different region fields. The event region field specifies the Region for the pipeline event. The region field under the detail section specifies the Region for the action.

Emitted event
{ "version": "0", "id": "01234567-EXAMPLE", "detail-type": "CodePipeline Action Execution State Change", "source": "aws.codepipeline", "account": "123456789012", "time": "2020-01-24T22:03:11Z", "region": "us-west-2", "resources": [ "arn:aws:codepipeline:us-west-2:123456789012:myPipeline" ], "detail": { "pipeline": "myPipeline", "execution-id": "12345678-1234-5678-abcd-12345678abcd", "stage": "Source", "execution-result": { "external-execution-url": "https://us-west-2.console.aws.amazon.com/codecommit/home#/repository/my-repo/commit/8cf40f2EXAMPLE", "external-execution-summary": "Added LICENSE.txt", "external-execution-id": "8cf40fEXAMPLE" }, "output-artifacts": [ { "name": "SourceArtifact", "s3location": { "bucket": "codepipeline-us-west-2-BUCKETEXAMPLE", "key": "myPipeline/SourceArti/KEYEXAMPLE" } } ], "action": "Source", "state": "SUCCEEDED", "region": "us-west-2", "type": { "owner": "AWS", "provider": "CodeCommit", "category": "Source", "version": "1" }, "version": 3 } }
Processed event
{ "account": "123456789012", "detailType": "CodePipeline Action Execution State Change", "region": "us-west-2", "source": "aws.codepipeline", "time": "2021-06-24T00:45:44Z", "notificationRuleArn": "arn:aws:codestar-notifications:us-west-2:ACCOUNT:notificationrule/a69c62c21EXAMPLE", "detail": { "pipeline": "myPipeline", "execution-id": "arn:aws:codepipeline:us-west-2:123456789012:myPipeline", "stage": "Source", "execution-result": { "external-execution-url": "https://us-west-2.console.aws.amazon.com/codecommit/home#/repository/my-repo/commit/8cf40f2EXAMPLE", "external-execution-summary": "Edited index.html", "external-execution-id": "36ab3ab7EXAMPLE" }, "output-artifacts": [ { "name": "SourceArtifact", "s3location": { "bucket": "codepipeline-us-west-2-EXAMPLE", "key": "myPipeline/SourceArti/EXAMPLE" } } ], "action": "Source", "state": "SUCCEEDED", "region": "us-west-2", "type": { "owner": "AWS", "provider": "CodeCommit", "category": "Source", "version": "1" }, "version": 1, "pipeline-execution-attempt": 1 }, "resources": [ "arn:aws:codepipeline:us-west-2:123456789012:myPipeline" ], "additionalAttributes": {} }

Action FAILED event

When an action execution fails, it emits an event that sends notifications with the following content. This example is for the pipeline named "myPipeline" in the us-west-2 Region, for the action "Deploy".

Emitted event
{ "version": "0", "id": "01234567-EXAMPLE", "detail-type": "CodePipeline Action Execution State Change", "source": "aws.codepipeline", "account": "123456789012", "time": "2020-01-31T18:55:43Z", "region": "us-west-2", "resources": [ "arn:aws:codepipeline:us-west-2:123456789012:myPipeline" ], "detail": { "pipeline": "myPipeline", "execution-id": "12345678-1234-5678-abcd-12345678abcd", "stage": "Deploy", "execution-result": { "external-execution-url": "https://us-west-2.console.aws.amazon.com/codedeploy/home?#/deployments/<ID>", "external-execution-summary": "Deployment <ID> failed", "external-execution-id": "<ID>", "error-code": "JobFailed" }, "action": "Deploy", "state": "FAILED", "region": "us-west-2", "type": { "owner": "AWS", "provider": "CodeDeploy", "category": "Deploy", "version": "1" }, "version": 4 } }
Processed event
{ "account": "123456789012", "detailType": "CodePipeline Action Execution State Change", "region": "us-west-2", "source": "aws.codepipeline", "time": "2021-06-24T00:46:16Z", "notificationRuleArn": "arn:aws:codestar-notifications:us-west-2:123456789012:notificationrule/a69c62c21EXAMPLE", "detail": { "pipeline": "myPipeline", "execution-id": "12345678-1234-5678-abcd-12345678abcd", "stage": "Deploy", "execution-result": { "external-execution-url": "https://console.aws.amazon.com/codedeploy/home?region=us-west-2#/deployments/<ID>", "external-execution-summary": "Deployment <ID> failed", "external-execution-id": "<ID>", "error-code": "JobFailed" }, "action": "Deploy", "state": "FAILED", "region": "us-west-2", "type": { "owner": "AWS", "provider": "CodeDeploy", "category": "Deploy", "version": "1" }, "version": 13, "pipeline-execution-attempt": 1 }, "resources": [ "arn:aws:codepipeline:us-west-2:123456789012:myPipeline" ], "additionalAttributes": { "additionalInformation": "Deployment <ID> failed" } }

Action ABANDONED event

When an action execution is abandoned, it emits an event that sends notifications with the following content. This example is for the pipeline named "myPipeline" in the us-west-2 Region, for the action "Deploy".

{ "version": "0", "id": "01234567-EXAMPLE", "detail-type": "CodePipeline Action Execution State Change", "source": "aws.codepipeline", "account": "123456789012", "time": "2020-01-31T18:21:39Z", "region": "us-west-2", "resources": [ "arn:aws:codepipeline:us-west-2:123456789012:myPipeline" ], "detail": { "pipeline": "myPipeline", "execution-id": "12345678-1234-5678-abcd-12345678abcd", "stage": "Deploy", "action": "Deploy", "state": "ABANDONED", "region": "us-west-2", "type": { "owner": "AWS", "provider": "CodeDeploy", "category": "Deploy", "version": "1" }, "version": 3 } }

Create a Rule That Sends a Notification on a Pipeline Event

A rule watches for certain events and then routes them to AWS targets that you choose. You can create a rule that performs an AWS action automatically when another AWS action happens, or a rule that performs an AWS action regularly on a set schedule.

Send a Notification When Pipeline State Changes (Console)

These steps show how to use the CloudWatch console to create a rule to send notifications of changes in CodePipeline.

To create a CloudWatch Events rule with CodePipeline as the event source

  1. Open the CloudWatch console at https://console.aws.amazon.com/cloudwatch/.

  2. In the navigation pane, choose Events.

  3. Choose Create rule. Under Event source, from the Service Name drop-down list, choose CodePipeline.

  4. From the Event Type drop-down list, choose the level of state change for the notification.

    • For a rule that applies to pipeline-level events, choose CodePipeline Pipeline Execution State Change.

    • For a rule that applies to stage-level events, choose CodePipeline Stage Execution State Change.

    • For a rule that applies to action-level events, choose CodePipeline Action Execution State Change.

  5. Specify the state changes the rule applies to:

    • For a rule that applies to all state changes, choose Any state.

    • For a rule that applies to some state changes only, choose Specific state(s), and then choose one or more state values from the list.

  6. For event patterns that are more detailed than the selectors allow, you can also use the Edit option in the Event Pattern Preview window to designate an event pattern in JSON format. The following example shows the JSON structure edited manually to specify a pipeline named "myPipeline."

    
              A pipeline name can be edited manually in the JSON structure for the
                rule.

    Note

    If not otherwise specified, then the event pattern is created for all pipelines/stages/actions and states.

    For more detailed event patterns, you can copy and paste the following example event patterns into the Edit window.

    • Use this sample event pattern to capture failed deploy and build actions across all the pipelines.

      { "source": [ "aws.codepipeline" ], "detail-type": [ "CodePipeline Action Execution State Change" ], "detail": { "state": [ "FAILED" ], "type": { "category": ["Deploy", "Build"] } } }
    • Use this sample event pattern to capture all rejected or failed approval actions across all the pipelines.

      { "source": [ "aws.codepipeline" ], "detail-type": [ "CodePipeline Action Execution State Change" ], "detail": { "state": [ "FAILED" ], "type": { "category": ["Approval"] } } }
    • Use this sample event pattern to capture all the events from the specified pipelines.

      { "source": [ "aws.codepipeline" ], "detail-type": [ "CodePipeline Pipeline Execution State Change", "CodePipeline Action Execution State Change", "CodePipeline Stage Execution State Change" ], "detail": { "pipeline": ["myPipeline", "my2ndPipeline"] } }
  7. In the Targets area, choose Add target*.

  8. In the Select target type list, choose the type of target for this rule, and then configure options required by that type.

  9. Choose Configure details.

  10. On the Configure rule details page, type a name and description for the rule, and then select the State box to enable to rule now.

  11. Choose Create rule.

Send a Notification When Pipeline State Changes (CLI)

These steps show how to use the CLI to create a CloudWatch Events rule to send notifications of changes in CodePipeline.

To use the AWS CLI to create a rule, call the put-rule command, specifying:

  • A name that uniquely identifies the rule you are creating. This name must be unique across all of the pipelines you create with CodePipeline associated with your AWS account.

  • The event pattern for the source and detail fields used by the rule. For more information, see Amazon CloudWatch Events and Event Patterns.

To create a CloudWatch Events rule with CodePipeline as the event source

  1. Call the put-rule command to create a rule specifying the event pattern. (See the preceding tables for valid states.)

    The following sample command uses --event-pattern to create a rule called “MyPipelineStateChanges” that emits the CloudWatch event when a pipeline execution fails for the pipeline named "myPipeline."

    aws events put-rule --name "MyPipelineStateChanges" --event-pattern "{\"source\":[\"aws.codepipeline\"],\"detail-type\":[\"CodePipeline Pipeline Execution State Change\"],\"detail\":{\"pipeline\":[\"myPipeline\"],\"state\":[\"FAILED\"]}}"
  2. Call the put-targets command and include the following parameters:

    • The --rule parameter is used with the rule_name you created by using put-rule.

    • The --targets parameter is used with the list Id of the target in the list of targets and the ARN of the Amazon SNS topic.

    The following sample command specifies that for the rule called MyPipelineStateChanges, the target Id is composed of the number one, indicating that in a list of targets for the rule, this is target 1. The sample command also specifies an example ARN for the Amazon SNS topic.

    aws events put-targets --rule MyPipelineStateChanges --targets Id=1,Arn=arn:aws:sns:us-west-2:11111EXAMPLE:MyNotificationTopic
  3. Add permissions for Amazon CloudWatch Events to use the designated target service to invoke the notification. For more information, see Using Resource-Based Policies for Amazon CloudWatch Events.