Class ServiceDiscovery
Provides the Service Discovery method a VirtualNode uses.
Namespace: Amazon.CDK.AWS.AppMesh
Assembly: Amazon.CDK.Lib.dll
Syntax (csharp)
public abstract class ServiceDiscovery : DeputyBase
Syntax (vb)
Public MustInherit Class ServiceDiscovery Inherits DeputyBase
Remarks
ExampleMetadata: infused
Examples
Mesh mesh;
var vpc = new Vpc(this, "vpc");
var namespace = new PrivateDnsNamespace(this, "test-namespace", new PrivateDnsNamespaceProps {
Vpc = vpc,
Name = "domain.local"
});
var service = namespace.CreateService("Svc");
var node = mesh.AddVirtualNode("virtual-node", new VirtualNodeBaseProps {
ServiceDiscovery = ServiceDiscovery.CloudMap(service),
Listeners = new [] { VirtualNodeListener.Http(new HttpVirtualNodeListenerOptions {
Port = 8081,
HealthCheck = HealthCheck.Http(new HttpHealthCheckOptions {
HealthyThreshold = 3,
Interval = Duration.Seconds(5), // minimum
Path = "/health-check-path",
Timeout = Duration.Seconds(2), // minimum
UnhealthyThreshold = 2
})
}) },
AccessLog = AccessLog.FromFilePath("/dev/stdout")
});
Synopsis
Constructors
ServiceDiscovery() | Provides the Service Discovery method a VirtualNode uses. |
Methods
Bind(Construct) | Binds the current object when adding Service Discovery to a VirtualNode. |
CloudMap(IService, IDictionary<string, string>?, IpPreference?) | Returns Cloud Map based service discovery. |
Dns(string, DnsResponseType?, IpPreference?) | Returns DNS based service discovery. |
Constructors
ServiceDiscovery()
Provides the Service Discovery method a VirtualNode uses.
protected ServiceDiscovery()
Remarks
ExampleMetadata: infused
Examples
Mesh mesh;
var vpc = new Vpc(this, "vpc");
var namespace = new PrivateDnsNamespace(this, "test-namespace", new PrivateDnsNamespaceProps {
Vpc = vpc,
Name = "domain.local"
});
var service = namespace.CreateService("Svc");
var node = mesh.AddVirtualNode("virtual-node", new VirtualNodeBaseProps {
ServiceDiscovery = ServiceDiscovery.CloudMap(service),
Listeners = new [] { VirtualNodeListener.Http(new HttpVirtualNodeListenerOptions {
Port = 8081,
HealthCheck = HealthCheck.Http(new HttpHealthCheckOptions {
HealthyThreshold = 3,
Interval = Duration.Seconds(5), // minimum
Path = "/health-check-path",
Timeout = Duration.Seconds(2), // minimum
UnhealthyThreshold = 2
})
}) },
AccessLog = AccessLog.FromFilePath("/dev/stdout")
});
Methods
Bind(Construct)
Binds the current object when adding Service Discovery to a VirtualNode.
public abstract IServiceDiscoveryConfig Bind(Construct scope)
Parameters
- scope Construct
Returns
Remarks
ExampleMetadata: infused
CloudMap(IService, IDictionary<string, string>?, IpPreference?)
Returns Cloud Map based service discovery.
public static ServiceDiscovery CloudMap(IService service, IDictionary<string, string>? instanceAttributes = null, IpPreference? ipPreference = null)
Parameters
- service IService
The AWS Cloud Map Service to use for service discovery.
- instanceAttributes IDictionary<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
Remarks
ExampleMetadata: infused
Dns(string, DnsResponseType?, IpPreference?)
Returns DNS based service discovery.
public static ServiceDiscovery Dns(string hostname, DnsResponseType? responseType = null, IpPreference? ipPreference = null)
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
Remarks
ExampleMetadata: infused