2 Answers
- Newest
- Most votes
- Most comments
0
There is no AccountId dimension. Dimensions are predefined and you can check them by using AWS docs.
The corrected template will be:
AWSTemplateFormatVersion: '2010-09-09'
Parameters:
EC2InstanceId:
Type: String
Description: The ID of the EC2 instance to monitor
AlarmName:
Type: String
Description: The name of the CloudWatch alarm
Resources:
CPUUtilizationAlarm:
Type: 'AWS::CloudWatch::Alarm'
Properties:
AlarmName: !Ref AlarmName
AlarmDescription: 'Alarm for CPU Utilization > 2% on EC2 Instance'
Namespace: 'AWS/EC2'
MetricName: 'CPUUtilization'
Dimensions:
- Name: 'InstanceId'
Value: !Ref EC2InstanceId
ComparisonOperator: 'GreaterThanThreshold'
Threshold: 2
EvaluationPeriods: 1
Period: 60
Statistic: 'Average'
But, you can create a custom metrics and use any dimensions you want: https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/publishingMetrics.html
answered 8 months ago
0
Hi,
You can access current account id via CFN pseudo-parameters: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/pseudo-parameter-reference.html
It's called: AWS::AccountId
see details from link above
Some examples on this page: https://www.obstkel.com/cloudformation-pseudo-parameters
Best,
Didier
Relevant content
- Accepted Answer
- AWS OFFICIALUpdated a year ago
- AWS OFFICIALUpdated a month ago
- AWS OFFICIALUpdated 3 months ago
Hey,
is it then possible to override the AWS::AccountId parameter?
This way is working for the region, but not for Account ID:
Region: Description: AWS Region Type: String Default: ${AWS::Region}