Skip to content

create_private_dns_namespace async

create_private_dns_namespace(
    name: NamespaceNamePrivate,
    vpc: ResourceId,
    *,
    config_overrides: Optional[AsyncServiceDiscoveryClientConfig] = None,
    creator_request_id: Optional[ResourceId] = None,
    description: Optional[ResourceDescription] = None,
    tags: Optional[TagList] = None,
    properties: Optional[PrivateDnsNamespaceProperties] = None,
) -> CreatePrivateDnsNamespaceResponse

Creates a private namespace based on DNS, which is visible only inside a specified Amazon VPC. The namespace defines your service naming scheme. For example, if you name your namespace example.com and name your service backend, the resulting DNS name for the service is backend.example.com. Service instances that are registered using a private DNS namespace can be discovered using either a DiscoverInstances request or using DNS. For the current quota on the number of namespaces that you can create using the same Amazon Web Services account, see Cloud Map quotas in the Cloud Map Developer Guide.

Parameters:

  • name (NamespaceNamePrivate) –

    The name that you want to assign to this namespace. When you create a private DNS namespace, Cloud Map automatically creates an Amazon Route 53 private hosted zone that has the same name as the namespace.

  • creator_request_id (Optional[ResourceId], default: None ) –

    A unique string that identifies the request and that allows failed CreatePrivateDnsNamespace requests to be retried without the risk of running the operation twice. CreatorRequestId can be any unique string (for example, a date/timestamp).

  • description (Optional[ResourceDescription], default: None ) –

    A description for the namespace.

  • vpc (ResourceId) –

    The ID of the Amazon VPC that you want to associate the namespace with.

  • tags (Optional[TagList], default: None ) –

    The tags to add to the namespace. Each tag consists of a key and an optional value that you define. Tags keys can be up to 128 characters in length, and tag values can be up to 256 characters in length.

  • properties (Optional[PrivateDnsNamespaceProperties], default: None ) –

    Properties for the private DNS namespace.

Raises:

  • DuplicateRequest –

    The operation is already in progress.

  • InvalidInput –

    One or more specified values aren't valid. For example, a required value might be missing, a numeric value might be outside the allowed range, or a string value might exceed length constraints.

  • NamespaceAlreadyExists –

    The namespace that you're trying to create already exists.

  • ResourceLimitExceeded –

    The resource can't be created because you've reached the quota on the number of resources.

  • TooManyTagsException –

    The list of tags on the resource is over the quota. The maximum number of tags that can be applied to a resource is 50.

  • UnknownServiceError –

    The service returned an error code this client does not model.

Examples:

Example: Create private DNS namespace Example: Create private DNS namespace

>>> await client.create_private_dns_namespace(name='example.com', vpc='vpc-1c56417b', creator_request_id='eedd6892-50f3-41b2-8af9-611d6e1d1a8c')
Source code in docs_src/capo_servicediscovery/_services/async_service_discovery.py
async def create_private_dns_namespace(
    self,
    name: "capo_servicediscovery.types.namespace_name_private.NamespaceNamePrivate",
    vpc: "capo_servicediscovery.types.resource_id.ResourceId",
    *,
    config_overrides: Optional[AsyncServiceDiscoveryClientConfig] = None,
    creator_request_id: Optional[
        "capo_servicediscovery.types.resource_id.ResourceId"
    ] = None,
    description: Optional[
        "capo_servicediscovery.types.resource_description.ResourceDescription"
    ] = None,
    tags: Optional["capo_servicediscovery.types.tag_list.TagList"] = None,
    properties: Optional[
        "capo_servicediscovery.types.private_dns_namespace_properties.PrivateDnsNamespaceProperties"
    ] = None,
) -> "capo_servicediscovery.types.create_private_dns_namespace_response.CreatePrivateDnsNamespaceResponse":
    """<p>Creates a private namespace based on DNS, which is visible only inside a specified Amazon VPC. The namespace defines your service naming scheme. For example, if you name your namespace <code>example.com</code> and name your service <code>backend</code>, the resulting DNS name for the service is <code>backend.example.com</code>. Service instances that are registered using a private DNS namespace can be discovered using either a <code>DiscoverInstances</code> request or using DNS. For the current quota on the number of namespaces that you can create using the same Amazon Web Services account, see <a href="https://docs.aws.amazon.com/cloud-map/latest/dg/cloud-map-limits.html">Cloud Map quotas</a> in the <i>Cloud Map Developer Guide</i>.</p>

    Args:
        name: <p>The name that you want to assign to this namespace. When you create a private DNS namespace, Cloud Map automatically creates an Amazon Route 53 private hosted zone that has the same name as the namespace.</p>
        creator_request_id: <p>A unique string that identifies the request and that allows failed <code>CreatePrivateDnsNamespace</code> requests to be retried without the risk of running the operation twice. <code>CreatorRequestId</code> can be any unique string (for example, a date/timestamp).</p>
        description: <p>A description for the namespace.</p>
        vpc: <p>The ID of the Amazon VPC that you want to associate the namespace with.</p>
        tags: <p>The tags to add to the namespace. Each tag consists of a key and an optional value that you define. Tags keys can be up to 128 characters in length, and tag values can be up to 256 characters in length.</p>
        properties: <p>Properties for the private DNS namespace.</p>

    Raises:
        capo_servicediscovery.errors.duplicate_request.DuplicateRequest: <p>The operation is already in progress.</p>
        capo_servicediscovery.errors.invalid_input.InvalidInput: <p>One or more specified values aren't valid. For example, a required value might be missing, a numeric value might be outside the allowed range, or a string value might exceed length constraints.</p>
        capo_servicediscovery.errors.namespace_already_exists.NamespaceAlreadyExists: <p>The namespace that you're trying to create already exists.</p>
        capo_servicediscovery.errors.resource_limit_exceeded.ResourceLimitExceeded: <p>The resource can't be created because you've reached the quota on the number of resources.</p>
        capo_servicediscovery.errors.too_many_tags_exception.TooManyTagsException: <p>The list of tags on the resource is over the quota. The maximum number of tags that can be applied to a resource is 50.</p>
        capo_servicediscovery.errors.UnknownServiceError: The service returned an error code this client does not model.

    Examples:
        Example: Create private DNS namespace
        Example: Create private DNS namespace

        >>> await client.create_private_dns_namespace(name='example.com', vpc='vpc-1c56417b', creator_request_id='eedd6892-50f3-41b2-8af9-611d6e1d1a8c')
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_servicediscovery.types.create_private_dns_namespace_request.CreatePrivateDnsNamespaceRequest]",
    ) -> AsyncOperationResponse[
        "capo_servicediscovery.types.create_private_dns_namespace_response.CreatePrivateDnsNamespaceResponse"
    ]:
        import capo_servicediscovery._operations.route53_auto_naming_v20170314.create_private_dns_namespace

        (
            output,
            http_response,
        ) = await capo_servicediscovery._operations.route53_auto_naming_v20170314.create_private_dns_namespace.async_create_private_dns_namespace(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("CreatePrivateDnsNamespace")
    )
    input_: capo_servicediscovery.types.create_private_dns_namespace_request.CreatePrivateDnsNamespaceRequest = {
        "name": name,
        "vpc": vpc,
    }
    if creator_request_id is None:
        creator_request_id = str(uuid.uuid4())
    input_["creator_request_id"] = creator_request_id
    if description is not None:
        input_["description"] = description
    if tags is not None:
        input_["tags"] = tags
    if properties is not None:
        input_["properties"] = properties

    response = await aexecute_pipeline(
        AsyncOperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    await response.response.aclose()
    return response.output