简体   繁体   English

AWS ECS CloudFormation 无法使用服务发现注册表创建服务

[英]AWS ECS CloudFormation unable to create service with service discovery registry

I have the following lines in my stack template:我的堆栈模板中有以下几行:

Service:
        Type: AWS::ECS::Service
        DependsOn: ListenerRule
        Properties:
            LaunchType: EC2
            ServiceRegistries:
                - RegistryArn: {"Fn::GetAtt": [ServiceDiscovery, Arn]}...
ServiceDiscovery:
      Type: "AWS::ServiceDiscovery::Service"
      Properties:
        Description: Service discovery registry
        DnsConfig:
          DnsRecords: [{"Type": "SRV", "TTL": 100}]
          NamespaceId:
            Fn::ImportValue: PrivateDNS
        Name: ping-service

Task definition network mode = "host".任务定义网络模式=“主机”。

When I push the template I see the following error: When specifying 'host' or 'bridge' for networkMode, values for 'containerName' and 'containerPort' must be specified from the task definition当我推送模板时,我看到以下错误: When specifying 'host' or 'bridge' for networkMode, values for 'containerName' and 'containerPort' must be specified from the task definition

However if registry properties 'containerName' and 'containerPort' are set then it throws another error: Encountered unsupported property containerName但是,如果设置了注册表属性“containerName”和“containerPort”,则会引发另一个错误: Encountered unsupported property containerName

How can service discovery registry be created with CloudFormation?如何使用 CloudFormation 创建服务发现注册表?

It's not possible to specify those properties from CloudFormation yet.尚无法从 CloudFormation 指定这些属性。 As seen in the developer guide for ECS you have to specify containerName from the serviceRegistries parameter.正如ECS 的开发人员指南中所见,您必须从serviceRegistries参数中指定containerName But when we look at the CloudFormation ServiceRegistry documentation we can't find those options:但是当我们查看CloudFormation ServiceRegistry 文档时,我们找不到这些选项:

{
  "Port" : Integer,
  "RegistryArn" : String
}

I got When specifying 'host' or 'bridge' for networkMode, values for 'containerName' and 'containerPort' must be specified from the task definition when simply trying to create an EC2 deployment type with Host networking on an existing Service Discovery service.我得到When specifying 'host' or 'bridge' for networkMode, values for 'containerName' and 'containerPort' must be specified from the task definition The fix was to create the ECS service with a Service Discovery type of "SRV" instead of "A" (the error should read more like "Service Discovery A records are not compatible with EC2 Host networking.")修复是使用“SRV”而不是“A”的服务发现类型创建 ECS 服务(错误应该更像“服务发现 A 记录与 EC2 主机网络不兼容。”)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM