AWS, Cloud Computing, DevOps

4 Mins Read

A Guide to Automate the Creation of Amazon CloudWatch Alarms using Ansible


Monitoring is one of the key factors for analyzing the Resource performance and identifying any underlying issues or debugging instance performance. It’s also helping us to set up a reliable, cost-effective Infrastructure. Integration of Ansible and AWS Systems Manager to automate the Monitor creation will provide a smooth deployment model. 


Amazon CloudWatch is one of the most widely used Monitoring tools for AWS resources. Its integration with AWS services provides more reliability and accuracy while monitoring service performances.

Monitoring Amazon EC2 instances is crucial for detecting any underlying issues or debugging instance performance early. Amazon CloudWatch is a stable, scalable, and adaptable monitoring solution. Customers who run Amazon EC2 instances in a self-managed environment often use Amazon CloudWatch metrics to monitor instance performance and set up alarms for key performance indicators to warn them of any difficulties based on the thresholds they designate. Amazon CloudWatch agent is used in some cases to monitor custom metrics.

Amazon CloudWatch dashboards offer flexible home pages in the Amazon CloudWatch console that you may use to monitor your resources in a single perspective, even if they are dispersed across multiple Regions. Amazon CloudWatch dashboards can be used to build personalized views of metrics and alarms for your AWS services. Alarms can be added to dashboards to monitor and get notifications about your AWS resources and applications across various Regions.

In this blog, we will automate the creation process of Amazon CloudWatch Alarms creation using the help of Ansible and AWS Systems Manager.

Pioneers in Cloud Consulting & Migration Services

  • Reduced infrastructural costs
  • Accelerated application deployment
Get Started

Step-by-Step Guide

Step 1: Integration of Amazon EC2 Instance with AWS Systems Manager

  • Create IAM Role for AWS Systems Manager Association
  • Go to the IAM console and select Role
  • Now click on Create Role
  • Select the trusted entity and select Amazon EC2


  • Select AmazonSSMManagedInstanceCore policy and AmazonSSMFullAccess


  • Provide a suitable name and create the role.
  • Associate the created AWS IAM Role to our Amazon EC2 Instance. Select the Amazon EC2 Instance and click on Actions -> Security and then Modify IAM Role


  • Select the AWS IAM Role and Update the AWS IAM role



  • Go to AWS Systems Manager and select Fleet Manager. Now you can view the Managed Instances there.


Step 2: Installation of Ansible on Amazon EC2 Instance


  • Verify that Ansible is Installed correctly by running a simple playbook


  • If you got the above output, then Ansible is installed correctly.

Step 3: Download code from GitHub Repo



Step 4: Configure AWS State Manager

  • Go to AWS Systems Manager then go to Systems Manager, then click on “Create Association”
  • Select Document “AWS-ApplyAnsiblePlaybooks” then select Amazon S3 as the source type,
  • “Source info” as { “path”:”<s3 bucket name>” }
  • In the example, snippet below, “Source info” is set as { “path”:”” }
  • Select true as Install Dependencies.
  • Provide playbook file as amazon-cloudwatch-dashboard-alarms-with-ssm-ansible-role-main/playbook.yml


  • Select the Instance manually.


  • Then click on Create Association.
  • Now you can view your CloudWatch Alarm in the Alarm section,



Monitoring is important nowadays to understand and troubleshoot the underlying issues of Infrastructure. This demo shows how we can automate the process of creating Amazon CloudWatch Alarm by eliminating manual Interventions.

Drop a query if you have any questions regarding Amazon CloudWatch Alarm and we will get back to you quickly.

Making IT Networks Enterprise-ready – Cloud Management Services

  • Accelerated cloud migration
  • End-to-end view of the cloud environment
Get Started

About CloudThat

CloudThat is an official AWS (Amazon Web Services) Advanced Consulting Partner and Training partner and Microsoft Gold Partner, helping people develop knowledge of the cloud and help their businesses aim for higher goals using best in industry cloud computing practices and expertise. We are on a mission to build a robust cloud computing ecosystem by disseminating knowledge on technological intricacies within the cloud space. Our blogs, webinars, case studies, and white papers enable all the stakeholders in the cloud computing sphere.

To get started, go through our Consultancy page and Managed Services Package that is CloudThat’s offerings.


1. What are the target configuration options?

ANS: – You can choose to target instances or tags. This implies you can have different configurations for different sets of instances, such as web servers.

2. What are the benefits of using AWS Systems Manager state manager?

ANS: – It isn’t easy to ensure that the infrastructure that powers your applications is consistent. AWS Systems Manager enables you to set policies, reapply them to minimize configuration drift, and monitor the status of your desired state.

3. Can I run AWS Systems Manager automation playbook steps sequentially?

ANS: – Yes, you can execute the whole AWS Systems Manager automation playbook at once or one step at a time using the manual execution method.

WRITTEN BY Deepak Surendran



    Click to Comment

Get The Most Out Of Us

Our support doesn't end here. We have monthly newsletters, study guides, practice questions, and more to assist you in upgrading your cloud career. Subscribe to get them all!