有没有一种方法可以为特定的链接帐户创建CloudWatch计费警报



在组织-合并账单中,我有一个具有链接帐户的付款人帐户。我想做的是创建一个CloudFormation模板,为每个链接帐户创建一个计费警报。原因是,我希望根据账户类型(例如开发/生产/测试(在不同级别上对估计费用进行警报。

我搜索了Boto3文档和AWS API文档,但没有引用链接帐户指标。但是,我能够从控制台创建它。

https://docs.aws.amazon.com/AmazonCloudWatch/latest/APIReference/API_ListMetrics.html

我找不到文档,但我用链接帐户创建了警报,然后创建了一个EC2实例,该实例具有运行描述警报的权限(https://docs.aws.amazon.com/cli/latest/reference/cloudwatch/describe-alarms.html)。

这向我返回了一个JSON,其中显示Linked Accounts是CloudWatch::Alarm的Dimensions属性的一部分。

以下是CloudFormation片段,用于创建特定于该链接帐户的警报。

CloudWatchAlarm:
Type: 'AWS::CloudWatch::Alarm'
Properties:
AlarmName: !Ref AlarmName
AlarmDescription: !Join ["", ['CloudWatch Alarm to notify when the estimated charges >= $', !Ref ThresholdAmount, '.']]
MetricName: EstimatedCharges
Namespace: AWS/Billing
Statistic: Maximum
Period: '21600'
EvaluationPeriods: '1'
Threshold: !Ref ThresholdAmount
ComparisonOperator: GreaterThanOrEqualToThreshold
AlarmActions:
- Ref: SNSTopic
Dimensions:
- Name: Currency
Value: USD
- Name: LinkedAccount
Value: !Ref LinkedAccountNumber
InsufficientDataActions:
- Ref: SNSTopic

最新更新