Esempio n. 1
0
        /// <summary>
        /// Create a new hosted zone. When you create 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 Route 53 DNS servers.
        /// </summary>
        /// <param name="domain">The name of the domain</param>
        /// <param name="vpc">The VPC that you want your hosted zone to be associated with. By providing this parameter, your newly created hosted cannot be resolved anywhere other than the given VPC.</param>
        /// <param name="region">The region of your VPC</param>
        /// <param name="settings">The <see cref="Route53Settings"/> required to connect to Route53.</param>
        /// <param name="cancellationToken">A cancellation token that can be used by other objects or threads to receive notice of cancellation.</param>
        public async Task <string> CreateHostedZone(string domain, string vpc, VPCRegion region, Route53Settings settings, CancellationToken cancellationToken = default(CancellationToken))
        {
            if (String.IsNullOrEmpty(domain))
            {
                throw new ArgumentNullException("domain");
            }



            CreateHostedZoneRequest request = new CreateHostedZoneRequest(domain, "");

            if (!String.IsNullOrEmpty(vpc))
            {
                request.VPC = new VPC()
                {
                    VPCId     = vpc,
                    VPCRegion = region
                };
            }

            AmazonRoute53Client      client   = this.GetClient(settings);
            CreateHostedZoneResponse response = await client.CreateHostedZoneAsync(request);

            if (response.HttpStatusCode == HttpStatusCode.OK)
            {
                await this.WaitForChange(client, response.ChangeInfo.Id, 10000, 60);

                _Log.Verbose("Created hosted zone");
                return(response.HostedZone.Id);
            }
            else
            {
                _Log.Error("Could not create hosted zone");
                return("");
            }
        }