【问题标题】:AWS Cloudwatch Alarm Passing Parameters to another ParameterAWS Cloudwatch 警报将参数传递给另一个参数
【发布时间】:2021-07-02 05:51:33
【问题描述】:

我对在 AWS Cloudwatch 上创建警报非常陌生,所以我不确定这是否可行,但我能够创建警报并且到目前为止一切正常,但我想在另一个参数中参数化硬编码变量是我们的警报会发出警报的表达式。就目前而言,代码如下所示。

AWSTemplateFormatVersion: "2010-09-09"
Parameters:
    AlarmExpression:
        Type: String
        Default: IF( m1 > .9 || m2 > .9 || m3 > .9 || m4 > .9 || m5 > .9 || m6 > .9
                      || m7 > .9 || m8 > .9 || m9 > .9 || m10 > .9,1,0 )

这是我尝试过的,但它永远不会将参数阈值传递给另一个参数。

AWSTemplateFormatVersion: "2010-09-09"
Parameters:
    Threshold:
        Type: Number
        Default: .9
    AlarmExpression:
        Type: String
        Default: IF( m1 > !Ref Threshold || m2 > !Ref Threshold || m3 > !Ref Threshold ||    
                     m4 > !Ref Threshold || m5 > !Ref Threshold || m6 > !Ref Threshold ||    
                     m7 > !Ref Threshold || m8 > !Ref Threshold || m9 > !Ref Threshold ||   
                     m10 > !Ref Threshold,1,0 )

可以这样做吗?

【问题讨论】:

  • 进展如何?仍然不清楚为什么你不能这样做?

标签: amazon-web-services amazon-cloudformation amazon-cloudwatch


【解决方案1】:

不可能,因为Paramters 不能引用其他参数。他们只能是references in

您可以从模板的资源和输出部分引用参数。

你需要开发一个custom resourcemacro 来做你想做的事。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-09-25
    • 2020-10-03
    • 2014-08-06
    • 2018-10-22
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多