Use Pseudo Variables in Cloudwatch Dashboard Template (Cloudformation)

天涯浪子 提交于 2019-12-06 20:53:28

In your example, the DashboardBody is a string, therefore AWS::Region will not get replaced. You'll probably be better by adding the Fn::Sub function, like:

AutoscalingDashboard:
  Type: 'AWS::CloudWatch::Dashboard'
  Properties:
    DashboardName: 'AutoscalingDashboard'
    DashboardBody: !Sub >-
     {
      "widgets":[
         {
            "type":"metric",
            "x":0,
            "y":0,
            "width":12,
            "height":6,
            "properties":{
                "metrics":[
                    [ "AWS/ECS", "MemoryUtilization", "ServiceName", "invoice_web", "ClusterName", "InvoicegenappCluster" ],
                    [ "...", "invoice_data", ".", "." ],
                    [ "...", "invoice_generator", ".", "." ]
                ],
                "region": "${AWS::Region}",
                "period": 300,
                "view": "timeSeries",
                "title":"ECS MemoryUtilization",
                "stacked": false
            }           
          }]
      }

Notice the ${} around the region, and also the YAML block string >-.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!