Registry / aws / aws-cdk-aws-servicediscovery

aws-cdk-aws-servicediscovery

JSON →
library1.204.0pypypiunverified

The `aws-cdk-aws-servicediscovery` package provides AWS Cloud Development Kit (CDK) constructs for AWS Cloud Map (Service Discovery). It allows you to define and manage DNS-based service discovery for your applications within AWS infrastructure as code. This package is part of the CDK v1 ecosystem, and its functionality is integrated into `aws-cdk-lib` for CDK v2. The current version is 1.204.0, following the release cadence of AWS CDK v1.

pip install aws-cdk-aws-servicediscovery aws-cdk.core
INSTALL
IMPORT
SIG · AWS-CDK-AWS-SERVIC
A
aws-cdk-aws-servicediscovery
awspythonv1.204.0
Install
7.8s avg
Import
Disk
65MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.204.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.910 runs
installs and imports cleanly · install 0.0s · import 0.000s · 62.7MB
glibc
py 3.103.910 runs
installs and imports cleanly · install 7.8s · import 0.000s · 63MB
65MB installed
● package 65MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

aws_servicediscovery
from aws_cdk import aws_servicediscovery
from aws_cdk_lib import aws_servicediscovery
This package is for CDK v1. For CDK v2, the `aws_servicediscovery` module is imported from `aws_cdk.aws_servicediscovery` within the `aws-cdk-lib` package.
PublicDnsNamespace
from aws_cdk.aws_servicediscovery import PublicDnsNamespace
PrivateDnsNamespace
from aws_cdk.aws_servicediscovery import PrivateDnsNamespace
Service
from aws_cdk.aws_servicediscovery import Service

This quickstart demonstrates how to create a Public DNS Namespace and register an IP-based service instance using AWS CDK v1. This sets up a discoverable DNS record (e.g., `web-api.example.com`) that can be resolved by clients.

import os from aws_cdk import ( core, aws_servicediscovery as servicediscovery ) class MyServiceDiscoveryStack(core.Stack): def __init__(self, scope: core.Construct, id: str, **kwargs) -> None: super().__init__(scope, id, **kwargs) # Create a Public DNS Namespace # This will create a Route 53 Hosted Zone for your services. public_dns_namespace = servicediscovery.PublicDnsNamespace( self, "MyPublicNamespace", name="example.com" ) # Create a service within the namespace # This service will have an A record by default for IP instances. service = public_dns_namespace.create_service( "MyPublicWebService", name="web-api" ) # Register an IP instance with the service # Applications can now discover 'web-api.example.com' service.register_ip_instance( "WebInstance1", ip="192.0.2.100", # Example IP address, replace with actual target port=80 ) # Instantiate and synthesize the CDK app app = core.App() MyServiceDiscoveryStack(app, os.environ.get('CDK_STACK_NAME', 'ServiceDiscoveryQuickstartStack')) app.synth()
cdk --version
Debug
Known issues
breakingThis package (`aws-cdk-aws-servicediscovery`) is for AWS CDK v1. AWS CDK v2 has consolidated all `aws-cdk.aws-*` packages into `aws-cdk-lib`. Mixing v1 and v2 packages will lead to runtime errors.
fix
For new projects or migration, use CDK v2 and import `aws_cdk.aws_servicediscovery` from `aws_cdk.aws_servicediscovery` after installing `aws-cdk-lib`. For existing v1 projects, ensure all CDK packages (`aws-cdk.core` and `aws-cdk.aws-*`) are consistently v1.
affects: All v1.x.x versions when used with v2 core.
gotchaWhen creating a `PrivateDnsNamespace`, you *must* associate it with an existing VPC. Forgetting this will cause CloudFormation deployment failures.
fix
Ensure you provide a `vpc` property, typically an `aws_ec2.Vpc` object, when instantiating `servicediscovery.PrivateDnsNamespace`.
affects: All versions
gotchaCloud Map service instances registered via IP (`register_ip_instance`) are not automatically deregistered if the underlying resource (e.g., an EC2 instance) is terminated outside of CDK's control. This can lead to stale DNS records.
fix
Implement custom lifecycle hooks or monitoring to deregister instances when the associated resource is terminated. For EC2 instances, consider using Auto Scaling Groups with integrated Cloud Map support.
affects: All versions
Upgrade
Version history
1.204.0latest on PyPI · released Jun 19, 2023
Audit
Dependencies
aws-cdk.corerequiredCore CDK functionalities like Stack and Construct are required.
aws-cdk.aws-ec2optionalRequired for creating Private DNS Namespaces which must be associated with a VPC.
aws-cdk.aws-route53optionalIndirectly used by Public DNS Namespaces.
Agent activity
19 hits · last 30 days
node
16
OpenAI (training)
2
Resources
aws-cdk-aws-servicediscovery — pip install aws-cdk-aws-servicediscovery · libregistry