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=Duration.seconds(5),  # minimum
            path="/health-check-path",
            timeout=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, ip_preference=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.

  • ip_preference (Optional[IpPreference]) – No IP preference is applied to the Virtual Node.

Return type:

ServiceDiscovery

classmethod dns(hostname, response_type=None, ip_preference=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.

  • ip_preference (Optional[IpPreference]) – No IP preference is applied to the Virtual Node.

Return type:

ServiceDiscovery