Package software.amazon.awscdk.services.servicediscovery
Amazon ECS Service Discovery Construct Library
---
AWS CDK v1 has reached End-of-Support on 2023-06-01. This package is no longer being updated, and users should migrate to AWS CDK v2.
For more information on how to migrate, see the Migrating to AWS CDK v2 guide.
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:
import software.amazon.awscdk.core.*;
import software.amazon.awscdk.services.servicediscovery.*;
App app = new App();
Stack stack = new Stack(app, "aws-servicediscovery-integ");
HttpNamespace namespace = HttpNamespace.Builder.create(stack, "MyNamespace")
.name("covfefe")
.build();
Service service1 = namespace.createService("NonIpService", BaseServiceProps.builder()
.description("service registering non-ip instances")
.build());
service1.registerNonIpInstance("NonIpInstance", NonIpInstanceBaseProps.builder()
.customAttributes(Map.of("arn", "arn:aws:s3:::mybucket"))
.build());
Service service2 = namespace.createService("IpService", BaseServiceProps.builder()
.description("service registering ip instances")
.healthCheck(HealthCheckConfig.builder()
.type(HealthCheckType.HTTP)
.resourcePath("/check")
.build())
.build());
service2.registerIpInstance("IpInstance", IpInstanceBaseProps.builder()
.ipv4("54.239.25.192")
.build());
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:
import software.amazon.awscdk.services.ec2.*;
import software.amazon.awscdk.services.elasticloadbalancingv2.*;
import software.amazon.awscdk.core.*;
import software.amazon.awscdk.services.servicediscovery.*;
App app = new App();
Stack stack = new Stack(app, "aws-servicediscovery-integ");
Vpc vpc = Vpc.Builder.create(stack, "Vpc").maxAzs(2).build();
PrivateDnsNamespace namespace = PrivateDnsNamespace.Builder.create(stack, "Namespace")
.name("boobar.com")
.vpc(vpc)
.build();
Service service = namespace.createService("Service", DnsServiceProps.builder()
.dnsRecordType(DnsRecordType.A_AAAA)
.dnsTtl(Duration.seconds(30))
.loadBalancer(true)
.build());
ApplicationLoadBalancer loadbalancer = ApplicationLoadBalancer.Builder.create(stack, "LB").vpc(vpc).internetFacing(true).build();
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:
import software.amazon.awscdk.core.*;
import software.amazon.awscdk.services.servicediscovery.*;
App app = new App();
Stack stack = new Stack(app, "aws-servicediscovery-integ");
PublicDnsNamespace namespace = PublicDnsNamespace.Builder.create(stack, "Namespace")
.name("foobar.com")
.build();
Service service = namespace.createService("Service", DnsServiceProps.builder()
.name("foo")
.dnsRecordType(DnsRecordType.A)
.dnsTtl(Duration.seconds(30))
.healthCheck(HealthCheckConfig.builder()
.type(HealthCheckType.HTTPS)
.resourcePath("/healthcheck")
.failureThreshold(2)
.build())
.build());
service.registerIpInstance("IpInstance", IpInstanceBaseProps.builder()
.ipv4("54.239.25.192")
.port(443)
.build());
app.synth();
For DNS namespaces, you can also register instances to services with CNAME records:
import software.amazon.awscdk.core.*;
import software.amazon.awscdk.services.servicediscovery.*;
App app = new App();
Stack stack = new Stack(app, "aws-servicediscovery-integ");
PublicDnsNamespace namespace = PublicDnsNamespace.Builder.create(stack, "Namespace")
.name("foobar.com")
.build();
Service service = namespace.createService("Service", DnsServiceProps.builder()
.name("foo")
.dnsRecordType(DnsRecordType.CNAME)
.dnsTtl(Duration.seconds(30))
.build());
service.registerCnameInstance("CnameInstance", CnameInstanceBaseProps.builder()
.instanceCname("service.pizza")
.build());
app.synth();
Deprecated: AWS CDK v1 has reached End-of-Support on 2023-06-01.
This package is no longer being updated, and users should migrate to AWS CDK v2.
For more information on how to migrate, see https://docs.aws.amazon.com/cdk/v2/guide/migrating-v2.html-
ClassDescriptionInstance that uses Route 53 Alias record type.A fluent builder for
AliasTargetInstance.Example:A builder forAliasTargetInstancePropsAn implementation forAliasTargetInstancePropsUsed 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.A builder forBaseInstancePropsAn implementation forBaseInstancePropsExample:A builder forBaseNamespacePropsAn implementation forBaseNamespacePropsBasic props needed to create a service in a given namespace.A builder forBaseServicePropsAn implementation forBaseServicePropsA CloudFormationAWS::ServiceDiscovery::HttpNamespace.A fluent builder forCfnHttpNamespace.Properties for defining aCfnHttpNamespace.A builder forCfnHttpNamespacePropsAn implementation forCfnHttpNamespacePropsA CloudFormationAWS::ServiceDiscovery::Instance.A fluent builder forCfnInstance.Properties for defining aCfnInstance.A builder forCfnInstancePropsAn implementation forCfnInstancePropsA CloudFormationAWS::ServiceDiscovery::PrivateDnsNamespace.A fluent builder forCfnPrivateDnsNamespace.DNS properties for the private DNS namespace.An implementation forCfnPrivateDnsNamespace.PrivateDnsPropertiesMutablePropertyProperties for the private DNS namespace.A builder forCfnPrivateDnsNamespace.PropertiesPropertyAn implementation forCfnPrivateDnsNamespace.PropertiesPropertyStart of Authority (SOA) properties for a public or private DNS namespace.A builder forCfnPrivateDnsNamespace.SOAPropertyAn implementation forCfnPrivateDnsNamespace.SOAPropertyProperties for defining aCfnPrivateDnsNamespace.A builder forCfnPrivateDnsNamespacePropsAn implementation forCfnPrivateDnsNamespacePropsA CloudFormationAWS::ServiceDiscovery::PublicDnsNamespace.A fluent builder forCfnPublicDnsNamespace.Properties for the public DNS namespace.A builder forCfnPublicDnsNamespace.PropertiesPropertyAn implementation forCfnPublicDnsNamespace.PropertiesPropertyDNS properties for the public DNS namespace.A builder forCfnPublicDnsNamespace.PublicDnsPropertiesMutablePropertyAn implementation forCfnPublicDnsNamespace.PublicDnsPropertiesMutablePropertyStart of Authority (SOA) properties for a public or private DNS namespace.A builder forCfnPublicDnsNamespace.SOAPropertyAn implementation forCfnPublicDnsNamespace.SOAPropertyProperties for defining aCfnPublicDnsNamespace.A builder forCfnPublicDnsNamespacePropsAn implementation forCfnPublicDnsNamespacePropsA CloudFormationAWS::ServiceDiscovery::Service.A fluent builder forCfnService.A complex type that contains information about the Amazon RouteĀ 53 DNS records that you want AWS Cloud Map to create when you register an instance.A builder forCfnService.DnsConfigPropertyAn implementation forCfnService.DnsConfigPropertyA complex type that contains information about the RouteĀ 53 DNS records that you want AWS Cloud Map to create when you register an instance.A builder forCfnService.DnsRecordPropertyAn implementation forCfnService.DnsRecordPropertyPublic DNS and HTTP namespaces only. A complex type that contains settings for an optional health check.A builder forCfnService.HealthCheckConfigPropertyAn implementation forCfnService.HealthCheckConfigPropertyA complex type that contains information about an optional custom health check.A builder forCfnService.HealthCheckCustomConfigPropertyAn implementation forCfnService.HealthCheckCustomConfigPropertyProperties for defining aCfnService.A builder forCfnServicePropsAn implementation forCfnServicePropsInstance that is accessible using a domain name (CNAME).A fluent builder forCnameInstance.Example:A builder forCnameInstanceBasePropsAn implementation forCnameInstanceBasePropsExample:A builder forCnameInstancePropsAn implementation forCnameInstancePropsExample:Service props needed to create a service in a given namespace.A builder forDnsServicePropsAn implementation forDnsServicePropsSettings for an optional Amazon Route 53 health check.A builder forHealthCheckConfigAn implementation forHealthCheckConfigSpecifies information about an optional custom health check.A builder forHealthCheckCustomConfigAn implementation forHealthCheckCustomConfigExample:Define an HTTP Namespace.A fluent builder forHttpNamespace.Example:A builder forHttpNamespaceAttributesAn implementation forHttpNamespaceAttributesExample:A builder forHttpNamespacePropsAn implementation forHttpNamespacePropsInternal default implementation forIHttpNamespace.A proxy class which represents a concrete javascript instance of this type.Internal default implementation forIInstance.A proxy class which represents a concrete javascript instance of this type.Internal default implementation forINamespace.A proxy class which represents a concrete javascript instance of this type.Instance that is accessible using an IP address.A fluent builder forIpInstance.Example:A builder forIpInstanceBasePropsAn implementation forIpInstanceBasePropsExample:A builder forIpInstancePropsAn implementation forIpInstancePropsInternal default implementation forIPrivateDnsNamespace.A proxy class which represents a concrete javascript instance of this type.Internal default implementation forIPublicDnsNamespace.A proxy class which represents a concrete javascript instance of this type.Internal default implementation forIService.A proxy class which represents a concrete javascript instance of this type.Instance accessible using values other than an IP address or a domain name (CNAME).A fluent builder forNonIpInstance.Example:A builder forNonIpInstanceBasePropsAn implementation forNonIpInstanceBasePropsExample:A builder forNonIpInstancePropsAn implementation forNonIpInstancePropsDefine a Service Discovery HTTP Namespace.A fluent builder forPrivateDnsNamespace.Example:A builder forPrivateDnsNamespaceAttributesAn implementation forPrivateDnsNamespaceAttributesExample:A builder forPrivateDnsNamespacePropsAn implementation forPrivateDnsNamespacePropsDefine a Public DNS Namespace.A fluent builder forPublicDnsNamespace.Example:A builder forPublicDnsNamespaceAttributesAn implementation forPublicDnsNamespaceAttributesExample:A builder forPublicDnsNamespacePropsAn implementation forPublicDnsNamespacePropsDefine a CloudMap Service.A fluent builder forService.Example:A builder forServiceAttributesAn implementation forServiceAttributesExample:A builder forServicePropsAn implementation forServiceProps