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.
Example
Use a bare-bones client and the command you need to make an API call.
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.
Base exception class for all service exceptions from Route53 service.
Example
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. constinput = { "ChangeBatch": { "Changes": [ { "Action":"CREATE", "ResourceRecordSet": { "Name":"example.com", "ResourceRecords": [ { "Value":"192.0.2.44" } ], "TTL":60, "Type":"A" } } ], "Comment":"Web server for example.com" }, "HostedZoneId":"Z3M3LMPEXAMPLE" }; constcommand = newChangeResourceRecordSetsCommand(input); constresponse = awaitclient.send(command); /* response == { "ChangeInfo": { "Comment": "Web server for example.com", "Id": "/change/C2682N5HXP0BZ4", "Status": "PENDING", "SubmittedAt": "2017-02-10T01:36:41.958Z" } } */ // example id: to-create-update-or-delete-resource-record-sets-1484344703668
Example
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. constinput = { "ChangeBatch": { "Changes": [ { "Action":"CREATE", "ResourceRecordSet": { "HealthCheckId":"abcdef11-2222-3333-4444-555555fedcba", "Name":"example.com", "ResourceRecords": [ { "Value":"192.0.2.44" } ], "SetIdentifier":"Seattle data center", "TTL":60, "Type":"A", "Weight":100 } }, { "Action":"CREATE", "ResourceRecordSet": { "HealthCheckId":"abcdef66-7777-8888-9999-000000fedcba", "Name":"example.com", "ResourceRecords": [ { "Value":"192.0.2.45" } ], "SetIdentifier":"Portland data center", "TTL":60, "Type":"A", "Weight":200 } } ], "Comment":"Web servers for example.com" }, "HostedZoneId":"Z3M3LMPEXAMPLE" }; constcommand = newChangeResourceRecordSetsCommand(input); constresponse = awaitclient.send(command); /* response == { "ChangeInfo": { "Comment": "Web servers for example.com", "Id": "/change/C2682N5HXP0BZ4", "Status": "PENDING", "SubmittedAt": "2017-02-10T01:36:41.958Z" } } */ // example id: to-create-weighted-resource-record-sets-1484348208522
Example
To create an alias resource record set
// The following example creates an alias resource record set that routes traffic to a CloudFront distribution. constinput = { "ChangeBatch": { "Changes": [ { "Action":"CREATE", "ResourceRecordSet": { "AliasTarget": { "DNSName":"d123rk29d0stfj.cloudfront.net", "EvaluateTargetHealth":false, "HostedZoneId":"Z2FDTNDATAQYW2" }, "Name":"example.com", "Type":"A" } } ], "Comment":"CloudFront distribution for example.com" }, "HostedZoneId":"Z3M3LMPEXAMPLE" }; constcommand = newChangeResourceRecordSetsCommand(input); constresponse = awaitclient.send(command); /* response == { "ChangeInfo": { "Comment": "CloudFront distribution for example.com", "Id": "/change/C2682N5HXP0BZ4", "Status": "PENDING", "SubmittedAt": "2017-02-10T01:36:41.958Z" } } */ // example id: to-create-an-alias-resource-record-set-1484348404062
Example
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. constinput = { "ChangeBatch": { "Changes": [ { "Action":"CREATE", "ResourceRecordSet": { "AliasTarget": { "DNSName":"example-com-123456789.us-east-2.elb.amazonaws.com ", "EvaluateTargetHealth":true, "HostedZoneId":"Z3AADJGX6KTTL2" }, "Name":"example.com", "SetIdentifier":"Ohio region", "Type":"A", "Weight":100 } }, { "Action":"CREATE", "ResourceRecordSet": { "AliasTarget": { "DNSName":"example-com-987654321.us-west-2.elb.amazonaws.com ", "EvaluateTargetHealth":true, "HostedZoneId":"Z1H1FL5HABSF5" }, "Name":"example.com", "SetIdentifier":"Oregon region", "Type":"A", "Weight":200 } } ], "Comment":"ELB load balancers for example.com" }, "HostedZoneId":"Z3M3LMPEXAMPLE" }; constcommand = newChangeResourceRecordSetsCommand(input); constresponse = awaitclient.send(command); /* response == { "ChangeInfo": { "Comment": "ELB load balancers for example.com", "Id": "/change/C2682N5HXP0BZ4", "Status": "PENDING", "SubmittedAt": "2017-02-10T01:36:41.958Z" } } */ // example id: to-create-weighted-alias-resource-record-sets-1484349467416
Example
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. constinput = { "ChangeBatch": { "Changes": [ { "Action":"CREATE", "ResourceRecordSet": { "HealthCheckId":"abcdef11-2222-3333-4444-555555fedcba", "Name":"example.com", "Region":"us-east-2", "ResourceRecords": [ { "Value":"192.0.2.44" } ], "SetIdentifier":"Ohio region", "TTL":60, "Type":"A" } }, { "Action":"CREATE", "ResourceRecordSet": { "HealthCheckId":"abcdef66-7777-8888-9999-000000fedcba", "Name":"example.com", "Region":"us-west-2", "ResourceRecords": [ { "Value":"192.0.2.45" } ], "SetIdentifier":"Oregon region", "TTL":60, "Type":"A" } } ], "Comment":"EC2 instances for example.com" }, "HostedZoneId":"Z3M3LMPEXAMPLE" }; constcommand = newChangeResourceRecordSetsCommand(input); constresponse = awaitclient.send(command); /* response == { "ChangeInfo": { "Comment": "EC2 instances for example.com", "Id": "/change/C2682N5HXP0BZ4", "Status": "PENDING", "SubmittedAt": "2017-02-10T01:36:41.958Z" } } */ // example id: to-create-latency-resource-record-sets-1484350219917
Example
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. constinput = { "ChangeBatch": { "Changes": [ { "Action":"CREATE", "ResourceRecordSet": { "AliasTarget": { "DNSName":"example-com-123456789.us-east-2.elb.amazonaws.com ", "EvaluateTargetHealth":true, "HostedZoneId":"Z3AADJGX6KTTL2" }, "Name":"example.com", "Region":"us-east-2", "SetIdentifier":"Ohio region", "Type":"A" } }, { "Action":"CREATE", "ResourceRecordSet": { "AliasTarget": { "DNSName":"example-com-987654321.us-west-2.elb.amazonaws.com ", "EvaluateTargetHealth":true, "HostedZoneId":"Z1H1FL5HABSF5" }, "Name":"example.com", "Region":"us-west-2", "SetIdentifier":"Oregon region", "Type":"A" } } ], "Comment":"ELB load balancers for example.com" }, "HostedZoneId":"Z3M3LMPEXAMPLE" }; constcommand = newChangeResourceRecordSetsCommand(input); constresponse = awaitclient.send(command); /* response == { "ChangeInfo": { "Comment": "ELB load balancers for example.com", "Id": "/change/C2682N5HXP0BZ4", "Status": "PENDING", "SubmittedAt": "2017-02-10T01:36:41.958Z" } } */ // example id: to-create-latency-alias-resource-record-sets-1484601774179
Example
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. constinput = { "ChangeBatch": { "Changes": [ { "Action":"CREATE", "ResourceRecordSet": { "Failover":"PRIMARY", "HealthCheckId":"abcdef11-2222-3333-4444-555555fedcba", "Name":"example.com", "ResourceRecords": [ { "Value":"192.0.2.44" } ], "SetIdentifier":"Ohio region", "TTL":60, "Type":"A" } }, { "Action":"CREATE", "ResourceRecordSet": { "Failover":"SECONDARY", "HealthCheckId":"abcdef66-7777-8888-9999-000000fedcba", "Name":"example.com", "ResourceRecords": [ { "Value":"192.0.2.45" } ], "SetIdentifier":"Oregon region", "TTL":60, "Type":"A" } } ], "Comment":"Failover configuration for example.com" }, "HostedZoneId":"Z3M3LMPEXAMPLE" }; constcommand = newChangeResourceRecordSetsCommand(input); constresponse = awaitclient.send(command); /* response == { "ChangeInfo": { "Comment": "Failover configuration for example.com", "Id": "/change/C2682N5HXP0BZ4", "Status": "PENDING", "SubmittedAt": "2017-02-10T01:36:41.958Z" } } */ // example id: to-create-failover-resource-record-sets-1484604541740
Example
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. constinput = { "ChangeBatch": { "Changes": [ { "Action":"CREATE", "ResourceRecordSet": { "AliasTarget": { "DNSName":"example-com-123456789.us-east-2.elb.amazonaws.com ", "EvaluateTargetHealth":true, "HostedZoneId":"Z3AADJGX6KTTL2" }, "Failover":"PRIMARY", "Name":"example.com", "SetIdentifier":"Ohio region", "Type":"A" } }, { "Action":"CREATE", "ResourceRecordSet": { "AliasTarget": { "DNSName":"example-com-987654321.us-west-2.elb.amazonaws.com ", "EvaluateTargetHealth":true, "HostedZoneId":"Z1H1FL5HABSF5" }, "Failover":"SECONDARY", "Name":"example.com", "SetIdentifier":"Oregon region", "Type":"A" } } ], "Comment":"Failover alias configuration for example.com" }, "HostedZoneId":"Z3M3LMPEXAMPLE" }; constcommand = newChangeResourceRecordSetsCommand(input); constresponse = awaitclient.send(command); /* response == { "ChangeInfo": { "Comment": "Failover alias configuration for example.com", "Id": "/change/C2682N5HXP0BZ4", "Status": "PENDING", "SubmittedAt": "2017-02-10T01:36:41.958Z" } } */ // example id: to-create-failover-alias-resource-record-sets-1484607497724
Example
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 (*). constinput = { "ChangeBatch": { "Changes": [ { "Action":"CREATE", "ResourceRecordSet": { "GeoLocation": { "ContinentCode":"NA" }, "Name":"example.com", "ResourceRecords": [ { "Value":"192.0.2.44" } ], "SetIdentifier":"North America", "TTL":60, "Type":"A" } }, { "Action":"CREATE", "ResourceRecordSet": { "GeoLocation": { "ContinentCode":"SA" }, "Name":"example.com", "ResourceRecords": [ { "Value":"192.0.2.45" } ], "SetIdentifier":"South America", "TTL":60, "Type":"A" } }, { "Action":"CREATE", "ResourceRecordSet": { "GeoLocation": { "ContinentCode":"EU" }, "Name":"example.com", "ResourceRecords": [ { "Value":"192.0.2.46" } ], "SetIdentifier":"Europe", "TTL":60, "Type":"A" } }, { "Action":"CREATE", "ResourceRecordSet": { "GeoLocation": { "CountryCode":"*" }, "Name":"example.com", "ResourceRecords": [ { "Value":"192.0.2.47" } ], "SetIdentifier":"Other locations", "TTL":60, "Type":"A" } } ], "Comment":"Geolocation configuration for example.com" }, "HostedZoneId":"Z3M3LMPEXAMPLE" }; constcommand = newChangeResourceRecordSetsCommand(input); constresponse = awaitclient.send(command); /* response == { "ChangeInfo": { "Comment": "Geolocation configuration for example.com", "Id": "/change/C2682N5HXP0BZ4", "Status": "PENDING", "SubmittedAt": "2017-02-10T01:36:41.958Z" } } */ // example id: to-create-geolocation-resource-record-sets-1484612462466
Example
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 (*). constinput = { "ChangeBatch": { "Changes": [ { "Action":"CREATE", "ResourceRecordSet": { "AliasTarget": { "DNSName":"example-com-123456789.us-east-2.elb.amazonaws.com ", "EvaluateTargetHealth":true, "HostedZoneId":"Z3AADJGX6KTTL2" }, "GeoLocation": { "ContinentCode":"NA" }, "Name":"example.com", "SetIdentifier":"North America", "Type":"A" } }, { "Action":"CREATE", "ResourceRecordSet": { "AliasTarget": { "DNSName":"example-com-234567890.sa-east-1.elb.amazonaws.com ", "EvaluateTargetHealth":true, "HostedZoneId":"Z2P70J7HTTTPLU" }, "GeoLocation": { "ContinentCode":"SA" }, "Name":"example.com", "SetIdentifier":"South America", "Type":"A" } }, { "Action":"CREATE", "ResourceRecordSet": { "AliasTarget": { "DNSName":"example-com-234567890.eu-central-1.elb.amazonaws.com ", "EvaluateTargetHealth":true, "HostedZoneId":"Z215JYRZR1TBD5" }, "GeoLocation": { "ContinentCode":"EU" }, "Name":"example.com", "SetIdentifier":"Europe", "Type":"A" } }, { "Action":"CREATE", "ResourceRecordSet": { "AliasTarget": { "DNSName":"example-com-234567890.ap-southeast-1.elb.amazonaws.com ", "EvaluateTargetHealth":true, "HostedZoneId":"Z1LMS91P8CMLE5" }, "GeoLocation": { "CountryCode":"*" }, "Name":"example.com", "SetIdentifier":"Other locations", "Type":"A" } } ], "Comment":"Geolocation alias configuration for example.com" }, "HostedZoneId":"Z3M3LMPEXAMPLE" }; constcommand = newChangeResourceRecordSetsCommand(input); constresponse = awaitclient.send(command); /* response == { "ChangeInfo": { "Comment": "Geolocation alias configuration for example.com", "Id": "/change/C2682N5HXP0BZ4", "Status": "PENDING", "SubmittedAt": "2017-02-10T01:36:41.958Z" } } */ // example id: to-create-geolocation-alias-resource-record-sets-1484612871203
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 theDELETE
or theCREATE
action fails, then the request is canceled, and the originalCNAME
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 ofPENDING
. When propagation is complete,GetChange
returns a status ofINSYNC
. 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.Example
Use a bare-bones client and the command you need to make an API call.
Param
ChangeResourceRecordSetsCommandInput
Returns
ChangeResourceRecordSetsCommandOutput
See
input
shape.response
shape.config
shape.Throws
InvalidChangeBatch (client fault)
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.
Throws
InvalidInput (client fault)
The input is not valid.
Throws
NoSuchHealthCheck (client fault)
No health check exists with the specified ID.
Throws
NoSuchHostedZone (client fault)
No hosted zone exists with the ID that you specified.
Throws
PriorRequestNotComplete (client fault)
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.Throws
Route53ServiceException
Base exception class for all service exceptions from Route53 service.
Example
To create a basic resource record set
Example
To create weighted resource record sets
Example
To create an alias resource record set
Example
To create weighted alias resource record sets
Example
To create latency resource record sets
Example
To create latency alias resource record sets
Example
To create failover resource record sets
Example
To create failover alias resource record sets
Example
To create geolocation resource record sets
Example
To create geolocation alias resource record sets