有没有一种方法可以使用CloudFormation模板更新/添加新的小部件CloudWatch仪表板?

时间:2019-07-01 02:39:13

标签: amazon-cloudformation amazon-cloudwatch

我正在尝试使用cloudformation将lambda函数统计信息添加到我的仪表板中,但是问题是lambda函数是在与具有仪表板的堆栈之后创建的我的仪表板不同的堆栈中创建的。因此,有一种方法可以在使用cloudformation创建仪表板之后对其进行更新

2 个答案:

答案 0 :(得分:0)

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

答案 1 :(得分:0)

在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也可以这样做。

相关问题