【问题标题】:is there is a way to update/ add a new widget CloudWatch dashboard using CloudFormation template?有没有办法使用 CloudFormation 模板更新/添加新的小部件 CloudWatch 仪表板?
【发布时间】:2019-11-11 17:51:40
【问题描述】:

我正在尝试使用 cloudformation 将 lambda 函数统计信息添加到我的仪表板,但问题是 lambda 函数是在与我的仪表板不同的堆栈中创建的,而仪表板是在具有仪表板的堆栈之后创建的。那么有没有办法在使用 cloudformation 创建仪表板后更新仪表板

【问题讨论】:

    标签: amazon-cloudformation amazon-cloudwatch


    【解决方案1】:

    您能否尝试更新其他 cloudformation 堆栈以防万一,看看是否有帮助。顺便说一句,您想尝试创建 cloudformation 模板,有一个名为 cloudkast 的在线工具可用。它是一个在线 aws cloudformation 模板生成器。

    【讨论】:

      【解决方案2】:

      在 CloudFormation 中,当引用另一个堆栈中的资源时,您使用内部函数:

      Fn::ImportValue 在您的仪表板 CloudFormation 中。请参阅documentation。

      可以在 AWS 博客上找到一个很好的例子 - https://aws.amazon.com/premiumsupport/knowledge-center/cloudformation-reference-resource/

      {
         "Parameters":{
              "NetworkStackNameParameter":{
                    "Type":"String"
            }
          },
      "Resources" : {
        "WebServerInstance" : {
          "Type" : "AWS::EC2::Instance",
          "Properties" : {
             "InstanceType" : "t2.micro",
            "ImageId" : "ami-a1b23456",
            "NetworkInterfaces" : [{
              "GroupSet" : [{"Fn::ImportValue" : {"Fn::Sub" : 
      "${NetworkStackNameParameter}-SecurityGroupID"}}],
              "AssociatePublicIpAddress" : "true",
              "DeviceIndex" : "0",
              "DeleteOnTermination" : "true",
              "SubnetId" : {"Fn::ImportValue" : {"Fn::Sub" : "${NetworkStackNameParameter}- SubnetID"}}
            }]
          }
        }
      }
      

      上面的SubnetId 是使用 ImportValue 从另一个堆栈中拉入的。

      在使用 CloudFormation 构建仪表板时,也可以对 Lambda 执行相同的操作。

      【讨论】:

        猜你喜欢
        • 2016-07-15
        • 1970-01-01
        • 2016-04-09
        • 2021-07-07
        • 2020-08-16
        • 2022-01-13
        • 2020-06-23
        • 1970-01-01
        • 2015-03-14
        相关资源
        最近更新 更多