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.

Creates a new public or private hosted zone. You create records in a public hosted zone to define how you want to route traffic on the internet for a domain, such as example.com, and its subdomains (apex.example.com, acme.example.com). You create records in a private hosted zone to define how you want to route traffic for a domain and its subdomains within one or more Amazon Virtual Private Clouds (Amazon VPCs).

You can't convert a public hosted zone to a private hosted zone or vice versa. Instead, you must create a new hosted zone with the same name and create new resource record sets.

For more information about charges for hosted zones, see Amazon Route 53 Pricing.

Note the following:

When you submit a CreateHostedZone request, the initial status of the hosted zone is PENDING. For public hosted zones, this means that the NS and SOA records are not yet available on all Route 53 DNS servers. When the NS and SOA records are available, the status of the zone changes to INSYNC.

The CreateHostedZone request requires the caller to have an ec2:DescribeVpcs permission.

When creating private hosted zones, the Amazon VPC must belong to the same partition where the hosted zone is created. 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 CreateHostedZoneAsync.

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

Syntax

C#
public virtual CreateHostedZoneResponse CreateHostedZone(
         CreateHostedZoneRequest request
)

Parameters

request
Type: Amazon.Route53.Model.CreateHostedZoneRequest

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

Return Value


The response from the CreateHostedZone 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.
DelegationSetNotAvailableException You can create a hosted zone that has the same name as an existing hosted zone (example.com is common), but there is a limit to the number of hosted zones that have the same name. If you get this error, Amazon Route 53 has reached that limit. If you own the domain name and Route 53 generates this error, contact Customer Support.
DelegationSetNotReusableException A reusable delegation set with the specified ID does not exist.
HostedZoneAlreadyExistsException The hosted zone you're trying to create already exists. Amazon Route 53 returns this error when a hosted zone has already been created with the specified CallerReference.
InvalidDomainNameException The specified domain name is not valid.
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.
NoSuchDelegationSetException A reusable delegation set with the specified ID does not exist.
TooManyHostedZonesException This operation can't be completed either because the current account has reached the limit on the number of hosted zones or because you've reached the limit on the number of hosted zones that can be associated with a reusable delegation set. For information about default limits, see Limits in the Amazon Route 53 Developer Guide. To get the current limit on hosted zones that can be created by an account, see GetAccountLimit. To get the current limit on hosted zones that can be associated with a reusable delegation set, see GetReusableDelegationSetLimit. To request a higher limit, create a case with the Amazon Web Services Support Center.

Examples

This example shows how to create an Amazon Route 53 hosted zone and add a resource record set to the zone.

Create a hosted zone and add a resource record set

string domainName = "www.example.org";

IAmazonRoute53 route53Client = new AmazonRoute53Client();

CreateHostedZoneRequest zoneRequest = new CreateHostedZoneRequest
{
  Name = domainName,
  CallerReference = "my_change_request"
};

CreateHostedZoneResponse zoneResponse = route53Client.CreateHostedZone(zoneRequest);

ResourceRecordSet recordSet = new ResourceRecordSet
{
  Name = domainName,
  TTL = 60,
  Type = RRType.A,
  ResourceRecords = new List<ResourceRecord> { new ResourceRecord { Value = "192.0.2.235" } }
};

Change change1 = new Change
{
  ResourceRecordSet = recordSet,
  Action = ChangeAction.CREATE
};

ChangeBatch changeBatch = new ChangeBatch
{
  Changes = new List<Change> { change1 }
};

ChangeResourceRecordSetsRequest recordsetRequest = new ChangeResourceRecordSetsRequest
{
  HostedZoneId = zoneResponse.HostedZone.Id,
  ChangeBatch = changeBatch
};

ChangeResourceRecordSetsResponse recordsetResponse = route53Client.ChangeResourceRecordSets(recordsetRequest);

GetChangeRequest changeRequest = new GetChangeRequest
{
  Id = recordsetResponse.ChangeInfo.Id
};

while (route53Client.GetChange(changeRequest).ChangeInfo.Status == ChangeStatus.PENDING)
{
  Console.WriteLine("Change is pending.");
  Thread.Sleep(TimeSpan.FromSeconds(15));
}
      

Version Information

.NET Framework:
Supported in: 4.5 and newer, 3.5

See Also