Skip to content

disassociate_vpc_from_hosted_zone async

disassociate_vpc_from_hosted_zone(
    hosted_zone_id: ResourceId,
    vpc: VPC,
    *,
    config_overrides: Optional[AsyncRoute53ClientConfig] = None,
    comment: Optional[DisassociateVPCComment] = None,
) -> DisassociateVPCFromHostedZoneResponse

Disassociates an Amazon Virtual Private Cloud (Amazon VPC) from an Amazon Route 53 private hosted zone. Note the following:

  • You can't disassociate the last Amazon VPC from a private hosted zone.

  • You can't convert a private hosted zone into a public hosted zone.

  • You can submit a DisassociateVPCFromHostedZone request using either the account that created the hosted zone or the account that created the Amazon VPC.

  • Some services, such as Cloud Map and Amazon Elastic File System (Amazon EFS) automatically create hosted zones and associate VPCs with the hosted zones. A service can create a hosted zone using your account or using its own account. You can disassociate a VPC from a hosted zone only if the service created the hosted zone using your account.

    When you run DisassociateVPCFromHostedZone, if the hosted zone has a value for OwningAccount, you can use DisassociateVPCFromHostedZone. If the hosted zone has a value for OwningService, you can't use DisassociateVPCFromHostedZone.

When revoking access, the hosted zone and the Amazon VPC must belong to the same partition. A partition is a group of Amazon Web Services Regions. Each Amazon Web Services account is scoped to one partition.

The following are the supported partitions:

  • aws - Amazon Web Services Regions

  • aws-cn - China Regions

  • aws-us-gov - Amazon Web Services GovCloud (US) Region

For more information, see Access Management in the Amazon Web Services General Reference.

Parameters:

  • hosted_zone_id (ResourceId) –

    The ID of the private hosted zone that you want to disassociate a VPC from.

  • vpc (VPC) –

    A complex type that contains information about the VPC that you're disassociating from the specified hosted zone.

  • comment (Optional[DisassociateVPCComment], default: None ) –

    Optional: A comment about the disassociation request.

Raises:

  • InvalidInput –

    The input is not valid.

  • InvalidVPCId –

    The VPC ID that you specified either isn't a valid ID or the current account is not authorized to access this VPC.

  • LastVPCAssociation –

    The VPC that you're trying to disassociate from the private hosted zone is the last VPC that is associated with the hosted zone. Amazon Route 53 doesn't support disassociating the last VPC from a hosted zone.

  • NoSuchHostedZone –

    No hosted zone exists with the ID that you specified.

  • VPCAssociationNotFound –

    The specified VPC and hosted zone are not currently associated.

  • UnknownServiceError –

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

Source code in docs_src/capo_route_53/_services/async_route53.py
async def disassociate_vpc_from_hosted_zone(
    self,
    hosted_zone_id: "capo_route_53.types.resource_id.ResourceId",
    vpc: "capo_route_53.types.vpc.VPC",
    *,
    config_overrides: Optional[AsyncRoute53ClientConfig] = None,
    comment: Optional[
        "capo_route_53.types.disassociate_vpc_comment.DisassociateVPCComment"
    ] = None,
) -> "capo_route_53.types.disassociate_vpc_from_hosted_zone_response.DisassociateVPCFromHostedZoneResponse":
    """<p>Disassociates an Amazon Virtual Private Cloud (Amazon VPC) from an Amazon Route 53 private hosted zone. Note the following:</p> <ul> <li> <p>You can't disassociate the last Amazon VPC from a private hosted zone.</p> </li> <li> <p>You can't convert a private hosted zone into a public hosted zone.</p> </li> <li> <p>You can submit a <code>DisassociateVPCFromHostedZone</code> request using either the account that created the hosted zone or the account that created the Amazon VPC.</p> </li> <li> <p>Some services, such as Cloud Map and Amazon Elastic File System (Amazon EFS) automatically create hosted zones and associate VPCs with the hosted zones. A service can create a hosted zone using your account or using its own account. You can disassociate a VPC from a hosted zone only if the service created the hosted zone using your account.</p> <p>When you run <a href="https://docs.aws.amazon.com/Route53/latest/APIReference/API_ListHostedZonesByVPC.html">DisassociateVPCFromHostedZone</a>, if the hosted zone has a value for <code>OwningAccount</code>, you can use <code>DisassociateVPCFromHostedZone</code>. If the hosted zone has a value for <code>OwningService</code>, you can't use <code>DisassociateVPCFromHostedZone</code>.</p> </li> </ul> <note> <p>When revoking access, the hosted zone and the Amazon VPC must belong to the same partition. A partition is a group of Amazon Web Services Regions. Each Amazon Web Services account is scoped to one partition.</p> <p>The following are the supported partitions:</p> <ul> <li> <p> <code>aws</code> - Amazon Web Services Regions</p> </li> <li> <p> <code>aws-cn</code> - China Regions</p> </li> <li> <p> <code>aws-us-gov</code> - Amazon Web Services GovCloud (US) Region</p> </li> </ul> <p>For more information, see <a href="https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html">Access Management</a> in the <i>Amazon Web Services General Reference</i>.</p> </note>

    Args:
        hosted_zone_id: <p>The ID of the private hosted zone that you want to disassociate a VPC from.</p>
        vpc: <p>A complex type that contains information about the VPC that you're disassociating from the specified hosted zone.</p>
        comment: <p> <i>Optional:</i> A comment about the disassociation request.</p>

    Raises:
        capo_route_53.errors.invalid_input.InvalidInput: <p>The input is not valid.</p>
        capo_route_53.errors.invalid_vpc_id.InvalidVPCId: <p>The VPC ID that you specified either isn't a valid ID or the current account is not authorized to access this VPC.</p>
        capo_route_53.errors.last_vpc_association.LastVPCAssociation: <p>The VPC that you're trying to disassociate from the private hosted zone is the last VPC that is associated with the hosted zone. Amazon Route 53 doesn't support disassociating the last VPC from a hosted zone.</p>
        capo_route_53.errors.no_such_hosted_zone.NoSuchHostedZone: <p>No hosted zone exists with the ID that you specified.</p>
        capo_route_53.errors.vpc_association_not_found.VPCAssociationNotFound: <p>The specified VPC and hosted zone are not currently associated.</p>
        capo_route_53.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_route_53.types.disassociate_vpc_from_hosted_zone_request.DisassociateVPCFromHostedZoneRequest]",
    ) -> AsyncOperationResponse[
        "capo_route_53.types.disassociate_vpc_from_hosted_zone_response.DisassociateVPCFromHostedZoneResponse"
    ]:
        import capo_route_53._operations.aws_dns_v20130401.disassociate_vpc_from_hosted_zone

        (
            output,
            http_response,
        ) = await capo_route_53._operations.aws_dns_v20130401.disassociate_vpc_from_hosted_zone.async_disassociate_vpc_from_hosted_zone(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("DisassociateVPCFromHostedZone")
    )
    input_: capo_route_53.types.disassociate_vpc_from_hosted_zone_request.DisassociateVPCFromHostedZoneRequest = {
        "hosted_zone_id": hosted_zone_id,
        "vpc": vpc,
    }
    if comment is not None:
        input_["comment"] = comment

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