Namespace Amazon.CDK.AWS.ServiceDiscovery
Amazon ECS Service Discovery Construct Library
---This module is part of the AWS Cloud Development Kit project.
This package contains constructs for working with AWS Cloud Map
AWS Cloud Map is a fully managed service that you can use to create and maintain a map of the backend services and resources that your applications depend on.
For further information on AWS Cloud Map, see the AWS Cloud Map documentation
HTTP Namespace Example
The following example creates an AWS Cloud Map namespace that supports API calls, creates a service in that namespace, and registers an instance to it:
// Example automatically generated. See https://github.com/aws/jsii/issues/826
using Amazon.CDK;
using Lib;
App app = new App();
Stack stack = new Stack(app, "aws-servicediscovery-integ");
HttpNamespace namespace = new HttpNamespace(stack, "MyNamespace", new HttpNamespaceProps {
Name = "covfefe"
});
Service service1 = namespace.CreateService("NonIpService", new BaseServiceProps {
Description = "service registering non-ip instances"
});
service1.RegisterNonIpInstance("NonIpInstance", new NonIpInstanceBaseProps {
CustomAttributes = new Dictionary<string, string> { { "arn", "arn:aws:s3:::mybucket" } }
});
Service service2 = namespace.CreateService("IpService", new BaseServiceProps {
Description = "service registering ip instances",
HealthCheck = new HealthCheckConfig {
Type = HealthCheckType.HTTP,
ResourcePath = "/check"
}
});
service2.RegisterIpInstance("IpInstance", new Dictionary<string, string?> {
{ "ipv4", "54.239.25.192" }
});
app.Synth();
Private DNS Namespace Example
The following example creates an AWS Cloud Map namespace that supports both API calls and DNS queries within a vpc, creates a service in that namespace, and registers a loadbalancer as an instance:
// Example automatically generated. See https://github.com/aws/jsii/issues/826
using Amazon.CDK.AWS.EC2;
using Amazon.CDK.AWS.ElasticLoadBalancingV2;
using Amazon.CDK;
using Lib;
App app = new App();
Stack stack = new Stack(app, "aws-servicediscovery-integ");
Vpc vpc = new Vpc(stack, "Vpc", new VpcProps { MaxAzs = 2 });
PrivateDnsNamespace namespace = new PrivateDnsNamespace(stack, "Namespace", new PrivateDnsNamespaceProps {
Name = "boobar.com",
Vpc = vpc
});
Service service = namespace.CreateService("Service", new DnsServiceProps {
DnsRecordType = DnsRecordType.A_AAAA,
DnsTtl = Duration.Seconds(30),
LoadBalancer = true
});
ApplicationLoadBalancer loadbalancer = new ApplicationLoadBalancer(stack, "LB", new ApplicationLoadBalancerProps { Vpc = vpc, InternetFacing = true });
service.RegisterLoadBalancer("Loadbalancer", loadbalancer);
app.Synth();
Public DNS Namespace Example
The following example creates an AWS Cloud Map namespace that supports both API calls and public DNS queries, creates a service in that namespace, and registers an IP instance:
// Example automatically generated. See https://github.com/aws/jsii/issues/826
using Amazon.CDK;
using Lib;
App app = new App();
Stack stack = new Stack(app, "aws-servicediscovery-integ");
PublicDnsNamespace namespace = new PublicDnsNamespace(stack, "Namespace", new PublicDnsNamespaceProps {
Name = "foobar.com"
});
Service service = namespace.CreateService("Service", new DnsServiceProps {
Name = "foo",
DnsRecordType = DnsRecordType.A,
DnsTtl = Duration.Seconds(30),
HealthCheck = new HealthCheckConfig {
Type = HealthCheckType.HTTPS,
ResourcePath = "/healthcheck",
FailureThreshold = 2
}
});
service.RegisterIpInstance("IpInstance", new Dictionary<string, string?> {
{ "ipv4", "54.239.25.192" },
{ "port", 443 }
});
app.Synth();
For DNS namespaces, you can also register instances to services with CNAME records:
// Example automatically generated. See https://github.com/aws/jsii/issues/826
using Amazon.CDK;
using Lib;
App app = new App();
Stack stack = new Stack(app, "aws-servicediscovery-integ");
PublicDnsNamespace namespace = new PublicDnsNamespace(stack, "Namespace", new PublicDnsNamespaceProps {
Name = "foobar.com"
});
Service service = namespace.CreateService("Service", new DnsServiceProps {
Name = "foo",
DnsRecordType = DnsRecordType.CNAME,
DnsTtl = Duration.Seconds(30)
});
service.RegisterCnameInstance("CnameInstance", new CnameInstanceBaseProps {
InstanceCname = "service.pizza"
});
app.Synth();
Classes
AliasTargetInstance | Instance that uses Route 53 Alias record type. |
AliasTargetInstanceProps | |
BaseInstanceProps | Used when the resource that's associated with the service instance is accessible using values other than an IP address or a domain name (CNAME), i.e. for non-ip-instances. |
BaseNamespaceProps | |
BaseServiceProps | Basic props needed to create a service in a given namespace. |
CfnHttpNamespace | A CloudFormation |
CfnHttpNamespaceProps | Properties for defining a |
CfnInstance | A CloudFormation |
CfnInstanceProps | Properties for defining a |
CfnPrivateDnsNamespace | A CloudFormation |
CfnPrivateDnsNamespaceProps | Properties for defining a |
CfnPublicDnsNamespace | A CloudFormation |
CfnPublicDnsNamespaceProps | Properties for defining a |
CfnService | A CloudFormation |
CfnService.DnsConfigProperty | |
CfnService.DnsRecordProperty | |
CfnService.HealthCheckConfigProperty | |
CfnService.HealthCheckCustomConfigProperty | |
CfnServiceProps | Properties for defining a |
CnameInstance | Instance that is accessible using a domain name (CNAME). |
CnameInstanceBaseProps | |
CnameInstanceProps | |
DnsRecordType | |
DnsServiceProps | Service props needed to create a service in a given namespace. |
HealthCheckConfig | Settings for an optional Amazon Route 53 health check. |
HealthCheckCustomConfig | Specifies information about an optional custom health check. |
HealthCheckType | |
HttpNamespace | Define an HTTP Namespace. |
HttpNamespaceAttributes | |
HttpNamespaceProps | |
InstanceBase | |
IpInstance | Instance that is accessible using an IP address. |
IpInstanceBaseProps | |
IpInstanceProps | |
NamespaceType | |
NonIpInstance | Instance accessible using values other than an IP address or a domain name (CNAME). |
NonIpInstanceBaseProps | |
NonIpInstanceProps | |
PrivateDnsNamespace | Define a Service Discovery HTTP Namespace. |
PrivateDnsNamespaceAttributes | |
PrivateDnsNamespaceProps | |
PublicDnsNamespace | Define a Public DNS Namespace. |
PublicDnsNamespaceAttributes | |
PublicDnsNamespaceProps | |
RoutingPolicy | |
Service | Define a CloudMap Service. |
ServiceAttributes | |
ServiceProps |
Interfaces
CfnService.IDnsConfigProperty | |
CfnService.IDnsRecordProperty | |
CfnService.IHealthCheckConfigProperty | |
CfnService.IHealthCheckCustomConfigProperty | |
IAliasTargetInstanceProps | |
IBaseInstanceProps | Used when the resource that's associated with the service instance is accessible using values other than an IP address or a domain name (CNAME), i.e. for non-ip-instances. |
IBaseNamespaceProps | |
IBaseServiceProps | Basic props needed to create a service in a given namespace. |
ICfnHttpNamespaceProps | Properties for defining a |
ICfnInstanceProps | Properties for defining a |
ICfnPrivateDnsNamespaceProps | Properties for defining a |
ICfnPublicDnsNamespaceProps | Properties for defining a |
ICfnServiceProps | Properties for defining a |
ICnameInstanceBaseProps | |
ICnameInstanceProps | |
IDnsServiceProps | Service props needed to create a service in a given namespace. |
IHealthCheckConfig | Settings for an optional Amazon Route 53 health check. |
IHealthCheckCustomConfig | Specifies information about an optional custom health check. |
IHttpNamespace | |
IHttpNamespaceAttributes | |
IHttpNamespaceProps | |
IInstance | |
IIpInstanceBaseProps | |
IIpInstanceProps | |
INamespace | |
INonIpInstanceBaseProps | |
INonIpInstanceProps | |
IPrivateDnsNamespace | |
IPrivateDnsNamespaceAttributes | |
IPrivateDnsNamespaceProps | |
IPublicDnsNamespace | |
IPublicDnsNamespaceAttributes | |
IPublicDnsNamespaceProps | |
IService | |
IServiceAttributes | |
IServiceProps |