如何解决Cloudformation 中的 Cloudwatch 仪表板错误
我正在尝试使用 cloudformation 中的 JSON 在 AWS 系统管理器中创建 cloudwatch 仪表板。我有一个模板,其中有几个 lambda 函数已经在堆栈中运行。我更新如下:
{
"AWstemplateFormatVersion": "2010-09-09","Description": "The AWS CloudFormation template for deployment. Version 1.0","Mappings": {
"SourceCode": {
"General": {
"S3Bucket": "solutions","KeyPrefix": "connected-solution/latest"
}
}
},"Resources": {
"dashboard": {
"Type": "AWS::CloudWatch::Dashboard","Properties": {
"DashboardName": "Dynamodb-LambdaDashboard-xxx","DashboardBody": {
"widgets": [
{
"type": "metric","x": 0,"y": 0,"width": 12,"height": 7,"properties": {
"metrics": [
[
"AWS/DynamoDB","UserErrors"
]
],"view": "timeSeries","stacked": false,"period": 300,"stat": "Sum","region": "us-east-1"
}
}
]
}
}
}
}
}
当我尝试更新堆栈时出现以下错误:
Property validation failure: [Value of property {/DashboardBody} does not match type {String}]
请指教。如果有任何问题,请告诉我 谢谢,
解决方法
DashboardBody
应该是 string
,而不是 json 对象。您必须字符串化(将 json 对象转换为字符串)您的 DashboardBody
。例如:
{
"AWSTemplateFormatVersion": "2010-09-09","Description": "The AWS CloudFormation template for deployment. Version 1.0","Mappings": {
"SourceCode": {
"General": {
"S3Bucket": "solutions","KeyPrefix": "connected-solution/latest"
}
}
},"Resources": {
"dashboard": {
"Type": "AWS::CloudWatch::Dashboard","Properties": {
"DashboardName": "Dynamodb-LambdaDashboard-xxx","DashboardBody": "{\"widgets\":[{\"type\":\"metric\",\"x\":0,\"y\":0,\"width\":12,\"height\":7,\"properties\":{\"metrics\":[[\"AWS/DynamoDB\",\"UserErrors\"]],\"view\":\"timeSeries\",\"stacked\":false,\"period\":300,\"stat\":\"Sum\",\"region\":\"us-east-1\"}}]}"
}
}
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。