Exercise: Monitoring Pipeline Changes

Thuong To
3 min readJan 16, 2024

--

In this exercise, you will monitor pipeline changes. You will create an SNS topic and an EventBridge rule. The rule will monitor the pipeline execution state change. If there are any state changes, it will notify you through email.

Task 1: Setting up with AWS CloudFormation

In this task, you use the same CloudFormation stack you used in the previous course.

  1. Download the following CloudFormation template: final_pipeline.yaml
  2. In the AWS Management Console, choose Services, and search for and choose CloudFormation.
  3. In the CloudFormation navigation pane, choose Stacks.
  4. Choose Create stack and choose With new resources (standard).
  5. In the Specify template page, select Upload a template file and select Choose file.
  6. Upload the final_pipeline.yaml file by opening the directory where you downloaded it, choosing the final_pipeline.yaml file, and choosing Open.
  7. Choose Next
  8. In the Specify stack details page, enter the following values.
  • Stack name: final-pipeline
  • CodePipelineName: final-pipeline

9. Choose Next.

10. Skip Configure stack options by choosing Next.

11. At the bottom of the Review final-pipeline page, select I acknowledge that AWS CloudFormation might create IAM resources with custom names and choose Create stack.

Creating the stack can take some time to complete. Allow the pile to finish before you continue to the next task.

Task 2: Creating an SNS topic

In this task, you set up an SNS topic that will later be used as the target for your EventBridge rule.

  1. Choose Services, search for, and open Amazon SNS.
  2. In the navigation pane, choose Topics and then choose Create topic.
  3. In the Details section, configure the following options:
  • Type: Standard
  • Name: pipeline-topic

4. Keep all other settings at their defaults and choose Create topic.

5. In the Subscriptions tab, choose Create subscription.

6. In the Details section, configure the following settings:

  • Protocol: Email
  • Endpoint: Enter your email address

7. Choose to Create subscription.

You will receive an email message for subscription confirmation.

  1. Confirm the subscription.

Task 3: Creating an EventBridge rule

In this task, you create the EventBridge rule that will be used to key on any CodePipeline changes. This rule will filter out those events, and then use the SNS topic that you created to send you an email message.

  1. Search for and open EventBridge.
  2. Under Events, choose Rules and then choose Create rule.
  3. In the Create rule page, configure the following settings.
  • Name: pipeline-rule
  • Define pattern: Event pattern
  • Event matching pattern: Pre-defined pattern by service
  • Service provider: AWS
  • Service name: CodePipeline
  • EventType: CodePipeline Pipeline Execution State Change
  • Target: SNS topic
  • Topic: pipeline-topic

4. Choose Create.

Task 4: Running AWS CodePipeline

In this task, you start a pipeline execution manually. CodePipeline will then run the most recent version of the source through all stages and actions that are defined in the pipeline.

  1. Search for and open CodePipeline.
  2. From the Pipelines list, choose the final-pipeline link.
  3. On the final-pipeline page, choose Release change and then choose Release.

You will get an email notification about the pipeline’s state change.

  1. In the email message, you should see a state change that’s similar to the following example:
"state":"STARTED","version":1.0}}

And

"state":"SUCCEEDED","version":1.0}}

Cleaning up

In this task, you delete the AWS resources that you created for this exercise.

  1. Open the Amazon S3 console.
  • Empty and delete the bucket with the name: final-pipeline-codepipelineartifactstores3bucket-<random_string>.

2. Open the AWS CloudFormation console.

  • Delete the final-pipeline stack.

3. Open the EventBridge console and in the navigation pane, choose Rules.

  • Delete pipeline-rule.

4. Open the Amazon SNS console.

  • In the navigation pane, choose Topics and delete pipeline-topic.
  • In the navigation pane, choose Subscriptions and delete your pipeline-topic subscription.

--

--

Thuong To
Thuong To

No responses yet