change_resource_record_sets
async
¶
change_resource_record_sets(
hosted_zone_id: ResourceId,
change_batch: ChangeBatch,
*,
config_overrides: Optional[AsyncRoute53ClientConfig] = None,
) -> ChangeResourceRecordSetsResponse
Creates, changes, or deletes a resource record set, which contains authoritative DNS information for a specified domain name or subdomain name. For example, you can use ChangeResourceRecordSets to create a resource record set that routes traffic for test.example.com to a web server that has an IP address of 192.0.2.44.
Deleting Resource Record Sets
To delete a resource record set, you must specify all the same values that you specified when you created it.
Change Batches and Transactional Changes
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. Route 53 validates the changes in the request and then either makes all or none of the changes in the change batch request. This ensures that DNS routing isn't adversely affected by partial changes to the resource record sets in a hosted zone.
For example, suppose a change batch request contains two changes: it deletes the CNAME resource record set for www.example.com and creates an alias resource record set for www.example.com. If validation for both records succeeds, Route 53 deletes the first resource record set and creates the second resource record set in a single operation. If validation for either the DELETE or the CREATE action fails, then the request is canceled, and the original CNAME record continues to exist.
If you try to delete the same resource record set more than once in a single change batch, Route 53 returns an InvalidChangeBatch error.
Traffic Flow
To create resource record sets for complex routing configurations, use either the traffic flow visual editor in the 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.
Create, Delete, and Upsert
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 set doesn't exist, Route 53 creates it. If a resource set exists Route 53 updates it with the values in the request.
Syntaxes for Creating, Updating, and Deleting Resource Record Sets
The syntax for a request depends on the type of resource record set that you want to create, delete, or update, such as weighted, alias, or failover. The XML elements in your request must appear in the order listed in the syntax.
For an example for each type of resource record set, see "Examples."
Don't refer to the syntax in the "Parameter Syntax" section, which includes all of the elements for every kind of resource record set that you can create, delete, or update by using ChangeResourceRecordSets.
Change Propagation to Route 53 DNS Servers
When you submit a ChangeResourceRecordSets request, Route 53 propagates your changes to all of the Route 53 authoritative DNS servers managing the hosted zone. 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 Route 53 name servers managing the hosted zone within 60 seconds. For more information, see GetChange.
Limits on ChangeResourceRecordSets Requests
For information about the limits on a ChangeResourceRecordSets request, see Limits in the Amazon Route 53 Developer Guide.
Parameters:
-
hosted_zone_id(ResourceId) –The ID of the hosted zone that contains the resource record sets that you want to change.
-
change_batch(ChangeBatch) –A complex type that contains an optional comment and the
Changeselement.
Raises:
-
InvalidChangeBatch–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.
-
InvalidInput–The input is not valid.
-
NoSuchHealthCheck–No health check exists with the specified ID.
-
NoSuchHostedZone–No hosted zone exists with the ID that you specified.
-
PriorRequestNotComplete–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 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. -
UnknownServiceError–The service returned an error code this client does not model.
Examples:
To create an alias resource record set The following example creates an alias resource record set that routes traffic to a CloudFront distribution.
>>> await client.change_resource_record_sets(hosted_zone_id='Z3M3LMPEXAMPLE', change_batch={'Comment': 'CloudFront distribution for example.com', 'Changes': [{'Action': 'CREATE', 'ResourceRecordSet': {'Name': 'example.com', 'Type': 'A', 'AliasTarget': {'HostedZoneId': 'Z2FDTNDATAQYW2', 'DNSName': 'd123rk29d0stfj.cloudfront.net', 'EvaluateTargetHealth': False}}}]})
To create failover alias resource record sets
The following example creates primary and secondary failover alias resource record sets that route traffic to ELB load balancers. Traffic is generally routed to the primary resource, in the Ohio region. If that resource is unavailable, traffic is routed to the secondary resource, in the Oregon region.
>>> await client.change_resource_record_sets(hosted_zone_id='Z3M3LMPEXAMPLE', change_batch={'Comment': 'Failover alias configuration for example.com', 'Changes': [{'Action': 'CREATE', 'ResourceRecordSet': {'Name': 'example.com', 'Type': 'A', 'SetIdentifier': 'Ohio region', 'Failover': 'PRIMARY', 'AliasTarget': {'HostedZoneId': 'Z3AADJGX6KTTL2', 'DNSName': 'example-com-123456789.us-east-2.elb.amazonaws.com ', 'EvaluateTargetHealth': True}}}, {'Action': 'CREATE', 'ResourceRecordSet': {'Name': 'example.com', 'Type': 'A', 'SetIdentifier': 'Oregon region', 'Failover': 'SECONDARY', 'AliasTarget': {'HostedZoneId': 'Z1H1FL5HABSF5', 'DNSName': 'example-com-987654321.us-west-2.elb.amazonaws.com ', 'EvaluateTargetHealth': True}}}]})
To create failover resource record sets
The following example creates primary and secondary failover resource record sets that route traffic to EC2 instances. Traffic is generally routed to the primary resource, in the Ohio region. If that resource is unavailable, traffic is routed to the secondary resource, in the Oregon region.
>>> await client.change_resource_record_sets(hosted_zone_id='Z3M3LMPEXAMPLE', change_batch={'Comment': 'Failover configuration for example.com', 'Changes': [{'Action': 'CREATE', 'ResourceRecordSet': {'Name': 'example.com', 'Type': 'A', 'SetIdentifier': 'Ohio region', 'Failover': 'PRIMARY', 'TTL': 60, 'ResourceRecords': [{'Value': '192.0.2.44'}], 'HealthCheckId': 'abcdef11-2222-3333-4444-555555fedcba'}}, {'Action': 'CREATE', 'ResourceRecordSet': {'Name': 'example.com', 'Type': 'A', 'SetIdentifier': 'Oregon region', 'Failover': 'SECONDARY', 'TTL': 60, 'ResourceRecords': [{'Value': '192.0.2.45'}], 'HealthCheckId': 'abcdef66-7777-8888-9999-000000fedcba'}}]})
To create geolocation alias resource record sets
The following example creates four geolocation alias resource record sets that route traffic to ELB load balancers. Traffic is routed to one of four IP addresses, for North America (NA), for South America (SA), for Europe (EU), and for all other locations (*).
>>> await client.change_resource_record_sets(hosted_zone_id='Z3M3LMPEXAMPLE', change_batch={'Comment': 'Geolocation alias configuration for example.com', 'Changes': [{'Action': 'CREATE', 'ResourceRecordSet': {'Name': 'example.com', 'Type': 'A', 'SetIdentifier': 'North America', 'GeoLocation': {'ContinentCode': 'NA'}, 'AliasTarget': {'HostedZoneId': 'Z3AADJGX6KTTL2', 'DNSName': 'example-com-123456789.us-east-2.elb.amazonaws.com ', 'EvaluateTargetHealth': True}}}, {'Action': 'CREATE', 'ResourceRecordSet': {'Name': 'example.com', 'Type': 'A', 'SetIdentifier': 'South America', 'GeoLocation': {'ContinentCode': 'SA'}, 'AliasTarget': {'HostedZoneId': 'Z2P70J7HTTTPLU', 'DNSName': 'example-com-234567890.sa-east-1.elb.amazonaws.com ', 'EvaluateTargetHealth': True}}}, {'Action': 'CREATE', 'ResourceRecordSet': {'Name': 'example.com', 'Type': 'A', 'SetIdentifier': 'Europe', 'GeoLocation': {'ContinentCode': 'EU'}, 'AliasTarget': {'HostedZoneId': 'Z215JYRZR1TBD5', 'DNSName': 'example-com-234567890.eu-central-1.elb.amazonaws.com ', 'EvaluateTargetHealth': True}}}, {'Action': 'CREATE', 'ResourceRecordSet': {'Name': 'example.com', 'Type': 'A', 'SetIdentifier': 'Other locations', 'GeoLocation': {'CountryCode': '*'}, 'AliasTarget': {'HostedZoneId': 'Z1LMS91P8CMLE5', 'DNSName': 'example-com-234567890.ap-southeast-1.elb.amazonaws.com ', 'EvaluateTargetHealth': True}}}]})
To create geolocation resource record sets
The following example creates four geolocation resource record sets that use IPv4 addresses to route traffic to resources such as web servers running on EC2 instances. Traffic is routed to one of four IP addresses, for North America (NA), for South America (SA), for Europe (EU), and for all other locations (*).
>>> await client.change_resource_record_sets(hosted_zone_id='Z3M3LMPEXAMPLE', change_batch={'Comment': 'Geolocation configuration for example.com', 'Changes': [{'Action': 'CREATE', 'ResourceRecordSet': {'Name': 'example.com', 'Type': 'A', 'SetIdentifier': 'North America', 'GeoLocation': {'ContinentCode': 'NA'}, 'TTL': 60, 'ResourceRecords': [{'Value': '192.0.2.44'}]}}, {'Action': 'CREATE', 'ResourceRecordSet': {'Name': 'example.com', 'Type': 'A', 'SetIdentifier': 'South America', 'GeoLocation': {'ContinentCode': 'SA'}, 'TTL': 60, 'ResourceRecords': [{'Value': '192.0.2.45'}]}}, {'Action': 'CREATE', 'ResourceRecordSet': {'Name': 'example.com', 'Type': 'A', 'SetIdentifier': 'Europe', 'GeoLocation': {'ContinentCode': 'EU'}, 'TTL': 60, 'ResourceRecords': [{'Value': '192.0.2.46'}]}}, {'Action': 'CREATE', 'ResourceRecordSet': {'Name': 'example.com', 'Type': 'A', 'SetIdentifier': 'Other locations', 'GeoLocation': {'CountryCode': '*'}, 'TTL': 60, 'ResourceRecords': [{'Value': '192.0.2.47'}]}}]})
To create latency alias resource record sets
The following example creates two latency alias resource record sets that route traffic for example.com to ELB load balancers. Requests are routed either to the Ohio region or the Oregon region, depending on the latency between the user and those regions.
>>> await client.change_resource_record_sets(hosted_zone_id='Z3M3LMPEXAMPLE', change_batch={'Comment': 'ELB load balancers for example.com', 'Changes': [{'Action': 'CREATE', 'ResourceRecordSet': {'Name': 'example.com', 'Type': 'A', 'SetIdentifier': 'Ohio region', 'Region': 'us-east-2', 'AliasTarget': {'HostedZoneId': 'Z3AADJGX6KTTL2', 'DNSName': 'example-com-123456789.us-east-2.elb.amazonaws.com ', 'EvaluateTargetHealth': True}}}, {'Action': 'CREATE', 'ResourceRecordSet': {'Name': 'example.com', 'Type': 'A', 'SetIdentifier': 'Oregon region', 'Region': 'us-west-2', 'AliasTarget': {'HostedZoneId': 'Z1H1FL5HABSF5', 'DNSName': 'example-com-987654321.us-west-2.elb.amazonaws.com ', 'EvaluateTargetHealth': True}}}]})
To create latency resource record sets
The following example creates two latency resource record sets that route traffic to EC2 instances. Traffic for example.com is routed either to the Ohio region or the Oregon region, depending on the latency between the user and those regions.
>>> await client.change_resource_record_sets(hosted_zone_id='Z3M3LMPEXAMPLE', change_batch={'Comment': 'EC2 instances for example.com', 'Changes': [{'Action': 'CREATE', 'ResourceRecordSet': {'Name': 'example.com', 'Type': 'A', 'SetIdentifier': 'Ohio region', 'Region': 'us-east-2', 'TTL': 60, 'ResourceRecords': [{'Value': '192.0.2.44'}], 'HealthCheckId': 'abcdef11-2222-3333-4444-555555fedcba'}}, {'Action': 'CREATE', 'ResourceRecordSet': {'Name': 'example.com', 'Type': 'A', 'SetIdentifier': 'Oregon region', 'Region': 'us-west-2', 'TTL': 60, 'ResourceRecords': [{'Value': '192.0.2.45'}], 'HealthCheckId': 'abcdef66-7777-8888-9999-000000fedcba'}}]})
To create a basic resource record set
The following example creates a resource record set that routes Internet traffic to a resource with an IP address of 192.0.2.44.
>>> await client.change_resource_record_sets(hosted_zone_id='Z3M3LMPEXAMPLE', change_batch={'Comment': 'Web server for example.com', 'Changes': [{'Action': 'CREATE', 'ResourceRecordSet': {'Name': 'example.com', 'Type': 'A', 'TTL': 60, 'ResourceRecords': [{'Value': '192.0.2.44'}]}}]})
To create weighted alias resource record sets
The following example creates two weighted alias resource record sets that route traffic to ELB load balancers. The resource with a Weight of 100 will get 1/3rd of traffic (100/100+200), and the other resource will get the rest of the traffic for example.com.
>>> await client.change_resource_record_sets(hosted_zone_id='Z3M3LMPEXAMPLE', change_batch={'Comment': 'ELB load balancers for example.com', 'Changes': [{'Action': 'CREATE', 'ResourceRecordSet': {'Name': 'example.com', 'Type': 'A', 'SetIdentifier': 'Ohio region', 'Weight': 100, 'AliasTarget': {'HostedZoneId': 'Z3AADJGX6KTTL2', 'DNSName': 'example-com-123456789.us-east-2.elb.amazonaws.com ', 'EvaluateTargetHealth': True}}}, {'Action': 'CREATE', 'ResourceRecordSet': {'Name': 'example.com', 'Type': 'A', 'SetIdentifier': 'Oregon region', 'Weight': 200, 'AliasTarget': {'HostedZoneId': 'Z1H1FL5HABSF5', 'DNSName': 'example-com-987654321.us-west-2.elb.amazonaws.com ', 'EvaluateTargetHealth': True}}}]})
To create weighted resource record sets
The following example creates two weighted resource record sets. The resource with a Weight of 100 will get 1/3rd of traffic (100/100+200), and the other resource will get the rest of the traffic for example.com.
>>> await client.change_resource_record_sets(hosted_zone_id='Z3M3LMPEXAMPLE', change_batch={'Comment': 'Web servers for example.com', 'Changes': [{'Action': 'CREATE', 'ResourceRecordSet': {'Name': 'example.com', 'Type': 'A', 'SetIdentifier': 'Seattle data center', 'Weight': 100, 'TTL': 60, 'ResourceRecords': [{'Value': '192.0.2.44'}], 'HealthCheckId': 'abcdef11-2222-3333-4444-555555fedcba'}}, {'Action': 'CREATE', 'ResourceRecordSet': {'Name': 'example.com', 'Type': 'A', 'SetIdentifier': 'Portland data center', 'Weight': 200, 'TTL': 60, 'ResourceRecords': [{'Value': '192.0.2.45'}], 'HealthCheckId': 'abcdef66-7777-8888-9999-000000fedcba'}}]})
Source code in docs_src/capo_route_53/_services/async_route53.py
543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 | |