Skip to content

(aws-servicediscovery): DNSNamespace to allow non ip instances to be registered  #21490

@jmortlock

Description

@jmortlock

Describe the feature

Currently when using either public or private DNS namespaces CDK restricts the ability to register a nonIPInstance and fails with the following message

Error: This type of instance can only be registered for HTTP namespaces.

The reason for this is because CDK creates all services within this namespace as discoverable via DNS; however it is actually possible to create services within a DNS namespace which are API only discoverable, this is done by setting the CFN attribute Type to the value of HTTP.
https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-servicediscovery-service.html

Escape hatches do not work in this instance as the check happens within a L2 construct; so to workaround this both service and instances need to be created using L1 constructs.

Use Case

Cloudmap with a combination of services which are discoverable via API Calls and DNS Queries or API Calls Only

Proposed Solution

Add a new attribute to DnsServiceProps to allow controlling discoverability mode.

i.e.

  namespace.createService("service", {
      discoverableVia: Discovery.HTTP_ONLY
    });
  namespace.createService("service", {
      discoverableVia: Discovery.HTTP_AND_DNS
    });

Alternative could just expose the "type" attribute directly

Other Information

No response

Acknowledgements

  • I may be able to implement this feature request
  • This feature might incur a breaking change

CDK version used

2.35.0

Environment details (OS name and version, etc.)

Ubuntu 20.0.4

Metadata

Metadata

Assignees

Labels

@aws-cdk/aws-servicediscoveryRelated to Amazon ECS Service Discoveryfeature-requestA feature should be added or improved.needs-triageThis issue or PR still needs to be triaged.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions