ServiceDiscovery

class aws_cdk.aws_appmesh.ServiceDiscovery

Bases: object

Provides the Service Discovery method a VirtualNode uses.

ExampleMetadata:

infused

Example:

# mesh: appmesh.Mesh
vpc = ec2.Vpc(self, "vpc")
namespace = cloudmap.PrivateDnsNamespace(self, "test-namespace",
    vpc=vpc,
    name="domain.local"
)
service = namespace.create_service("Svc")
node = mesh.add_virtual_node("virtual-node",
    service_discovery=appmesh.ServiceDiscovery.cloud_map(service),
    listeners=[appmesh.VirtualNodeListener.http(
        port=8081,
        health_check=appmesh.HealthCheck.http(
            healthy_threshold=3,
            interval=cdk.Duration.seconds(5),  # minimum
            path="/health-check-path",
            timeout=cdk.Duration.seconds(2),  # minimum
            unhealthy_threshold=2
        )
    )],
    access_log=appmesh.AccessLog.from_file_path("/dev/stdout")
)

Methods

abstract bind(scope)

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

Parameters:

scope (Construct) –

Return type:

ServiceDiscoveryConfig

Static Methods

classmethod cloud_map(service, instance_attributes=None)

Returns Cloud Map based service discovery.

Parameters:
  • service (IService) – The AWS Cloud Map Service to use for service discovery.

  • instance_attributes (Optional[Mapping[str, str]]) – 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. Only instances that match all of the specified key/value pairs will be returned.

Return type:

ServiceDiscovery

classmethod dns(hostname, response_type=None)

Returns DNS based service discovery.

Parameters:
  • hostname (str) –

  • response_type (Optional[DnsResponseType]) – Specifies the DNS response type for the virtual node. The default is DnsResponseType.LOAD_BALANCER.

Return type:

ServiceDiscovery