3
votes

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

However if registry properties 'containerName' and 'containerPort' are set then it throws another error: Encountered unsupported property containerName

How can service discovery registry be created with CloudFormation?

1
It seems that the only way for now to associate service discovery service with ECS is to use "awsvpc" network mode for task definition.Alex

1 Answers

2
votes

It's not possible to specify those properties from CloudFormation yet. As seen in the developer guide for ECS you have to specify containerName from the serviceRegistries parameter. But when we look at the CloudFormation ServiceRegistry documentation we can't find those options:

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