View a markdown version of this page

Contoh rute 53 menggunakan AWS CLI - AWS Command Line Interface

Terjemahan disediakan oleh mesin penerjemah. Jika konten terjemahan yang diberikan bertentangan dengan versi bahasa Inggris aslinya, utamakan versi bahasa Inggris.

Contoh rute 53 menggunakan AWS CLI

Contoh kode berikut menunjukkan cara melakukan tindakan dan menerapkan skenario umum dengan menggunakan AWS Command Line Interface dengan Route 53.

Tindakan merupakan kutipan kode dari program yang lebih besar dan harus dijalankan dalam konteks. Sementara tindakan menunjukkan cara memanggil fungsi layanan individual, Anda dapat melihat tindakan dalam konteks dalam skenario terkait.

Setiap contoh menyertakan tautan ke kode sumber lengkap, di mana Anda dapat menemukan instruksi tentang cara mengatur dan menjalankan kode dalam konteks.

Tindakan

Contoh kode berikut menunjukkan cara menggunakanchange-resource-record-sets.

AWS CLI

Untuk membuat, memperbarui, atau menghapus kumpulan rekaman sumber daya

Per change-resource-record-sets intah berikut membuat kumpulan catatan sumber daya menggunakan hosted-zone-id Z1R8UBAEXAMPLE dan JSON-formatted konfigurasi dalam fileC:\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.json

Untuk informasi selengkapnya, lihat POST ChangeResourceRecordSets di Referensi API Amazon Route 53.

Konfigurasi dalam file JSON tergantung pada jenis kumpulan rekaman sumber daya yang ingin Anda buat:

BasicWeightedAliasWeighted AliasLatencyLatency AliasFailoverFailover Alias

Sintaks Das ar:

{ "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" }, {...} ] } }, {...} ] }

Sintaks Tertimbang:

{ "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" } }, {...} ] }

Sintaks 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" } }, {...} ] }

Sintaks Alias Tertimbang:

{ "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" } }, {...} ] }

Sintaks Latensi:

{ "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" } }, {...} ] }

Sintaks Alias Latensi:

{ "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" } }, {...} ] }

Sintaks 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" } }, {...} ] }

Sintaks Alias 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" } }, {...} ] }

Contoh kode berikut menunjukkan cara menggunakanchange-tags-for-resource.

AWS CLI

Perintah berikut menambahkan tag bernama owner ke sumber healthcheck yang ditentukan oleh ID:

aws route53 change-tags-for-resource --resource-type healthcheck --resource-id 6233434j-18c1-34433-ba8e-3443434 --add-tags Key=owner,Value=myboss

Perintah berikut menghapus tag bernama owner dari sumber daya zona yang dihosting yang ditentukan oleh ID:

aws route53 change-tags-for-resource --resource-type hostedzone --resource-id Z1523434445 --remove-tag-keys owner

Contoh kode berikut menunjukkan cara menggunakancreate-health-check.

AWS CLI

Untuk membuat pemeriksaan kesehatan

Per create-health-check intah berikut membuat pemeriksaan kesehatan menggunakan referensi pemanggil 2014-04-01-18:47 dan JSON-formatted konfigurasi dalam file: C:\awscli\route53\create-health-check.json

aws route53 create-health-check --caller-reference 2014-04-01-18:47 --health-check-config file://C:\awscli\route53\create-health-check.json

Sintaks JSON:

{ "IPAddress": "IP address of the endpoint to check", "Port": port on the endpoint to check--required when Type is "TCP", "Type": "HTTP"|"HTTPS"|"HTTP_STR_MATCH"|"HTTPS_STR_MATCH"|"TCP", "ResourcePath": "path of the file that you want Amazon Route 53 to request--all Types except TCP", "FullyQualifiedDomainName": "domain name of the endpoint to check--all Types except TCP", "SearchString": "if Type is HTTP_STR_MATCH or HTTPS_STR_MATCH, the string to search for in the response body from the specified resource", "RequestInterval": 10 | 30, "FailureThreshold": integer between 1 and 10 }

Untuk menambahkan pemeriksaan kesehatan ke kumpulan rekaman sumber daya Route 53, gunakan change-resource-record-sets perintah.

Untuk informasi selengkapnya, lihat Pemeriksaan Kesehatan Amazon Route 53 dan Failover DNS di Panduan Pengembang Amazon Route 53.

Contoh kode berikut menunjukkan cara menggunakancreate-hosted-zone.

AWS CLI

Untuk membuat zona yang dihosting

Per create-hosted-zone intah berikut menambahkan zona yang dihosting bernama example.com menggunakan referensi 2014-04-01-18:47 pemanggil. Komentar opsional menyertakan spasi, sehingga harus dilampirkan dalam tanda kutip:

aws route53 create-hosted-zone --name example.com --caller-reference 2014-04-01-18:47 --hosted-zone-config Comment="command-line version"

Untuk informasi selengkapnya, lihat Bekerja dengan Zona yang Dihosting di Panduan Pengembang Amazon Route 53.

Contoh kode berikut menunjukkan cara menggunakandelete-health-check.

AWS CLI

Untuk menghapus pemeriksaan kesehatan

Per delete-health-check intah berikut menghapus pemeriksaan kesehatan dengan a health-check-id of: e75b48d9-547a-4c3d-88a5-ae4002397608

aws route53 delete-health-check --health-check-id e75b48d9-547a-4c3d-88a5-ae4002397608

Contoh kode berikut menunjukkan cara menggunakandelete-hosted-zone.

AWS CLI

Untuk menghapus zona yang dihosting

Per delete-hosted-zone intah berikut menghapus zona yang dihosting dengan id dariZ36KTIQEXAMPLE:

aws route53 delete-hosted-zone --id Z36KTIQEXAMPLE

Contoh kode berikut menunjukkan cara menggunakanget-change.

AWS CLI

Untuk mendapatkan status perubahan pada kumpulan rekaman sumber daya

Per get-change intah berikut mendapatkan status dan informasi lain tentang change-resource-record-sets permintaan Id yang memiliki/change/CWPIK4URU2I5S:

aws route53 get-change --id /change/CWPIK4URU2I5S
  • Untuk detail API, lihat GetChange di Refer AWS CLI ensi Perintah.

Contoh kode berikut menunjukkan cara menggunakanget-health-check.

AWS CLI

Untuk mendapatkan informasi tentang pemeriksaan kesehatan

Per get-health-check intah berikut mendapatkan informasi tentang pemeriksaan kesehatan health-check-id yang memiliki02ec8401-9879-4259-91fa-04e66d094674:

aws route53 get-health-check --health-check-id 02ec8401-9879-4259-91fa-04e66d094674

Contoh kode berikut menunjukkan cara menggunakanget-hosted-zone.

AWS CLI

Untuk mendapatkan informasi tentang zona yang dihosting

Per get-hosted-zone intah berikut mendapatkan informasi tentang zona yang dihosting id denganZ1R8UBAEXAMPLE:

aws route53 get-hosted-zone --id Z1R8UBAEXAMPLE

Contoh kode berikut menunjukkan cara menggunakanlist-health-checks.

AWS CLI

Untuk membuat daftar pemeriksaan kesehatan yang terkait dengan AWS akun saat ini

Per list-health-checks intah berikut mencantumkan informasi terperinci tentang 100 pemeriksaan kesehatan pertama yang terkait dengan AWS akun saat ini. :

aws route53 list-health-checks

Jika Anda memiliki lebih dari 100 pemeriksaan kesehatan, atau jika Anda ingin mencantumkannya dalam kelompok yang lebih kecil dari 100, sertakan --maxitems parameter. Misalnya, untuk mencantumkan pemeriksaan kesehatan satu per satu, gunakan perintah berikut:

aws route53 list-health-checks --max-items 1

Untuk melihat pemeriksaan kesehatan berikutnya, ambil nilai NextToken dari respons ke perintah sebelumnya, dan sertakan dalam --starting-token parameter, misalnya:

aws route53 list-health-checks --max-items 1 --starting-token Z3M3LMPEXAMPLE

Contoh kode berikut menunjukkan cara menggunakanlist-hosted-zones-by-name.

AWS CLI

Perintah berikut mencantumkan hingga 100 zona yang dihosting diurutkan berdasarkan nama domain:

aws route53 list-hosted-zones-by-name

Output:

{ "HostedZones": [ { "ResourceRecordSetCount": 2, "CallerReference": "test20150527-2", "Config": { "Comment": "test2", "PrivateZone": false }, "Id": "/hostedzone/Z119WBBTVP5WFX", "Name": "2.example.com." }, { "ResourceRecordSetCount": 2, "CallerReference": "test20150527-1", "Config": { "Comment": "test", "PrivateZone": false }, "Id": "/hostedzone/Z3P5QSUBK4POTI", "Name": "www.example.com." } ], "IsTruncated": false, "MaxItems": "100" }

Perintah berikut mencantumkan zona yang dihosting diurutkan berdasarkan nama, dimulai denganwww.example.com:

aws route53 list-hosted-zones-by-name --dns-name www.example.com

Output:

{ "HostedZones": [ { "ResourceRecordSetCount": 2, "CallerReference": "mwunderl20150527-1", "Config": { "Comment": "test", "PrivateZone": false }, "Id": "/hostedzone/Z3P5QSUBK4POTI", "Name": "www.example.com." } ], "DNSName": "www.example.com", "IsTruncated": false, "MaxItems": "100" }

Contoh kode berikut menunjukkan cara menggunakanlist-hosted-zones.

AWS CLI

Untuk membuat daftar zona yang dihosting yang terkait dengan AWS akun saat ini

Per list-hosted-zones intah berikut mencantumkan informasi ringkasan tentang 100 zona host pertama yang terkait dengan AWS akun saat ini. :

aws route53 list-hosted-zones

Jika Anda memiliki lebih dari 100 zona yang dihosting, atau jika Anda ingin mencantumkannya dalam grup yang lebih kecil dari 100, sertakan --max-items parameter. Misalnya, untuk membuat daftar zona yang dihosting satu per satu, gunakan perintah berikut:

aws route53 list-hosted-zones --max-items 1

Untuk melihat informasi tentang zona yang dihosting berikutnya, ambil nilai NextToken dari respons ke perintah sebelumnya, dan sertakan dalam --starting-token parameter, misalnya:

aws route53 list-hosted-zones --max-items 1 --starting-token Z3M3LMPEXAMPLE

Contoh kode berikut menunjukkan cara menggunakanlist-query-logging-configs.

AWS CLI

Untuk mencantumkan konfigurasi pencatatan kueri

list-query-logging-configsContoh berikut mencantumkan informasi tentang 100 konfigurasi pencatatan kueri pertama di AWS akun Anda, untuk zona yang dihostingZ1OX3WQEXAMPLE.

aws route53 list-query-logging-configs \ --hosted-zone-id Z1OX3WQEXAMPLE

Output:

{ "QueryLoggingConfigs": [ { "Id": "964ff34e-ae03-4f06-80a2-9683cexample", "HostedZoneId": "Z1OX3WQEXAMPLE", "CloudWatchLogsLogGroupArn": "arn:aws:logs:us-east-1:111122223333:log-group:/aws/route53/example.com:*" } ] }

Untuk informasi selengkapnya, lihat Pencatatan kueri DNS di Panduan Pengembang Amazon Route 53.

Contoh kode berikut menunjukkan cara menggunakanlist-resource-record-sets.

AWS CLI

Untuk membuat daftar kumpulan rekaman sumber daya di zona yang dihosting

Per list-resource-record-sets intah berikut mencantumkan informasi ringkasan tentang 100 set rekaman sumber daya pertama di zona yang dihosting tertentu. :

aws route53 list-resource-record-sets --hosted-zone-id Z2LD58HEXAMPLE

Jika zona yang dihosting berisi lebih dari 100 set rekaman sumber daya, atau jika Anda ingin mencantumkannya dalam grup yang lebih kecil dari 100, sertakan --maxitems parameter. Misalnya, untuk mencantumkan kumpulan rekaman sumber daya satu per satu, gunakan perintah berikut:

aws route53 list-resource-record-sets --hosted-zone-id Z2LD58HEXAMPLE --max-items 1

Untuk melihat informasi tentang rekaman sumber daya berikutnya yang ditetapkan di zona yang dihosting, ambil nilai NextToken dari respons ke perintah sebelumnya, dan sertakan dalam --starting-token parameter, misalnya:

aws route53 list-resource-record-sets --hosted-zone-id Z2LD58HEXAMPLE --max-items 1 --starting-token Z3M3LMPEXAMPLE

Untuk melihat semua set rekaman sumber daya dari nama tertentu, gunakan --query parameter untuk menyaringnya. Contoh:

aws route53 list-resource-record-sets --hosted-zone-id Z2LD58HEXAMPLE --query "ResourceRecordSets[?Name == 'example.domain.']"