0

I'm completely new with boto. I created a Cloudwatch alarm for a certain Kinesis metrics. Now I want to write a Lambda function which can read the alarm status and the corresponding metrics value in every 5 minutes.

Does anyone have experiences with this task and can help me?

following is what I'm currently having in my code:

import json
import boto3

def lambda_handler(event, context):
    cloudwatch = boto3.resource('cloudwatch')
    alarm = cloudwatch.Alarm('Test') 
    response = alarm.describe_alarms()
    return{reponse}

Thanks a lot

Khue Nguyen
  • 73
  • 1
  • 2
  • 5

1 Answers1

1

There are several ways of doing this. One would be:

  1. Add/modify execution role of your function with permissions to read CloudWatch metrics.

  2. Use boto3's cloudwatch to read the metrics you require. You already started doing this.

  3. Setup a CloudWatch Event scheduled rule to trigger your lambda function every 5 minutes.

Marcin
  • 215,873
  • 14
  • 235
  • 294