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:
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.htmlimport 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();
-
ClassDescriptionInstance that uses Route 53 Alias record type.A fluent builder for
AliasTargetInstance
.Example:A builder forAliasTargetInstanceProps
An implementation forAliasTargetInstanceProps
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.A builder forBaseInstanceProps
An implementation forBaseInstanceProps
Example:A builder forBaseNamespaceProps
An implementation forBaseNamespaceProps
Basic props needed to create a service in a given namespace.A builder forBaseServiceProps
An implementation forBaseServiceProps
A CloudFormationAWS::ServiceDiscovery::HttpNamespace
.A fluent builder forCfnHttpNamespace
.Properties for defining aCfnHttpNamespace
.A builder forCfnHttpNamespaceProps
An implementation forCfnHttpNamespaceProps
A CloudFormationAWS::ServiceDiscovery::Instance
.A fluent builder forCfnInstance
.Properties for defining aCfnInstance
.A builder forCfnInstanceProps
An implementation forCfnInstanceProps
A CloudFormationAWS::ServiceDiscovery::PrivateDnsNamespace
.A fluent builder forCfnPrivateDnsNamespace
.DNS properties for the private DNS namespace.An implementation forCfnPrivateDnsNamespace.PrivateDnsPropertiesMutableProperty
Properties for the private DNS namespace.A builder forCfnPrivateDnsNamespace.PropertiesProperty
An implementation forCfnPrivateDnsNamespace.PropertiesProperty
Start of Authority (SOA) properties for a public or private DNS namespace.A builder forCfnPrivateDnsNamespace.SOAProperty
An implementation forCfnPrivateDnsNamespace.SOAProperty
Properties for defining aCfnPrivateDnsNamespace
.A builder forCfnPrivateDnsNamespaceProps
An implementation forCfnPrivateDnsNamespaceProps
A CloudFormationAWS::ServiceDiscovery::PublicDnsNamespace
.A fluent builder forCfnPublicDnsNamespace
.Properties for the public DNS namespace.A builder forCfnPublicDnsNamespace.PropertiesProperty
An implementation forCfnPublicDnsNamespace.PropertiesProperty
DNS properties for the public DNS namespace.A builder forCfnPublicDnsNamespace.PublicDnsPropertiesMutableProperty
An implementation forCfnPublicDnsNamespace.PublicDnsPropertiesMutableProperty
Start of Authority (SOA) properties for a public or private DNS namespace.A builder forCfnPublicDnsNamespace.SOAProperty
An implementation forCfnPublicDnsNamespace.SOAProperty
Properties for defining aCfnPublicDnsNamespace
.A builder forCfnPublicDnsNamespaceProps
An implementation forCfnPublicDnsNamespaceProps
A 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.DnsConfigProperty
An implementation forCfnService.DnsConfigProperty
A 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.DnsRecordProperty
An implementation forCfnService.DnsRecordProperty
Public DNS and HTTP namespaces only. A complex type that contains settings for an optional health check.A builder forCfnService.HealthCheckConfigProperty
An implementation forCfnService.HealthCheckConfigProperty
A complex type that contains information about an optional custom health check.A builder forCfnService.HealthCheckCustomConfigProperty
An implementation forCfnService.HealthCheckCustomConfigProperty
Properties for defining aCfnService
.A builder forCfnServiceProps
An implementation forCfnServiceProps
Instance that is accessible using a domain name (CNAME).A fluent builder forCnameInstance
.Example:A builder forCnameInstanceBaseProps
An implementation forCnameInstanceBaseProps
Example:A builder forCnameInstanceProps
An implementation forCnameInstanceProps
Example:Service props needed to create a service in a given namespace.A builder forDnsServiceProps
An implementation forDnsServiceProps
Settings for an optional Amazon Route 53 health check.A builder forHealthCheckConfig
An implementation forHealthCheckConfig
Specifies information about an optional custom health check.A builder forHealthCheckCustomConfig
An implementation forHealthCheckCustomConfig
Example:Define an HTTP Namespace.A fluent builder forHttpNamespace
.Example:A builder forHttpNamespaceAttributes
An implementation forHttpNamespaceAttributes
Example:A builder forHttpNamespaceProps
An implementation forHttpNamespaceProps
Internal 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 forIpInstanceBaseProps
An implementation forIpInstanceBaseProps
Example:A builder forIpInstanceProps
An implementation forIpInstanceProps
Internal 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 forNonIpInstanceBaseProps
An implementation forNonIpInstanceBaseProps
Example:A builder forNonIpInstanceProps
An implementation forNonIpInstanceProps
Define a Service Discovery HTTP Namespace.A fluent builder forPrivateDnsNamespace
.Example:A builder forPrivateDnsNamespaceAttributes
An implementation forPrivateDnsNamespaceAttributes
Example:A builder forPrivateDnsNamespaceProps
An implementation forPrivateDnsNamespaceProps
Define a Public DNS Namespace.A fluent builder forPublicDnsNamespace
.Example:A builder forPublicDnsNamespaceAttributes
An implementation forPublicDnsNamespaceAttributes
Example:A builder forPublicDnsNamespaceProps
An implementation forPublicDnsNamespaceProps
Define a CloudMap Service.A fluent builder forService
.Example:A builder forServiceAttributes
An implementation forServiceAttributes
Example:A builder forServiceProps
An implementation forServiceProps