internal void CreatedHostedZone(string p) { CreateHostedZoneResponse resp = route53.CreateHostedZone(new CreateHostedZoneRequest() .WithName(p) .WithCallerReference("zawscc" + new Random().Next(1000).ToString()) ); }
public override AmazonWebServiceResponse Unmarshall(XmlUnmarshallerContext context) { CreateHostedZoneResponse response = new CreateHostedZoneResponse(); UnmarshallResult(context, response); if (context.ResponseData.IsHeaderPresent("Location")) { response.Location = context.ResponseData.GetHeaderValue("Location"); } return(response); }
private async Task <CreateHostedZoneResponse> createAwsHostedZoneAsync(string zoneName) { logger.LogInformation($"Creating hosted zone '{ zoneName }'..."); CreateHostedZoneRequest request = new CreateHostedZoneRequest { CallerReference = zoneName, Name = zoneName }; CreateHostedZoneResponse zone = await TheRoute53Client().CreateHostedZoneAsync(request); return(zone); }
private static void UnmarshallResult(XmlUnmarshallerContext context, CreateHostedZoneResponse response) { int originalDepth = context.CurrentDepth; int targetDepth = originalDepth + 1; if (context.IsStartOfDocument) { targetDepth += 2; } while (context.Read()) { if (context.IsStartElement || context.IsAttribute) { if (context.TestExpression("HostedZone", targetDepth)) { response.HostedZone = HostedZoneUnmarshaller.GetInstance().Unmarshall(context); continue; } if (context.TestExpression("ChangeInfo", targetDepth)) { response.ChangeInfo = ChangeInfoUnmarshaller.GetInstance().Unmarshall(context); continue; } if (context.TestExpression("DelegationSet", targetDepth)) { response.DelegationSet = DelegationSetUnmarshaller.GetInstance().Unmarshall(context); continue; } } else if (context.IsEndElement && context.CurrentDepth < originalDepth) { return; } } IWebResponseData responseData = context.ResponseData; if (responseData.IsHeaderPresent("Location")) { response.Location = responseData.GetHeaderValue("Location"); } return; }
public override AmazonWebServiceResponse Unmarshall(XmlUnmarshallerContext context) { CreateHostedZoneResponse response = new CreateHostedZoneResponse(); while (context.Read()) { if (context.IsStartElement) { response.CreateHostedZoneResult = CreateHostedZoneResultUnmarshaller.GetInstance().Unmarshall(context); break; } } return(response); }
private static void UnmarshallResult(XmlUnmarshallerContext context, CreateHostedZoneResponse response) { int originalDepth = context.CurrentDepth; int targetDepth = originalDepth + 1; if (context.IsStartOfDocument) { targetDepth += 1; } while (context.Read()) { if (context.IsStartElement || context.IsAttribute) { if (context.TestExpression("HostedZone", targetDepth)) { var unmarshaller = HostedZoneUnmarshaller.Instance; response.HostedZone = unmarshaller.Unmarshall(context); continue; } if (context.TestExpression("ChangeInfo", targetDepth)) { var unmarshaller = ChangeInfoUnmarshaller.Instance; response.ChangeInfo = unmarshaller.Unmarshall(context); continue; } if (context.TestExpression("DelegationSet", targetDepth)) { var unmarshaller = DelegationSetUnmarshaller.Instance; response.DelegationSet = unmarshaller.Unmarshall(context); continue; } if (context.TestExpression("VPC", targetDepth)) { var unmarshaller = VPCUnmarshaller.Instance; response.VPC = unmarshaller.Unmarshall(context); continue; } } else if (context.IsEndElement && context.CurrentDepth < originalDepth) { return; } } return; }
/// <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(""); } }
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(); }