Creating Namespaces
To create a namespace, perform the following procedure.
- Amazon Web Services Management Console
-
Sign in to the Amazon Web Services Management Console and open the Amazon Cloud Map console at https://console.amazonaws.cn/cloudmap/
. -
Choose Create namespace.
-
On the Create namespace page, enter the applicable values. For more information, see Values That You Specify When You Create Namespaces.
-
Choose Create namespace.
- Amazon CLI
-
-
Create a namespace with the command for the instance discovery type you would prefer (replace the
red
values with your own).-
Create an HTTP namespace using
create-http-namespace
. Service instances registered using an HTTP namespace can be discovered using aDiscoverInstances
request, but they can't be discovered using DNS.aws servicediscovery create-http-namespace --name
name-of-namespace
-
Create a private namespace based on DNS and only visible inside a specified Amazon VPC using
create-private-dns-namespace
. You can discover instances that were registered with a private DNS namespace by using either aDiscoverInstances
request or using DNSaws servicediscovery create-private-dns-namespace --name
name-of-namespace
--vpcvpc-xxxxxxxxx
-
Create a public namespace based on DNS that is visible on the internet using
create-public-dns-namespace
. You can discover instances that were registered with a public DNS namespace by using either aDiscoverInstances
request or using DNS.aws servicediscovery create-public-dns-namespace --name
name-of-namespace
Note Namespace requirements:
-
Namespaces configured for public DNS queries must end with a top level domain (e.g .com).
-
The namespace name can have up to 1,024 characters, and must start and end with a letter.
-
Valid characters: a-z, A-Z, 0-9, . (period), _ (underscore), and - (hyphen).
-
-
-
- Amazon SDK for Python (Boto3)
-
-
If you don't already have
Boto3
installed, you can find instructions for installing, configuring, and usingBoto3
here. -
Import
Boto3
and useservicediscovery
as your service.import boto3 client = boto3.client('servicediscovery')
-
Create a namespace with the command for the instance discovery type you would prefer (replace the
red
values with your own):-
Create an HTTP namespace using
create_http_namespace()
. Service instances registered using an HTTP namespace can be discovered usingdiscover_instances()
, but they can't be discovered using DNS.response = client.create_http_namespace( Name='
name-of-namespace
', ) # If you want to see the response print(response) -
Create a private namespace based on DNS and only visible inside a specified Amazon VPC using
create_private_dns_namespace()
. You can discover instances that were registered with a private DNS namespace by using eitherdiscover_instances()
or using DNSresponse = client.create_private_dns_namespace( Name='
name-of-namespace
', Vpc='vpc-1c56417b
', ) # If you want to see the response print(response) -
Create a public namespace based on DNS that is visible on the internet using
create_public_dns_namespace()
. You can discover instances that were registered with a public DNS namespace by using eitherdiscover_instances()
or using DNS.response = client.create_public_dns_namespace( Name='
name-of-namespace
', ) # If you want to see the response print(response) -
Example response output
{ 'OperationId': 'gv4g5meo7ndmeh4fqskygvk23d2fijwa-k9302yzd', 'ResponseMetadata': { '...': '...', }, }
Note Namespace requirements:
-
Namespaces configured for public DNS queries must end with a top level domain (e.g .com).
-
The namespace name can have up to 1,024 characters, and must start and end with a letter.
-
Valid characters: a-z, A-Z, 0-9, . (period), _ (underscore), and - (hyphen).
-
-
-