Creating Namespaces - Amazon Cloud Map
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China (PDF).

Creating Namespaces

To create a namespace, perform the following procedure.

Amazon Web Services Management Console
  1. Sign in to the Amazon Web Services Management Console and open the Amazon Cloud Map console at https://console.amazonaws.cn/cloudmap/.

  2. Choose Create namespace.

  3. On the Create namespace page, enter the applicable values. For more information, see Values That You Specify When You Create Namespaces.

  4. 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 a DiscoverInstances 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 a DiscoverInstances request or using DNS

      aws servicediscovery create-private-dns-namespace --name name-of-namespace --vpc vpc-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 a DiscoverInstances 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)
  1. If you don't already have Boto3 installed, you can find instructions for installing, configuring, and using Boto3 here.

  2. Import Boto3 and use servicediscovery as your service.

    import boto3 client = boto3.client('servicediscovery')
  3. 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 discover_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 either discover_instances() or using DNS

      response = 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 either discover_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).