Ci sono altri AWS SDK esempi disponibili nel repository AWS Doc SDK Examples
Le traduzioni sono generate tramite traduzione automatica. In caso di conflitto tra il contenuto di una traduzione e la versione originale in Inglese, quest'ultima prevarrà.
Da utilizzare ChangeResourceRecordSets
con un CLI
I seguenti esempi di codice mostrano come utilizzareChangeResourceRecordSets
.
- CLI
-
- AWS CLI
-
Per creare, aggiornare o eliminare un set di record di risorse
Il
change-resource-record-sets
comando seguente crea un set di record di risorse utilizzando la configurazione in JSON formatohosted-zone-id
Z1R8UBAEXAMPLE
e nel file: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.jsonPer ulteriori informazioni, POST ChangeResourceRecordSets consulta Amazon Route 53 API Reference.
La configurazione nel JSON file dipende dal tipo di set di record di risorse che desideri creare:
BasicWeightedAliasWeighted AliasLatencyLatency AliasFailoverFailover Alias
Sintassi di base:
{ "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" }, {...} ] } }, {...} ] }
Sintassi ponderata:
{ "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" } }, {...} ] }
Sintassi degli 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" } }, {...} ] }
Sintassi degli alias ponderati:
{ "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" } }, {...} ] }
Sintassi della latenza:
{ "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" } }, {...} ] }
Sintassi dell'alias di latenza:
{ "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" } }, {...} ] }
Sintassi di failover:
{ "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" } }, {...} ] }
Sintassi degli alias di failover:
{ "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" } }, {...} ] }
-
Per API i dettagli, vedere ChangeResourceRecordSets
in AWS CLI Command Reference.
-
- PowerShell
-
- Strumenti per PowerShell
-
Esempio 1: questo esempio crea un record A per www.example.com e modifica il record A per test.example.com da 192.0.2.3 a 192.0.2.1. Nota che i valori per i record di tipo Changes devono essere racchiusi tra virgolette doppie. TXT Per ulteriori dettagli, consulta la documentazione di Amazon Route 53. Puoi utilizzare il Get-R53Change cmdlet per effettuare un sondaggio per determinare quando le modifiche sono state completate.
$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
Esempio 2: questo esempio mostra come creare set di record di risorse alias. 'Z222222222' è l'ID della zona ospitata di Amazon Route 53 in cui stai creando il set di record di risorse alias. 'example.com' è l'apice della zona per cui desideri creare un alias e 'www.example.com' è un sottodominio per il quale desideri creare anche un alias. 'Z11111' è un esempio di ID di zona ospitata per il sistema di bilanciamento del carico e 'example-load-balancer-11.us-east-1.elb.amazonaws.com' è un esempio di nome di dominio del load balancer con cui Amazon Route 53 risponde alle domande relative a example.com e www.example.com. Per ulteriori dettagli, consulta la documentazione di Amazon Route 53. Puoi utilizzare il Get-R53Change cmdlet per effettuare un sondaggio per determinare quando le modifiche sono state completate.
$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
Esempio 3: questo esempio crea due record A per www.example.com. Un quarto delle volte (1/ (1+3)), Amazon Route 53 risponde alle domande relative a www.example.com con i due valori del primo set di record di risorse (192.0.2.9 e 192.0.2.10). Tre quarti delle volte (3/ (1+3)) Amazon Route 53 risponde alle domande relative a www.example.com con i due valori per il secondo set di record di risorse (192.0.2.11 e 192.0.2.12). Per ulteriori dettagli, consulta la documentazione di Amazon Route 53. Puoi utilizzare il Get-R53Change cmdlet per effettuare un sondaggio per determinare quando le modifiche sono state completate.
$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
Esempio 4: Questo esempio mostra come creare set di record di risorse alias ponderati presupponendo che example.com sia il dominio per il quale si desidera creare set di record di risorse alias ponderati. SetIdentifier differenzia i due set di record di risorse alias ponderati l'uno dall'altro. Questo elemento è obbligatorio perché gli elementi Name e Type hanno gli stessi valori per entrambi i set di record di risorse. Z11111 e Z33333 sono esempi di zona ospitata IDs per il sistema di ELB bilanciamento del carico specificato dal valore di. DNSName example-load-balancer-2222222222.us-east-1.elb.amazonaws.com e example-load-balancer -4444444444.us-east-1.elb.amazonaws.com sono esempi di domini Elastic Load Balancing da cui Amazon Route 53 risponde alle domande per example.com. Per ulteriori dettagli, consulta la documentazione di Amazon Route 53. Puoi utilizzare il Get-R53Change cmdlet per effettuare un sondaggio per determinare quando le modifiche sono state completate.
$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
Esempio 5: Questo esempio crea due set di record di risorse con alias di latenza, uno per un sistema di ELB bilanciamento del carico nella regione Stati Uniti occidentali (Oregon) (us-west-2) e un altro per un sistema di bilanciamento del carico nella regione Asia Pacifico (Singapore) (ap-southeast-1). Per ulteriori dettagli, consulta la documentazione di Amazon Route 53. Puoi utilizzare il Get-R53Change cmdlet per effettuare un sondaggio per determinare quando le modifiche sono state completate.
$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
-
Per API i dettagli, vedere ChangeResourceRecordSetsin AWS Tools for PowerShell Cmdlet Reference.
-