{
"$type": "site.standard.document",
"bskyPostRef": {
"cid": "bafyreichc25pqgnv6upnaocd55b35gcafnw7tq2kw3vkcj2nojokjrsdy4",
"uri": "at://did:plc:25rdn5elo5izoxrmtis34zuk/app.bsky.feed.post/3mow2ukirz6c2"
},
"coverImage": {
"$type": "blob",
"ref": {
"$link": "bafkreifrrdtvf2xutq7u7e7cn4qaumj4k5u75n4sj2xnohp67oxi64tuuy"
},
"mimeType": "image/webp",
"size": 407972
},
"path": "/jonasbarros/automate-creation-of-amazon-cloudwatch-alarms-43o1",
"publishedAt": "2026-06-22T23:13:10.000Z",
"site": "https://dev.to",
"tags": [
"aws",
"sre",
"githubactions",
"github",
"Github Action",
"Automate Dashboards Quick Start",
"example",
"Example",
"new issue"
],
"textContent": "Recently I developed a new feature for this Github Action to automate the creation of AWS Cloudwatch alarms.\nNext steps I will show you the settings you need to add to your project to automate creation of CloudWatch alarms.\n\n## Prerequisites\n\n1- Your project should use the github actions\n\n2- Your user must have permissions to create an OpenID Connect IDP, policies, and roles in your AWS account.\n\n3- AWS CLI installed on your computer to make it easier to create IAM policies, roles, and a new IDP to connect to the GitHub account.\n\nMore informations about other features and prerequisites is available at Automate Dashboards Quick Start\n\n## Quick Start\n\nBefore starting, add the code snipet to your Github Actions file:\n\n\n\n #... before code\n\n # *** ADD THE CODE SNIPET BELOW ***\n jobs:\n AssumeRoleAndCallIdentity:\n runs-on: ubuntu-latest\n steps:\n # Add this step to authenticate on the AWS account\n - name: configure aws credentials\n uses: aws-actions/configure-aws-credentials@v1.7.0\n with:\n role-to-assume: arn:aws:iam::AWS_ACCOUNT_ID:role/to_enable_creating_dashbaords\n role-session-name: GitHub_to_AWS_via_FederatedOIDC\n aws-region: ${{ env.AWS_REGION }}\n\n # Add this step to load the github action\n - name: create dash\n env:\n ACTION_NAME: ${{ secrets.ACTION_NAME }} # Create a new environment in your repository with the SNS ARN value\n uses: \"JonasBarros1998/automate-dashboards@latest\"\n\n #... after code\n\n\nThe full Github workflow file should look similar to this:\n\n\n\n # File location: .github/workflows/action.yml\n name: Connect to an AWS role from a GitHub repository and install the action to create dashbaord in the CloudWatch\n\n # Execute the action when the user opens a new issue\n on:\n issues:\n types: [opened]\n\n # Change the region to your current region\n env:\n AWS_REGION: \"us-east-1\"\n\n permissions:\n id-token: write\n contents: read\n\n # *** ADD THE CODE SNIPPET BELOW ***\n jobs:\n AssumeRoleAndCallIdentity:\n runs-on: ubuntu-latest\n steps:\n # Add this step to authenticate with AWS account\n - name: configure aws credentials\n uses: aws-actions/configure-aws-credentials@v1.7.0\n with:\n role-to-assume: arn:aws:iam::AWS_ACCOUNT_ID:role/to_enable_creating_dashbaords\n role-session-name: GitHub_to_AWS_via_FederatedOIDC\n aws-region: ${{ env.AWS_REGION }}\n\n # Add this step to load the Github Action\n - name: create dash\n env:\n ACTION_NAME: ${{ secrets.ACTION_NAME }} # Create a new environment in your repository with the SNS ARN value\n uses: \"JonasBarros1998/automate-dashboards@latest\"\n\n\n\n`${{ secrets.ACTION_NAME }}`: Add a new repository secret to your Github repository with your SNS ARN value. Create an SNS topic to send notifications to you when an alarm status is **triggered**.\n\n**If your project is public, we highly recommend creating a Github repository secret to safely store the ARN value of your SNS topic.\n\n### How to execute the action to create alarms in AWS CloudWatch alarms\n\nTo automate AWS CloudWatch Alarms, you need to **open a new issue** with the title **Create Dashboard**. In body of the issue, add the JSON configuration specifyng the settings for your new alarms.\n\nFor example, you can send this json if you want to create a new alarm for an AWS Lambda.\n\n\n\n {\n \"title\": \"dashboard-services\",\n \"region\": \"us-east-1\",\n \"services\": [\n {\n \"enable\": false,\n \"serviceName\": \"change-data-capture\",\n \"serviceType\": \"Lambda\",\n \"alarms\": [\n {\n \"metric\": \"Duration\",\n \"period\": 600,\n \"statistic\": \"Average\",\n \"condition\": \"GreaterThanOrEqualToThreshold\",\n \"threshold\": 1\n },\n {\n \"metric\": \"Invocations\",\n \"period\": 600,\n \"statistic\": \"Sum\",\n \"condition\": \"LessThanOrEqualToThreshold\",\n \"threshold\": 1\n },\n {\n \"metric\": \"Errors\",\n \"period\": 600,\n \"statistic\": \"Sum\",\n \"condition\": \"GreaterThanThreshold\",\n \"threshold\": 1\n }\n ]\n }\n ]\n }\n\n\nIf you wish to add 2 or more services, use the JSON format below:\n\n\n\n {\n \"title\": \"dashboard-services\",\n \"region\": \"us-east-1\",\n \"services\": [\n {\n \"enable\": false,\n \"serviceName\": \"change-data-capture\",\n \"serviceType\": \"Lambda\",\n \"alarms\": [\n {\n \"metric\": \"Duration\",\n \"period\": 600,\n \"statistic\": \"Average\",\n \"condition\": \"GreaterThanOrEqualToThreshold\",\n \"threshold\": 1\n },\n {\n \"metric\": \"Invocations\",\n \"period\": 600,\n \"statistic\": \"Sum\",\n \"condition\": \"LessThanOrEqualToThreshold\",\n \"threshold\": 1\n },\n {\n \"metric\": \"Errors\",\n \"period\": 600,\n \"statistic\": \"Sum\",\n \"condition\": \"GreaterThanThreshold\",\n \"threshold\": 1\n }\n ]\n },\n {\n \"enable\": true,\n \"serviceName\": \"dashboard\",\n \"serviceType\": \"Dynamodb\",\n \"alarms\": [\n {\n \"metric\": \"ConsumedReadCapacityUnits\",\n \"period\": 600,\n \"statistic\": \"Sum\",\n \"condition\": \"GreaterThanThreshold\",\n \"threshold\": 1\n },\n {\n \"metric\": \"ConsumedWriteCapacityUnits\",\n \"period\": 600,\n \"statistic\": \"Sum\",\n \"condition\": \"GreaterThanThreshold\",\n \"threshold\": 1\n }\n ]\n },\n {\n \"enable\": false,\n \"serviceName\": \"my-topic-dashboards\",\n \"serviceType\": \"SNS\",\n \"alarms\": [\n {\n \"metric\": \"NumberOfNotificationsFailed\",\n \"period\": 600,\n \"statistic\": \"Sum\",\n \"condition\": \"GreaterThanThreshold\",\n \"threshold\": 1\n },\n {\n \"metric\": \"NumberOfMessagesPublished\",\n \"period\": 600,\n \"statistic\": \"Sum\",\n \"condition\": \"GreaterThanThreshold\",\n \"threshold\": 1\n }\n ]\n }\n ]\n }\n\n\nYout opened issue should should look similar to this example\n\n### More informations about the JSON attributes\n\n\n enable:\n description: If set `true`, it enables the creation of a new CloudWatch dashboard, but if to set `false`, the action will create a new CloudWatch alarm instead.\n type: boolean\n accept values: true or false\n\n metric:\n description: The metric name for the CloudWatch alarm\n type: String\n accept values: NumberOfObjects, BucketSizeBytes, NumberOfMessagesSent, NumberOfMessagesReceiver, NumberEmptyMessages, NumberOfNotificationsFailed, NumberOfMessagesPublished, Duration, Invocations, Errors, ConsumedReadCapacityUnits, ConsumedWriteCapacityUnits, CPUUtilization, StatusCheckFailed_Instance.\n\n period:\n description: To monitoring period specified in seconds\n type: Integer\n requiriment values: Any value greather than 0. For example 600 seconds is equivalent to 10 minutes\n\n statistic:\n description: The metric statistic\n type: String\n requiriment values: We currently accept the `Sum` value.\n\n condition:\n decsription: The alarm condition. If the condition is met, the alarm triggers and sends a notification to the specified SNS topic.\n type: String\n requiriment values: \"GreaterThanThreshold\", \"LessThanOrEqualToThreshold\", \"GreaterThanOrEqualToThreshold\", \"LessThanLowerThreshold\"\n\n\nOnce you have completed all steps, create your issue and monitor the workflow execution.\n\nThe issue format should follow the example provided below.\nExample\n\nOpen a new issue if you search some problem after executed the workflow.\n\n### Currently supported AWS services for CloudWatch alarm automation:\n\n 1. AWS Lambda\n 2. AWS Dynamodb\n 3. AWS EC2\n 4. AWS SNS\n 5. AWS SQS\n 6. AWS S3\n\n",
"title": "Automate creation of Amazon CloudWatch alarms"
}