不允许使用无关的密钥 [HealthCheck]

extraneous key [HealthCheck] is not permitted

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

Resource handler returned message: "Model validation failed (#: extraneous key [HealthCheck] is not permitted)" (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>

HealthCheck is a sub-property of AWS::ECS::TaskDefinition.ContainerDefinition, not a top-level property of AWS::ECS::TaskDefinition