Amazon.Route53.AmazonRoute53Client.ChangeResourceRecordSets C# (CSharp) Метод

ChangeResourceRecordSets() публичный Метод

Create, change, update, or delete authoritative DNS information on all Amazon Route 53 servers. Send a POST request to:

/2013-04-01/hostedzone/Amazon Route 53 hosted Zone ID/rrset resource.

The request body must include a document with a ChangeResourceRecordSetsRequest element. The request body contains a list of change items, known as a change batch. Change batches are considered transactional changes. When using the Amazon Route 53 API to change resource record sets, Amazon Route 53 either makes all or none of the changes in a change batch request. This ensures that Amazon Route 53 never partially implements the intended changes to the resource record sets in a hosted zone.

For example, a change batch request that deletes the CNAME record for www.example.com and creates an alias resource record set for www.example.com. Amazon Route 53 deletes the first resource record set and creates the second resource record set in a single operation. If either the DELETE or the CREATE action fails, then both changes (plus any other changes in the batch) fail, and the original CNAME record continues to exist.

Due to the nature of transactional changes, you can't delete the same resource record set more than once in a single change batch. If you attempt to delete the same change batch more than once, Amazon Route 53 returns an InvalidChangeBatch error.

To create resource record sets for complex routing configurations, use either the traffic flow visual editor in the Amazon Route 53 console or the API actions for traffic policies and traffic policy instances. Save the configuration as a traffic policy, then associate the traffic policy with one or more domain names (such as example.com) or subdomain names (such as www.example.com), in the same hosted zone or in multiple hosted zones. You can roll back the updates if the new configuration isn't performing as expected. For more information, see Using Traffic Flow to Route DNS Traffic in the Amazon Route 53 Developer Guide.

Use ChangeResourceRecordsSetsRequest to perform the following actions:

  • CREATE: Creates a resource record set that has the specified values.

  • DELETE: Deletes an existing resource record set that has the specified values.

  • UPSERT: If a resource record set does not already exist, AWS creates it. If a resource set does exist, Amazon Route 53 updates it with the values in the request.

The values that you need to include in the request depend on the type of resource record set that you're creating, deleting, or updating:

Basic resource record sets (excluding alias, failover, geolocation, latency, and weighted resource record sets)

  • Name

  • Type

  • TTL

Failover, geolocation, latency, or weighted resource record sets (excluding alias resource record sets)

  • Name

  • Type

  • TTL

  • SetIdentifier

Alias resource record sets (including failover alias, geolocation alias, latency alias, and weighted alias resource record sets)

  • Name

  • Type

  • AliasTarget (includes DNSName, EvaluateTargetHealth, and HostedZoneId)

  • SetIdentifier (for failover, geolocation, latency, and weighted resource record sets)

When you submit a ChangeResourceRecordSets request, Amazon Route 53 propagates your changes to all of the Amazon Route 53 authoritative DNS servers. While your changes are propagating, GetChange returns a status of PENDING. When propagation is complete, GetChange returns a status of INSYNC. Changes generally propagate to all Amazon Route 53 name servers in a few minutes. In rare circumstances, propagation can take up to 30 minutes. For more information, see GetChange

For information about the limits on a ChangeResourceRecordSets request, see Limits in the Amazon Route 53 Developer Guide.

/// This exception contains a list of messages that might contain one or more error messages. /// Each error message indicates one error in the change batch. /// /// The input is not valid. /// /// No health check exists with the ID that you specified in the DeleteHealthCheck /// request. /// /// No hosted zone exists with the ID that you specified. /// /// 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 Amazon 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. ///
public ChangeResourceRecordSets ( ChangeResourceRecordSetsRequest request ) : ChangeResourceRecordSetsResponse
request ChangeResourceRecordSetsRequest Container for the necessary parameters to execute the ChangeResourceRecordSets service method.
Результат ChangeResourceRecordSetsResponse
        public ChangeResourceRecordSetsResponse ChangeResourceRecordSets(ChangeResourceRecordSetsRequest request)
        {
            var marshaller = new ChangeResourceRecordSetsRequestMarshaller();
            var unmarshaller = ChangeResourceRecordSetsResponseUnmarshaller.Instance;

            return Invoke<ChangeResourceRecordSetsRequest,ChangeResourceRecordSetsResponse>(request, marshaller, unmarshaller);
        }

Usage Example

Пример #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