Skip to content
v2.274.0

ServiceDiscovery Class ​

Provides the Service Discovery method a VirtualNode uses.

Example ​

ts
const vpc = new ec2.Vpc(this, 'vpc');
const namespace = new cloudmap.PrivateDnsNamespace(this, 'test-namespace', {
    vpc,
    name: 'domain.local',
});
const service = namespace.createService('Svc');

declare const mesh: appmesh.Mesh;
const node = mesh.addVirtualNode('virtual-node', {
  serviceDiscovery: appmesh.ServiceDiscovery.cloudMap(service),
  listeners: [appmesh.VirtualNodeListener.http({
    port: 8081,
    healthCheck: appmesh.HealthCheck.http({
      healthyThreshold: 3,
      interval: Duration.seconds(5), // minimum
      path: '/health-check-path',
      timeout: Duration.seconds(2), // minimum
      unhealthyThreshold: 2,
    }),
  })],
  accessLog: appmesh.AccessLog.fromFilePath('/dev/stdout'),
});

Initializer ​

ts
new ServiceDiscovery()
python
ServiceDiscovery()
java
new ServiceDiscovery()
csharp
new ServiceDiscovery()
go
NewServiceDiscovery()

Methods ​

bind(scope: Construct): ServiceDiscoveryConfigdef bind(self, scope: Construct) -> ServiceDiscoveryConfigpublic ServiceDiscoveryConfig bind(Construct scope)public ServiceDiscoveryConfig Bind(Construct scope)func Bind(Scope Construct) ServiceDiscoveryConfig#
Binds the current object when adding Service Discovery to a VirtualNode.
cloudMap(service: IService, instanceAttributes?: { [key: string]: string }, ipPreference?: IpPreference): ServiceDiscovery // chainable@staticmethod def cloud_map(service: IService, instance_attributes: typing.Optional[typing.Mapping[str, str]] = None, ip_preference: typing.Optional[IpPreference] = None) -> ServiceDiscoverypublic static ServiceDiscovery cloudMap(IService service, Map<String, String> instanceAttributes, IpPreference ipPreference)public static ServiceDiscovery CloudMap(IService service, IDictionary<string, string>? instanceAttributes = null, IpPreference? ipPreference = null)func CloudMap(Service IService, InstanceAttributes *map[string]*string, IpPreference IpPreference) ServiceDiscoverystatic#
Returns Cloud Map based service discovery.
3 parameters

Parameters

  • serviceserviceserviceserviceService — The AWS Cloud Map Service to use for service discovery.
  • instanceAttributesinstance_attributesinstanceAttributesinstanceAttributesInstanceAttributes — A string map that contains attributes with values that you can use to filter instances by any custom attribute that you specified when you registered the instance.
  • ipPreferenceip_preferenceipPreferenceipPreferenceIpPreference — No IP preference is applied to the Virtual Node.
dns(hostname: string, responseType?: DnsResponseType, ipPreference?: IpPreference): ServiceDiscovery // chainable@staticmethod def dns(hostname: str, response_type: typing.Optional[DnsResponseType] = None, ip_preference: typing.Optional[IpPreference] = None) -> ServiceDiscoverypublic static ServiceDiscovery dns(String hostname, DnsResponseType responseType, IpPreference ipPreference)public static ServiceDiscovery Dns(string hostname, DnsResponseType? responseType = null, IpPreference? ipPreference = null)func Dns(Hostname *string, ResponseType DnsResponseType, IpPreference IpPreference) ServiceDiscoverystatic#
Returns DNS based service discovery.
2 parameters

Parameters

  • responseTyperesponse_typeresponseTyperesponseTypeResponseType — Specifies the DNS response type for the virtual node.
  • ipPreferenceip_preferenceipPreferenceipPreferenceIpPreference — No IP preference is applied to the Virtual Node.