惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

WordPress大学
WordPress大学
J
Java Code Geeks
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
腾讯CDC
IT之家
IT之家
罗磊的独立博客
酷 壳 – CoolShell
酷 壳 – CoolShell
U
Unit 42
爱范儿
爱范儿
博客园 - 聂微东
F
Fortinet All Blogs
V
Visual Studio Blog
Blog — PlanetScale
Blog — PlanetScale
G
Google Developers Blog
aimingoo的专栏
aimingoo的专栏
L
LangChain Blog
雷峰网
雷峰网
B
Blog RSS Feed
宝玉的分享
宝玉的分享
T
Tailwind CSS Blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Engineering at Meta
Engineering at Meta
H
Hackread – Cybersecurity News, Data Breaches, AI and More

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant
Automate creation of Amazon CloudWatch alarms
Jonas Barros · 2026-06-23 · via DEV Community
Cover image for Automate creation of Amazon CloudWatch alarms

Jonas Barros

Recently I developed a new feature for this Github Action to automate the creation of AWS Cloudwatch alarms.
Next steps I will show you the settings you need to add to your project to automate creation of CloudWatch alarms.


Prerequisites

1- Your project should use the github actions

2- Your user must have permissions to create an OpenID Connect IDP, policies, and roles in your AWS account.

3- 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.

More informations about other features and prerequisites is available at Automate Dashboards Quick Start


Quick Start

Before starting, add the code snipet to your Github Actions file:

#... before code

# *** ADD THE CODE SNIPET BELOW ***
jobs:
  AssumeRoleAndCallIdentity:
    runs-on: ubuntu-latest
    steps:
      # Add this step to authenticate on the AWS account 
      - name: configure aws credentials
        uses: aws-actions/configure-aws-credentials@v1.7.0
        with:
          role-to-assume: arn:aws:iam::AWS_ACCOUNT_ID:role/to_enable_creating_dashbaords
          role-session-name: GitHub_to_AWS_via_FederatedOIDC
          aws-region: ${{ env.AWS_REGION }}

      # Add this step to load the github action
      - name: create dash
        env: 
          ACTION_NAME: ${{ secrets.ACTION_NAME }} # Create a new environment in your repository with the SNS ARN value
        uses: "JonasBarros1998/automate-dashboards@latest"

#... after code

The full Github workflow file should look similar to this:

# File location: .github/workflows/action.yml
name: Connect to an AWS role from a GitHub repository and install the action to create dashbaord in the CloudWatch

# Execute the action when the user opens a new issue
on:
  issues:
    types: [opened]

# Change the region to your current region
env:
  AWS_REGION: "us-east-1"

permissions:
  id-token: write
  contents: read

# *** ADD THE CODE SNIPPET BELOW ***
jobs:
  AssumeRoleAndCallIdentity:
    runs-on: ubuntu-latest
    steps:
      # Add this step to authenticate with AWS account 
      - name: configure aws credentials
        uses: aws-actions/configure-aws-credentials@v1.7.0
        with:
          role-to-assume: arn:aws:iam::AWS_ACCOUNT_ID:role/to_enable_creating_dashbaords
          role-session-name: GitHub_to_AWS_via_FederatedOIDC
          aws-region: ${{ env.AWS_REGION }}

      # Add this step to load the Github Action
      - name: create dash
        env: 
          ACTION_NAME: ${{ secrets.ACTION_NAME }} # Create a new environment in your repository with the SNS ARN value
        uses: "JonasBarros1998/automate-dashboards@latest"

${{ 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.

**If your project is public, we highly recommend creating a Github repository secret to safely store the ARN value of your SNS topic.


How to execute the action to create alarms in AWS CloudWatch alarms

To 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.

For example, you can send this json if you want to create a new alarm for an AWS Lambda.

{
  "title": "dashboard-services",
  "region": "us-east-1",
  "services": [
    {
      "enable": false,
      "serviceName": "change-data-capture",
      "serviceType": "Lambda",
      "alarms": [
        {
          "metric": "Duration",
          "period": 600, 
          "statistic": "Average",
          "condition": "GreaterThanOrEqualToThreshold",
          "threshold": 1
        },
        {
          "metric": "Invocations",
          "period": 600, 
          "statistic": "Sum",
          "condition": "LessThanOrEqualToThreshold",
          "threshold": 1
        },
        {
          "metric": "Errors",
          "period": 600, 
          "statistic": "Sum",
          "condition": "GreaterThanThreshold",
          "threshold": 1
        }
      ]
    }
  ]
}

If you wish to add 2 or more services, use the JSON format below:

{
    "title": "dashboard-services",
    "region": "us-east-1",
    "services": [
        {
            "enable": false,
            "serviceName": "change-data-capture",
            "serviceType": "Lambda",
            "alarms": [
                {
                    "metric": "Duration",
                    "period": 600,
                    "statistic": "Average",
                    "condition": "GreaterThanOrEqualToThreshold",
                    "threshold": 1
                },
                {
                    "metric": "Invocations",
                    "period": 600,
                    "statistic": "Sum",
                    "condition": "LessThanOrEqualToThreshold",
                    "threshold": 1
                },
                {
                    "metric": "Errors",
                    "period": 600,
                    "statistic": "Sum",
                    "condition": "GreaterThanThreshold",
                    "threshold": 1
                }
            ]
        },
        {
            "enable": true,
            "serviceName": "dashboard",
            "serviceType": "Dynamodb",
            "alarms": [
                {
                    "metric": "ConsumedReadCapacityUnits",
                    "period": 600,
                    "statistic": "Sum",
                    "condition": "GreaterThanThreshold",
                    "threshold": 1
                },
                {
                    "metric": "ConsumedWriteCapacityUnits",
                    "period": 600,
                    "statistic": "Sum",
                    "condition": "GreaterThanThreshold",
                    "threshold": 1
                }
            ]
        },
        {
            "enable": false,
            "serviceName": "my-topic-dashboards",
            "serviceType": "SNS",
            "alarms": [
                {
                    "metric": "NumberOfNotificationsFailed",
                    "period": 600,
                    "statistic": "Sum",
                    "condition": "GreaterThanThreshold",
                    "threshold": 1
                },
                {
                    "metric": "NumberOfMessagesPublished",
                    "period": 600,
                    "statistic": "Sum",
                    "condition": "GreaterThanThreshold",
                    "threshold": 1
                }
            ]
        }
    ]
}

Yout opened issue should should look similar to this example


More informations about the JSON attributes

enable:
  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. 
  type: boolean
  accept values: true or false

metric: 
  description: The metric name for the CloudWatch alarm
  type: String
  accept values: NumberOfObjects, BucketSizeBytes, NumberOfMessagesSent, NumberOfMessagesReceiver, NumberEmptyMessages, NumberOfNotificationsFailed, NumberOfMessagesPublished, Duration, Invocations, Errors, ConsumedReadCapacityUnits, ConsumedWriteCapacityUnits, CPUUtilization, StatusCheckFailed_Instance.

period:
  description: To monitoring period specified in seconds
  type: Integer
  requiriment values: Any value greather than 0. For example 600 seconds is equivalent to 10 minutes

statistic: 
  description: The metric statistic
  type: String
  requiriment values: We currently accept the `Sum` value. 

condition: 
  decsription: The alarm condition. If the condition is met, the alarm triggers and sends a notification to the specified SNS topic.
  type: String 
  requiriment values: "GreaterThanThreshold", "LessThanOrEqualToThreshold", "GreaterThanOrEqualToThreshold", "LessThanLowerThreshold"

Once you have completed all steps, create your issue and monitor the workflow execution.

The issue format should follow the example provided below.
Example

Open a new issue if you search some problem after executed the workflow.


Currently supported AWS services for CloudWatch alarm automation:

  1. AWS Lambda
  2. AWS Dynamodb
  3. AWS EC2
  4. AWS SNS
  5. AWS SQS
  6. AWS S3