gpt4 book ai didi

json - Cloudformation 中的 Cloudwatch 仪表板错误

转载 作者:行者123 更新时间:2023-12-03 07:27:00 39 4
gpt4 key购买 nike

我正在尝试使用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\"}}]}"
}
}
}

关于json - Cloudformation 中的 Cloudwatch 仪表板错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67060504/

39 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com