Reputation: 113
I am trying to create alarms based on existing SQS queue metrics in my AWS account using cloud formation. I have more than 25 SQS queues and don't want to repeat the code where I mention the SQS queues one by one. Is there an effective method (shorter code) to create the alarms using programming?
Here is the YAML code for the CloudFormation template. In this, I have mentioned one of the queues from my existing queues.
Parameters:
SQSAlarm:
Type: String
Description: Alarm for existing SQS Queues
Default: Queue1
SQSAlarm:
Type: String
Description: Alarm for existing SQS Queues
Default: Queue3
Resources:
MyAlarm:
Type: AWS::CloudWatch::Alarm
Properties:
AlarmName:
!Ref SQSAlarm
MetricName: "QueueName"
Namespace: AWS/SQS
Statistic: Average
Period: 60
EvaluationPeriods: 1
Threshold: 60
ComparisonOperator: GreaterThanThreshold
MetricName: ApproximateAgeOfOldestMessage
AlarmActions:
- arn:aws:sns:us-east-1:589557565942:SQS-Oldest-Message
Dimensions:
- Name: QueueName
Value: !Ref SQSAlarm
Upvotes: 1
Views: 1258
Reputation: 238051
There are no loops in CloudFormation (CFN). The only solutions for you would be as follows:
Upvotes: 1