Las traducciones son generadas a través de traducción automática. En caso de conflicto entre la traducción y la version original de inglés, prevalecerá la version en inglés.
ChangeResourceRecordSets
Úselo con un AWS SDK o CLI
En los siguientes ejemplos de código, se muestra cómo utilizar ChangeResourceRecordSets
.
- CLI
-
- AWS CLI
-
Para crear, actualizar o eliminar un conjunto de registros de recursos
El siguiente
change-resource-record-sets
comando crea un conjunto de registros de recursos mediante la configuración JSON con formatohosted-zone-id
Z1R8UBAEXAMPLE
y del archivo:C:\awscli\route53\change-resource-record-sets.json
aws route53 change-resource-record-sets --hosted-zone-id
Z1R8UBAEXAMPLE
--change-batch file://C:\awscli\route53\change-resource-record-sets.jsonPara obtener más información, consulte POST ChangeResourceRecordSets la APIreferencia de Amazon Route 53.
La configuración del JSON archivo depende del tipo de conjunto de registros de recursos que desee crear:
BasicWeightedAliasWeighted AliasLatencyLatency AliasFailoverFailover Alias
Sintaxis básica:
{ "Comment": "optional comment about the changes in this change batch request", "Changes": [ { "Action": "CREATE"|"DELETE"|"UPSERT", "ResourceRecordSet": { "Name": "DNS domain name", "Type": "SOA"|"A"|"TXT"|"NS"|"CNAME"|"MX"|"PTR"|"SRV"|"SPF"|"AAAA", "TTL": time to live in seconds, "ResourceRecords": [ { "Value": "applicable value for the record type" }, {...} ] } }, {...} ] }
Sintaxis ponderada:
{ "Comment": "optional comment about the changes in this change batch request", "Changes": [ { "Action": "CREATE"|"DELETE"|"UPSERT", "ResourceRecordSet": { "Name": "DNS domain name", "Type": "SOA"|"A"|"TXT"|"NS"|"CNAME"|"MX"|"PTR"|"SRV"|"SPF"|"AAAA", "SetIdentifier": "unique description for this resource record set", "Weight": value between 0 and 255, "TTL": time to live in seconds, "ResourceRecords": [ { "Value": "applicable value for the record type" }, {...} ], "HealthCheckId": "optional ID of an Amazon Route 53 health check" } }, {...} ] }
Sintaxis de alias:
{ "Comment": "optional comment about the changes in this change batch request", "Changes": [ { "Action": "CREATE"|"DELETE"|"UPSERT", "ResourceRecordSet": { "Name": "DNS domain name", "Type": "SOA"|"A"|"TXT"|"NS"|"CNAME"|"MX"|"PTR"|"SRV"|"SPF"|"AAAA", "AliasTarget": { "HostedZoneId": "hosted zone ID for your CloudFront distribution, Amazon S3 bucket, Elastic Load Balancing load balancer, or Amazon Route 53 hosted zone", "DNSName": "DNS domain name for your CloudFront distribution, Amazon S3 bucket, Elastic Load Balancing load balancer, or another resource record set in this hosted zone", "EvaluateTargetHealth": true|false }, "HealthCheckId": "optional ID of an Amazon Route 53 health check" } }, {...} ] }
Sintaxis de alias ponderada:
{ "Comment": "optional comment about the changes in this change batch request", "Changes": [ { "Action": "CREATE"|"DELETE"|"UPSERT", "ResourceRecordSet": { "Name": "DNS domain name", "Type": "SOA"|"A"|"TXT"|"NS"|"CNAME"|"MX"|"PTR"|"SRV"|"SPF"|"AAAA", "SetIdentifier": "unique description for this resource record set", "Weight": value between 0 and 255, "AliasTarget": { "HostedZoneId": "hosted zone ID for your CloudFront distribution, Amazon S3 bucket, Elastic Load Balancing load balancer, or Amazon Route 53 hosted zone", "DNSName": "DNS domain name for your CloudFront distribution, Amazon S3 bucket, Elastic Load Balancing load balancer, or another resource record set in this hosted zone", "EvaluateTargetHealth": true|false }, "HealthCheckId": "optional ID of an Amazon Route 53 health check" } }, {...} ] }
Sintaxis de latencia:
{ "Comment": "optional comment about the changes in this change batch request", "Changes": [ { "Action": "CREATE"|"DELETE"|"UPSERT", "ResourceRecordSet": { "Name": "DNS domain name", "Type": "SOA"|"A"|"TXT"|"NS"|"CNAME"|"MX"|"PTR"|"SRV"|"SPF"|"AAAA", "SetIdentifier": "unique description for this resource record set", "Region": "Amazon EC2 region name", "TTL": time to live in seconds, "ResourceRecords": [ { "Value": "applicable value for the record type" }, {...} ], "HealthCheckId": "optional ID of an Amazon Route 53 health check" } }, {...} ] }
Sintaxis de alias de latencia:
{ "Comment": "optional comment about the changes in this change batch request", "Changes": [ { "Action": "CREATE"|"DELETE"|"UPSERT", "ResourceRecordSet": { "Name": "DNS domain name", "Type": "SOA"|"A"|"TXT"|"NS"|"CNAME"|"MX"|"PTR"|"SRV"|"SPF"|"AAAA", "SetIdentifier": "unique description for this resource record set", "Region": "Amazon EC2 region name", "AliasTarget": { "HostedZoneId": "hosted zone ID for your CloudFront distribution, Amazon S3 bucket, Elastic Load Balancing load balancer, or Amazon Route 53 hosted zone", "DNSName": "DNS domain name for your CloudFront distribution, Amazon S3 bucket, Elastic Load Balancing load balancer, or another resource record set in this hosted zone", "EvaluateTargetHealth": true|false }, "HealthCheckId": "optional ID of an Amazon Route 53 health check" } }, {...} ] }
Sintaxis de conmutación por error:
{ "Comment": "optional comment about the changes in this change batch request", "Changes": [ { "Action": "CREATE"|"DELETE"|"UPSERT", "ResourceRecordSet": { "Name": "DNS domain name", "Type": "SOA"|"A"|"TXT"|"NS"|"CNAME"|"MX"|"PTR"|"SRV"|"SPF"|"AAAA", "SetIdentifier": "unique description for this resource record set", "Failover": "PRIMARY" | "SECONDARY", "TTL": time to live in seconds, "ResourceRecords": [ { "Value": "applicable value for the record type" }, {...} ], "HealthCheckId": "ID of an Amazon Route 53 health check" } }, {...} ] }
Sintaxis del alias de conmutación por error:
{ "Comment": "optional comment about the changes in this change batch request", "Changes": [ { "Action": "CREATE"|"DELETE"|"UPSERT", "ResourceRecordSet": { "Name": "DNS domain name", "Type": "SOA"|"A"|"TXT"|"NS"|"CNAME"|"MX"|"PTR"|"SRV"|"SPF"|"AAAA", "SetIdentifier": "unique description for this resource record set", "Failover": "PRIMARY" | "SECONDARY", "AliasTarget": { "HostedZoneId": "hosted zone ID for your CloudFront distribution, Amazon S3 bucket, Elastic Load Balancing load balancer, or Amazon Route 53 hosted zone", "DNSName": "DNS domain name for your CloudFront distribution, Amazon S3 bucket, Elastic Load Balancing load balancer, or another resource record set in this hosted zone", "EvaluateTargetHealth": true|false }, "HealthCheckId": "optional ID of an Amazon Route 53 health check" } }, {...} ] }
-
Para API obtener más información, consulte ChangeResourceRecordSets
la Referencia de AWS CLI comandos.
-
- PowerShell
-
- Herramientas para PowerShell
-
Ejemplo 1: en este ejemplo se crea un registro A para www.example.com y se cambia el registro A de test.example.com de 192.0.2.3 a 192.0.2.1. Tenga en cuenta que los valores de los registros de tipo cambio deben estar entre comillas dobles. TXT Consulte la documentación de Amazon Route 53 para obtener más información. Puede usar el Get-R53Change cmdlet para sondear y determinar cuándo se han completado los cambios.
$change1 = New-Object Amazon.Route53.Model.Change $change1.Action = "CREATE" $change1.ResourceRecordSet = New-Object Amazon.Route53.Model.ResourceRecordSet $change1.ResourceRecordSet.Name = "www.example.com" $change1.ResourceRecordSet.Type = "TXT" $change1.ResourceRecordSet.TTL = 600 $change1.ResourceRecordSet.ResourceRecords.Add(@{Value="item 1 item 2 item 3"}) $change2 = New-Object Amazon.Route53.Model.Change $change2.Action = "DELETE" $change2.ResourceRecordSet = New-Object Amazon.Route53.Model.ResourceRecordSet $change2.ResourceRecordSet.Name = "test.example.com" $change2.ResourceRecordSet.Type = "A" $change2.ResourceRecordSet.TTL = 600 $change2.ResourceRecordSet.ResourceRecords.Add(@{Value="192.0.2.3"}) $change3 = New-Object Amazon.Route53.Model.Change $change3.Action = "CREATE" $change3.ResourceRecordSet = New-Object Amazon.Route53.Model.ResourceRecordSet $change3.ResourceRecordSet.Name = "test.example.com" $change3.ResourceRecordSet.Type = "A" $change3.ResourceRecordSet.TTL = 600 $change3.ResourceRecordSet.ResourceRecords.Add(@{Value="192.0.2.1"}) $params = @{ HostedZoneId="Z1PA6795UKMFR9" ChangeBatch_Comment="This change batch creates a TXT record for www.example.com. and changes the A record for test.example.com. from 192.0.2.3 to 192.0.2.1." ChangeBatch_Change=$change1,$change2,$change3 } Edit-R53ResourceRecordSet @params
Ejemplo 2: en este ejemplo se muestra cómo crear conjuntos de registros de recursos de alias. «Z222222222» es el ID de la zona alojada de Amazon Route 53 en la que va a crear el conjunto de registros de recursos de alias. «example.com» es el vértice de la zona para el que desea crear un alias y «www.example.com» es un subdominio para el que también desea crear un alias. «Z11111» es un ejemplo de un ID de zona alojada para el balanceador de cargas y «example-load-balancer-11.us-east-1.elb.amazonaws.com» es un ejemplo de un nombre de dominio de balanceador de carga con el que Amazon Route 53 responde a las consultas de example.com y www.example.com. Consulte la documentación de Amazon Route 53 para obtener más información. Puede usar el Get-R53Change cmdlet para sondear y determinar cuándo se han completado los cambios.
$change1 = New-Object Amazon.Route53.Model.Change $change1.Action = "CREATE" $change1.ResourceRecordSet = New-Object Amazon.Route53.Model.ResourceRecordSet $change1.ResourceRecordSet.Name = "example.com" $change1.ResourceRecordSet.Type = "A" $change1.ResourceRecordSet.AliasTarget = New-Object Amazon.Route53.Model.AliasTarget $change1.ResourceRecordSet.AliasTarget.HostedZoneId = "Z1111111111111" $change1.ResourceRecordSet.AliasTarget.DNSName = "example-load-balancer-1111111111.us-east-1.elb.amazonaws.com." $change1.ResourceRecordSet.AliasTarget.EvaluateTargetHealth = $true $change2 = New-Object Amazon.Route53.Model.Change $change2.Action = "CREATE" $change2.ResourceRecordSet = New-Object Amazon.Route53.Model.ResourceRecordSet $change1.ResourceRecordSet.Name = "www.example.com" $change1.ResourceRecordSet.Type = "A" $change1.ResourceRecordSet.AliasTarget = New-Object Amazon.Route53.Model.AliasTarget $change1.ResourceRecordSet.AliasTarget.HostedZoneId = "Z1111111111111" $change1.ResourceRecordSet.AliasTarget.DNSName = "example-load-balancer-1111111111.us-east-1.elb.amazonaws.com." $change1.ResourceRecordSet.AliasTarget.EvaluateTargetHealth = $false $params = @{ HostedZoneId="Z222222222" ChangeBatch_Comment="This change batch creates two alias resource record sets, one for the zone apex, example.com, and one for www.example.com, that both point to example-load-balancer-1111111111.us-east-1.elb.amazonaws.com." ChangeBatch_Change=$change1,$change2 } Edit-R53ResourceRecordSet @params
Ejemplo 3: en este ejemplo se crean dos registros A para www.example.com. Una cuarta parte de las veces (1/ (1+3)), Amazon Route 53 responde a las consultas de www.example.com con los dos valores del primer conjunto de registros de recursos (192.0.2.9 y 192.0.2.10). Tres cuartas partes de las veces (3/ (1+3)) Amazon Route 53 responde a las consultas de www.example.com con los dos valores del segundo conjunto de registros de recursos (192.0.2.11 y 192.0.2.12). Consulte la documentación de Amazon Route 53 para obtener más información. Puede usar el Get-R53Change cmdlet para sondear y determinar cuándo se han completado los cambios.
$change1 = New-Object Amazon.Route53.Model.Change $change1.Action = "CREATE" $change1.ResourceRecordSet = New-Object Amazon.Route53.Model.ResourceRecordSet $change1.ResourceRecordSet.Name = "www.example.com" $change1.ResourceRecordSet.Type = "A" $change1.ResourceRecordSet.SetIdentifier = "Rack 2, Positions 4 and 5" $change1.ResourceRecordSet.Weight = 1 $change1.ResourceRecordSet.TTL = 600 $change1.ResourceRecordSet.ResourceRecords.Add(@{Value="192.0.2.9"}) $change1.ResourceRecordSet.ResourceRecords.Add(@{Value="192.0.2.10"}) $change2 = New-Object Amazon.Route53.Model.Change $change2.Action = "CREATE" $change2.ResourceRecordSet = New-Object Amazon.Route53.Model.ResourceRecordSet $change2.ResourceRecordSet.Name = "www.example.com" $change2.ResourceRecordSet.Type = "A" $change2.ResourceRecordSet.SetIdentifier = "Rack 5, Positions 1 and 2" $change2.ResourceRecordSet.Weight = 3 $change2.ResourceRecordSet.TTL = 600 $change2.ResourceRecordSet.ResourceRecords.Add(@{Value="192.0.2.11"}) $change2.ResourceRecordSet.ResourceRecords.Add(@{Value="192.0.2.12"}) $params = @{ HostedZoneId="Z1PA6795UKMFR9" ChangeBatch_Comment="This change creates two weighted resource record sets, each of which has two values." ChangeBatch_Change=$change1,$change2 } Edit-R53ResourceRecordSet @params
Ejemplo 4: en este ejemplo se muestra cómo crear conjuntos de registros de recursos de alias ponderados suponiendo que example.com es el dominio para el que desea crear conjuntos de registros de recursos de alias ponderados. SetIdentifier diferencia los dos conjuntos de registros de recursos de alias ponderados entre sí. Este elemento es obligatorio porque los elementos Nombre y Tipo tienen los mismos valores para ambos conjuntos de registros de recursos. Los valores Z333311111 y Z3333333333333 son ejemplos de zona hospedada para el balanceador de ELB cargas especificado IDs por el valor de. DNSName example-load-balancer-2222222222.us-east-1.elb.amazonaws.com y -4444444444.us-east-1.elb.amazonaws.com example-load-balancer son ejemplos de dominios de Elastic Load Balancing desde los que Amazon Route 53 responde a las consultas de example.com. Consulte la documentación de Amazon Route 53 para obtener más información. Puede usar el Get-R53Change cmdlet para sondear y determinar cuándo se han completado los cambios.
$change1 = New-Object Amazon.Route53.Model.Change $change1.Action = "CREATE" $change1.ResourceRecordSet = New-Object Amazon.Route53.Model.ResourceRecordSet $change1.ResourceRecordSet.Name = "example.com" $change1.ResourceRecordSet.Type = "A" $change1.ResourceRecordSet.SetIdentifier = "1" $change1.ResourceRecordSet.Weight = 3 $change1.ResourceRecordSet.AliasTarget = New-Object Amazon.Route53.Model.AliasTarget $change1.ResourceRecordSet.AliasTarget.HostedZoneId = "Z1111111111111" $change1.ResourceRecordSet.AliasTarget.DNSName = "example-load-balancer-2222222222.us-east-1.elb.amazonaws.com." $change1.ResourceRecordSet.AliasTarget.EvaluateTargetHealth = $true $change2 = New-Object Amazon.Route53.Model.Change $change2.Action = "CREATE" $change2.ResourceRecordSet = New-Object Amazon.Route53.Model.ResourceRecordSet $change2.ResourceRecordSet.Name = "example.com" $change2.ResourceRecordSet.Type = "A" $change2.ResourceRecordSet.SetIdentifier = "2" $change2.ResourceRecordSet.Weight = 1 $change2.ResourceRecordSet.AliasTarget = New-Object Amazon.Route53.Model.AliasTarget $change2.ResourceRecordSet.AliasTarget.HostedZoneId = "Z3333333333333" $change2.ResourceRecordSet.AliasTarget.DNSName = "example-load-balancer-4444444444.us-east-1.elb.amazonaws.com." $change2.ResourceRecordSet.AliasTarget.EvaluateTargetHealth = $false $params = @{ HostedZoneId="Z5555555555" ChangeBatch_Comment="This change batch creates two weighted alias resource record sets. Amazon Route 53 responds to queries for example.com with the first ELB domain 3/4ths of the times and the second one 1/4th of the time." ChangeBatch_Change=$change1,$change2 } Edit-R53ResourceRecordSet @params
Ejemplo 5: en este ejemplo se crean dos conjuntos de registros de recursos de alias de latencia, uno para un balanceador de ELB cargas en la región EE.UU. Oeste (Oregón) (us-west-2) y otro para un balanceador de cargas en la región Asia-Pacífico (Singapur) (ap-southeast-1). Consulte la documentación de Amazon Route 53 para obtener más información. Puede usar el Get-R53Change cmdlet para sondear y determinar cuándo se han completado los cambios.
$change1 = New-Object Amazon.Route53.Model.Change $change1.Action = "CREATE" $change1.ResourceRecordSet = New-Object Amazon.Route53.Model.ResourceRecordSet $change1.ResourceRecordSet.Name = "example.com" $change1.ResourceRecordSet.Type = "A" $change1.ResourceRecordSet.SetIdentifier = "Oregon load balancer 1" $change1.ResourceRecordSet.Region = us-west-2 $change1.ResourceRecordSet.AliasTarget = New-Object Amazon.Route53.Model.AliasTarget $change1.ResourceRecordSet.AliasTarget.HostedZoneId = "Z1111111111111" $change1.ResourceRecordSet.AliasTarget.DNSName = "example-load-balancer-2222222222.us-west-2.elb.amazonaws.com" $change1.ResourceRecordSet.AliasTarget.EvaluateTargetHealth = $true $change2 = New-Object Amazon.Route53.Model.Change $change2.Action = "CREATE" $change2.ResourceRecordSet = New-Object Amazon.Route53.Model.ResourceRecordSet $change2.ResourceRecordSet.Name = "example.com" $change2.ResourceRecordSet.Type = "A" $change2.ResourceRecordSet.SetIdentifier = "Singapore load balancer 1" $change2.ResourceRecordSet.Region = ap-southeast-1 $change2.ResourceRecordSet.AliasTarget = New-Object Amazon.Route53.Model.AliasTarget $change2.ResourceRecordSet.AliasTarget.HostedZoneId = "Z2222222222222" $change2.ResourceRecordSet.AliasTarget.DNSName = "example-load-balancer-1111111111.ap-southeast-1.elb.amazonaws.com" $change2.ResourceRecordSet.AliasTarget.EvaluateTargetHealth = $true $params = @{ HostedZoneId="Z5555555555" ChangeBatch_Comment="This change batch creates two latency resource record sets, one for the US West (Oregon) region and one for the Asia Pacific (Singapore) region." ChangeBatch_Change=$change1,$change2 } Edit-R53ResourceRecordSet @params
-
Para API obtener más información, consulte la referencia del ChangeResourceRecordSets AWS Tools for PowerShellcmdlet.
-
Para obtener una lista completa de guías para AWS SDK desarrolladores y ejemplos de código, consulte. Uso de Route 53 con un AWS SDK En este tema también se incluye información sobre cómo empezar y detalles sobre SDK las versiones anteriores.