amazon-web-services - 发现 CloudFormation ECS ContainerDefinitions 预期类型 : JSONArray,:字符串

标签 amazon-web-services aws-cloudformation

我尝试部署 CloudFormation 模板并收到以下错误:

(这是一个 YAML 文件)

资源处理程序返回消息:“模型验证失败(#/ContainerDefinitions:预期类型:JSONArray,找到:String)”(RequestToken:d23861e3-70c3-2777-96ce-18b46a118437,HandlerErrorCode:InvalidRequest)

我必须从下面的代码中删除一些值,但除此之外它的布局相同。

ECSTaskDefinition:
Type: AWS::ECS::TaskDefinition
Properties:
  ContainerDefinitions: !Sub |
    [
      {
        "name": "web",
        "image": "xxxxxxxxxxxxxxxxxxxxx:latest",
        "portMappings": [
          {
            "containerPort": 80,
            "hostPort": 80,
            "protocol": "tcp"
          }
        ],
        "environment": [
          {
            "name": "",
            "value": ""
          },
          {
            "name": "",
            "value": ""
          },
          {
            "name": "",
            "value": ""
          },
          {
            "name": "",
            "value": ""
          },
          {
            "name": "",
            "value": ""
          },
          {
            "name": "",
            "value": ""
          },
          {
            "name": "",
            "value": ""
          },
          {
            "name": "",
            "value": ""
          },
          {
            "name": "",
            "value": ""
          },
          {
            "name": "",
            "value": ""
          },
          {
            "name": "",
            "value": ""
          },
          {
            "name": "",
            "value": ""
          },
          {
            "name": "",
            "value": ""
          },
          {
            "name": "",
            "value": ""
          },
          {
            "name": "",
            "value": ""
          },
          {
            "name": "",
            "value": ""
          },
          {
            "name": "",
            "value": ""
          },
          {
            "name": "",
            "value": ""
          },
          {
            "name": "",
            "value": ""
          },
          {
            "name": "",
            "value": ""
          }
        ],
        "ulimits": [
          {
            "name": "nofile",
            "softLimit": 65536,
            "hardLimit": 65536
          }
        ],
        "volumesFrom": [],
        "logConfiguration": {
          "logDriver": "awslogs",
          "secretOptions": null,
          "options": {
            "awslogs-group": "/ecs/web",
            "awslogs-region": "eu-west-2",
            "awslogs-stream-prefix": "ecs"
          }
        }
      }
    ]

最佳答案

容器定义中的管道将在 yaml 中强制使用字符串。这就是问题所在。

容器定义:!Sub |

遵循文档https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-ecs-taskdefinition.html

关于amazon-web-services - 发现 CloudFormation ECS ContainerDefinitions 预期类型 : JSONArray,:字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/72044464/

相关文章:

mysql - 在 AWS MySQL 中存储 Emoji 字符

amazon-web-services - 在 AWS 中,我们可以仅对两个不同的 dynamodb 表使用一个客户托管 key 吗?这是好的做法吗?

amazon-web-services - 如何将过滤器与 boto3 vpc 端点服务结合使用?

swagger 文件内容未在 aws apigateway 中更新

aws-cloudformation - 如何使用 CloudFormation 在 IAM 中设置用户名和组名?

amazon-web-services - Amazon ElasticBeanStalk Worker Tier 无法连接到 SQS

json - 如何在集成请求 (AWS APIGateway) 中取消转义请求路径

node.js - 如何使用 Elastic Load Balancer 和 Node.js(HTTP 和 TCP)正确运行 Amazon EC2?

amazon-web-services - AWS Elastic Beanstalk EFS 安装错误 : unknown filesystem type 'efs'

aws-cloudformation - 云信息 : Dynamic Reference with Parameter