AWS SDK Version 3 for .NET
API Reference

AWS services or capabilities described in AWS Documentation may vary by region/location. Click Getting Started with Amazon AWS to see specific differences applicable to the China (Beijing) Region.

Associates an Amazon VPC with a private hosted zone.

To perform the association, the VPC and the private hosted zone must already exist. You can't convert a public hosted zone into a private hosted zone.

If you want to associate a VPC that was created by using one Amazon Web Services account with a private hosted zone that was created by using a different account, the Amazon Web Services account that created the private hosted zone must first submit a CreateVPCAssociationAuthorization request. Then the account that created the VPC must submit an AssociateVPCWithHostedZone request.

When granting 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.

Note:

For .NET Core this operation is only available in asynchronous form. Please refer to AssociateVPCWithHostedZoneAsync.

Namespace: Amazon.Route53
Assembly: AWSSDK.Route53.dll
Version: 3.x.y.z

Syntax

C#
public abstract AssociateVPCWithHostedZoneResponse AssociateVPCWithHostedZone(
         AssociateVPCWithHostedZoneRequest request
)

Parameters

request
Type: Amazon.Route53.Model.AssociateVPCWithHostedZoneRequest

Container for the necessary parameters to execute the AssociateVPCWithHostedZone service method.

Return Value


The response from the AssociateVPCWithHostedZone service method, as returned by Route53.

Exceptions

ExceptionCondition
ConflictingDomainExistsException The cause of this error depends on the operation that you're performing: Create a public hosted zone: Two hosted zones that have the same name or that have a parent/child relationship (example.com and test.example.com) can't have any common name servers. You tried to create a hosted zone that has the same name as an existing hosted zone or that's the parent or child of an existing hosted zone, and you specified a delegation set that shares one or more name servers with the existing hosted zone. For more information, see CreateReusableDelegationSet. Create a private hosted zone: A hosted zone with the specified name already exists and is already associated with the Amazon VPC that you specified. Associate VPCs with a private hosted zone: The VPC that you specified is already associated with another hosted zone that has the same name.
InvalidInputException The input is not valid.
InvalidVPCIdException The VPC ID that you specified either isn't a valid ID or the current account is not authorized to access this VPC.
LimitsExceededException This operation can't be completed because the current account has reached the limit on the resource you are trying to create. To request a higher limit, create a case with the Amazon Web Services Support Center.
NoSuchHostedZoneException No hosted zone exists with the ID that you specified.
NotAuthorizedException Associating the specified VPC with the specified hosted zone has not been authorized.
PriorRequestNotCompleteException If Amazon Route 53 can't process a request before the next request arrives, it will reject subsequent requests for the same hosted zone and return an HTTP 400 error (Bad request). If Route 53 returns this error repeatedly for the same request, we recommend that you wait, in intervals of increasing duration, before you try the request again.
PublicZoneVPCAssociationException You're trying to associate a VPC with a public hosted zone. Amazon Route 53 doesn't support associating a VPC with a public hosted zone.

Examples

The following example associates the VPC with ID vpc-1a2b3c4d with the hosted zone with ID Z3M3LMPEXAMPLE.

To associate a VPC with a hosted zone


var client = new AmazonRoute53Client();
var response = client.AssociateVPCWithHostedZone(new AssociateVPCWithHostedZoneRequest 
{
    Comment = "",
    HostedZoneId = "Z3M3LMPEXAMPLE",
    VPC = new VPC {
        VPCId = "vpc-1a2b3c4d",
        VPCRegion = "us-east-2"
    }
});

ChangeInfo changeInfo = response.ChangeInfo;

            

Version Information

.NET Framework:
Supported in: 4.5, 4.0, 3.5

See Also