Amazon.Route53.AmazonRoute53Client.CreateHostedZone C# (CSharp) Méthode

CreateHostedZone() public méthode

Creates a new public hosted zone, used to specify how the Domain Name System (DNS) routes traffic on the Internet for a domain, such as example.com, and its subdomains.

Public hosted zones can't be converted to a private hosted zone or vice versa. Instead, create a new hosted zone with the same name and create new resource record sets.

Send a POST request to the /2013-04-01/hostedzone resource. The request body must include a document with a CreateHostedZoneRequest element. The response returns the CreateHostedZoneResponse element containing metadata about the hosted zone.

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

Note the following:

  • You can't create a hosted zone for a top-level domain (TLD).

  • Amazon Route 53 automatically creates a default SOA record and four NS records for the zone. For more information about SOA and NS records, see NS and SOA Records that Amazon Route 53 Creates for a Hosted Zone in the Amazon Route 53 Developer Guide.

  • If your domain is registered with a registrar other than Amazon Route 53, you must update the name servers with your registrar to make Amazon Route 53 your DNS service. For more information, see Configuring Amazon Route 53 as your DNS Service in the Amazon Route 53 Developer's Guide.

After creating a zone, its initial status is PENDING. This means that it is not yet available on all DNS servers. The status of the zone changes to INSYNC when the NS and SOA records are available on all Amazon Route 53 DNS servers.

When trying to create a hosted zone using a reusable delegation set, specify an optional DelegationSetId, and Amazon Route 53 would assign those 4 NS records for the zone, instead of allotting a new one.

/// You specified an Amazon VPC that you're already using for another hosted zone, and /// the domain that you specified for one of the hosted zones is a subdomain of the domain /// that you specified for the other hosted zone. For example, you can't use the same /// Amazon VPC for the hosted zones for example.com and test.example.com. /// /// 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 Amazon Route 53 generates this error, contact Customer Support. /// /// A reusable delegation set with the specified ID does not exist. /// /// The hosted zone you are trying to create already exists. Amazon Route 53 returns this /// error when a hosted zone has already been created with the specified CallerReference. /// /// The specified domain name is not valid. /// /// The input is not valid. /// /// The VPC ID that you specified either isn't a valid ID or the current account is not /// authorized to access this VPC. /// /// A reusable delegation set with the specified ID does not exist. /// /// This hosted zone can't be created because the hosted zone limit is exceeded. To request /// a limit increase, go to the Amazon Route 53 Contact /// Us page. ///
public CreateHostedZone ( CreateHostedZoneRequest request ) : CreateHostedZoneResponse
request CreateHostedZoneRequest Container for the necessary parameters to execute the CreateHostedZone service method.
Résultat CreateHostedZoneResponse
        public CreateHostedZoneResponse CreateHostedZone(CreateHostedZoneRequest request)
        {
            var marshaller = new CreateHostedZoneRequestMarshaller();
            var unmarshaller = CreateHostedZoneResponseUnmarshaller.Instance;

            return Invoke<CreateHostedZoneRequest,CreateHostedZoneResponse>(request, marshaller, unmarshaller);
        }

Usage Example

Exemple #1
0
    public static void Route53CreateAdd(string[] args)
    {
      #region Route53CreateAdd
      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));
      }
      #endregion

      Console.WriteLine("Change is complete.");
      Console.ReadKey();
    }
AmazonRoute53Client