aws-cdk-lib.aws_appmesh.ServiceDiscovery

class ServiceDiscovery

LanguageType name
.NETAmazon.CDK.AWS.AppMesh.ServiceDiscovery
Gogithub.com/aws/aws-cdk-go/awscdk/v2/awsappmesh#ServiceDiscovery
Javasoftware.amazon.awscdk.services.appmesh.ServiceDiscovery
Pythonaws_cdk.aws_appmesh.ServiceDiscovery
TypeScript (source)aws-cdk-lib » aws_appmesh » ServiceDiscovery

Provides the Service Discovery method a VirtualNode uses.

Example

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

new ServiceDiscovery()

Methods

NameDescription
bind(scope)Binds the current object when adding Service Discovery to a VirtualNode.
static cloudMap(service, instanceAttributes?, ipPreference?)Returns Cloud Map based service discovery.
static dns(hostname, responseType?, ipPreference?)Returns DNS based service discovery.

bind(scope)

public bind(scope: Construct): ServiceDiscoveryConfig

Parameters

  • scope Construct

Returns

  • ServiceDiscoveryConfig

Binds the current object when adding Service Discovery to a VirtualNode.


static cloudMap(service, instanceAttributes?, ipPreference?)

public static cloudMap(service: IService, instanceAttributes?: { [string]: string }, ipPreference?: IpPreference): ServiceDiscovery

Parameters

  • service IService — The AWS Cloud Map Service to use for service discovery.
  • instanceAttributes { [string]: string } — 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.
  • ipPreference IpPreference — No IP preference is applied to the Virtual Node.

Returns

  • ServiceDiscovery

Returns Cloud Map based service discovery.


static dns(hostname, responseType?, ipPreference?)

public static dns(hostname: string, responseType?: DnsResponseType, ipPreference?: IpPreference): ServiceDiscovery

Parameters

  • hostname string
  • responseType DnsResponseType — Specifies the DNS response type for the virtual node.
  • ipPreference IpPreference — No IP preference is applied to the Virtual Node.

Returns

  • ServiceDiscovery

Returns DNS based service discovery.