In today’s agile development landscape, continuous integration and continuous deployment (CI/CD) have become fundamental practices for modern software deployments. stands as one of the industry leaders in this arena, offering seamless integration and deployment pipelines. Integrating with AWS CloudWatch for alerting can enhance your pipeline by notifying you about the build status and any anomalies that may occur during the build process.

In this blog post, we will walk you through the process of setting up AWS CloudWatch alerts for builds step by step.


Before we begin, ensure that you have the following:

  • An AWS account is set up and configured with the necessary access rights.
  • A account.
  • AWS CLI was installed and configured with the necessary access credentials for your AWS account.

Setting Up AWS CloudWatch

The first step involves setting up AWS CloudWatch in your AWS console. Go to the AWS CloudWatch service and create a new dashboard. In the AWS dashboard,  you can configure various metrics and alarms.

Setting Up an IAM Role for Workflows

To allow to send data to CloudWatch, create an IAM role with the necessary permissions. Grant permissions like cloudwatch:PutMetricData to allow to push metrics to CloudWatch.

Configuring Environment

Next, configure your environment variables to include AWS access credentials. You would typically do this in the project settings under secrets. When you are done, you can deploy any of our AWS Workflow stacks that suit your needs. We currently have the AWS ECS fargate workflow and the AWS EKS ASG workflow. Once you have deployed your infrastructure, create a Dockerfile and ops.yml file in your project repository, using our public sample repository as guidance for defining your own application and services.


Integrating and AWS CloudWatch

In your ops.yml file, replace the event values with your own values and define your jobs. Be sure to specify the Docker, AWS, and bash commands and workflow commands necessary to build and deploy your application container image.

version: "1"
  - name: sample-expressjs-pipeline-aws-ecs-fargate:0.1.1
    description: build a release for deployment
        - DEBIAN_FRONTEND=noninteractive
        - ORG=workflows-sh
        - REPO=sample-expressjs-aws-ecs-fargate
        - AWS_REGION=us-west-1
        - STACK_TYPE=aws-ecs-fargate
        - GITHUB_TOKEN
      - "github:workflows-sh/sample-expressjs-aws-ecs-fargate:pull_request.merged"
      - "github:workflows-sh/sample-expressjs-aws-ecs-fargate:pull_request.opened"
      - "github:workflows-sh/sample-expressjs-aws-ecs-fargate:pull_request.synchronize"
      - name: sample-expressjs-build-job-aws-ecs-fargate
        description: sample-expressjs build step
          - git
          - unzip
          - python
          - curl -o
          - unzip && ./awscli-bundle/install -b ~/bin/aws
          - export PATH=~/bin:$PATH
          - aws --version
          - git clone https://$GITHUB_TOKEN:[email protected]/$ORG/$REPO
          - cd $REPO && ls -asl
          - git fetch && git checkout $REF
          - aws ecr get-login-password --region $AWS_REGION | docker login --username AWS --password-stdin $AWS_ACCOUNT_NUMBER.dkr.ecr.$$REPO
          - docker build -f Dockerfile -t $AWS_ACCOUNT_NUMBER.dkr.ecr.$$REPO-$STACK_TYPE:$REF .
          - docker push $AWS_ACCOUNT_NUMBER.dkr.ecr.$$REPO-$STACK_TYPE:$REF
          # Adding CloudWatch metric and alarm commands
          - aws cloudwatch put-metric-data --metric-name BuildSuccess --namespace "" --value 1
          - aws cloudwatch put-metric-alarm --alarm-name build_failure_alarm --alarm-description "Alarm for build failures" --metric-name BuildFailure --namespace "" --statistic SampleCount --period 300 --threshold 1 --comparison-operator GreaterThanOrEqualToThreshold --dimensions Name=Build,Value=Failed --evaluation-periods 1 --alarm-actions arn:aws:sns:us-west-1:$AWS_ACCOUNT_NUMBER:MyTopic
  - name: sample-expressjs-service-aws-ecs-fargate:0.1.1
    description: A sample expressjs service
    run: node /ops/index.js
    port: [ '8080:8080' ]
    sdk: off
    domain: ""
        - PORT=8080
      - "github:workflows-sh/sample-expressjs-aws-ecs-fargate:pull_request.merged"
      - "github:workflows-sh/sample-expressjs-aws-ecs-fargate:pull_request.opened"
      - "github:workflows-sh/sample-expressjs-aws-ecs-fargate:pull_request.synchronize"
     - build
     - publish
     - start

Creating CloudWatch Alarms

Next, create CloudWatch Alarms to receive notifications. Navigate to the CloudWatch dashboard, create a new alarm, and define the conditions based on the metrics you have set up. Add the dashboard widget you want for your logs and metrics tooling.

Configuring Notification

Configure a notification to get alerted when the alarm state is triggered. AWS SNS (Simple Notification Service) can be used to set up email or SMS notifications.

Testing Your Setup

Finally, test your setup by triggering a build in using the ops build . You can also trigger your workflows when the event triggers you configured are met. Once the build completes, it should send the metrics to CloudWatch, and if the conditions are met, the alarm will trigger, sending a notification through the SNS topic you configured.


Setting up AWS CloudWatch alerts for can be a potent combination, ensuring that you are promptly notified of any issues in your CI/CD pipeline, thus maintaining a robust and reliable deployment process. By following the above steps, you can set up a monitoring and alerting system that will aid in proactive issue detection and resolution, bringing efficiency and stability to your deployment pipeline. Happy coding!

Ready to unlock the power of for your team? Schedule your consultation now with one of our experts today!