aws-cloudformation - 不允许使用无关 key [HealthCheck]

标签 aws-cloudformation amazon-ecs aws-fargate

我有点陷入这个奇怪的错误。 我正在使用 CloudFormation 脚本部署 ECS 任务 (Fargate),它可以正常工作并成功部署该任务。但是当设置了 HealthCheck 属性时 Cloudformation 会回复

资源处理程序返回消息:“模型验证失败(#:不允许使用无关 key [HealthCheck])”(RequestToken:xxxxxxx-xxx-xxxx-xxxx-xxxxxxxxxxxx,HandlerErrorCode:InvalidRequest)

我的任务定义是:

  TaskDefinition:
    Type: AWS::ECS::TaskDefinition
    Properties:
      Family: !Sub ${ServiceName}-${EnvironmentName}
      Cpu: !Ref 'ContainerCpu'
      Memory: !Ref 'ContainerMemory'
      NetworkMode: awsvpc
      RequiresCompatibilities:
        - FARGATE
      ExecutionRoleArn: arn:aws:iam::xxxxxxxx:role/some-iam-role
      HealthCheck:
        Command:
          - [ CMD-SHELL,./compose/healthcheck.sh || exit 1 ]
        Interval: 10
        Retries: 5
        StartPeriod: 30
        Timeout: 5
      TaskRoleArn:
        Fn::If:
          - 'HasCustomRole'
          - !Ref 'Role'
          - !Ref "AWS::NoValue"
      ContainerDefinitions:
        - Name: !Ref 'ServiceName'
          Cpu: !Ref 'ContainerCpu'
          Memory: !Ref 'ContainerMemory'
          Image: !Ref 'ImageUrl'
          PortMappings:
            - ContainerPort: !Ref 'ContainerPort'
          LogConfiguration:
            LogDriver: 'awslogs'
            Options:
              awslogs-group: !Sub ${ServiceName}-service-${EnvironmentName}
              awslogs-region: !Ref 'AWS::Region'
              awslogs-stream-prefix: !Ref 'ServiceName'
          Environment:
            - <some other environment that work ok>

最佳答案

关于aws-cloudformation - 不允许使用无关 key [HealthCheck],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68006404/

相关文章:

amazon-web-services - 尝试使用 SNS 和 SQS 创建云形成模板,但消息从未到达

amazon-web-services - 使用 UDP ECS 服务对 NetworkLoadBalancer 进行健康检查

node.js - Kubernetes AWS Fargate (EKS) 持续终止 pod 托管 React 服务

aws-cloudformation - 如何使用cloudformation在已有的任务定义中添加新容器?

amazon-web-services - 如何使用 AWS CLI 确定 AWS 资源属于哪个 CloudFormation 堆栈?

amazon-web-services - 无效的数据库实例类 : db. t2.micro

amazon-web-services - 使用自定义资源访问cloudformation中的API网关端点

java - 您如何使用 Docker 确定 Java 微服务的堆/非堆大小?

amazon-web-services - 附加到 EC2 实例的 IAM 策略规则是否与附加到在 EC2 中运行的 ECS 任务的策略规则重叠(&覆盖)?

amazon-web-services - AWS 使用 Fargate 对 ECS 服务的多个端口进行负载平衡