Terjemahan disediakan oleh mesin penerjemah. Jika konten terjemahan yang diberikan bertentangan dengan versi bahasa Inggris aslinya, utamakan versi bahasa Inggris.
Rute 53 contoh menggunakan AWS CLI
Contoh kode berikut menunjukkan cara melakukan tindakan dan mengimplementasikan skenario umum dengan menggunakan AWS Command Line Interface with 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.
Topik
Tindakan
Contoh kode berikut menunjukkan cara menggunakanchange-resource-record-sets.
- AWS CLI
-
Untuk membuat, memperbarui, atau menghapus kumpulan catatan sumber daya
change-resource-record-setsPerintah berikut membuat catatan sumber daya yang ditetapkan menggunakanhosted-zone-idZ1R8UBAEXAMPLEdan konfigurasi berformat JSON dalam file:C:\awscli\route53\change-resource-record-sets.jsonaws route53 change-resource-record-sets --hosted-zone-idZ1R8UBAEXAMPLE--change-batch file://C:\awscli\route53\change-resource-record-sets.jsonUntuk informasi selengkapnya, lihat POST ChangeResourceRecordSets di Referensi API Amazon Route 53.
Konfigurasi dalam file JSON tergantung pada jenis kumpulan catatan sumber daya yang ingin Anda buat:
BasicWeightedAliasWeighted AliasLatencyLatency AliasFailoverFailover Alias
Sintaks dasar:
{ "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" } }, {...} ] }-
Untuk detail API, lihat ChangeResourceRecordSets
di Referensi AWS CLI Perintah.
-
Contoh kode berikut menunjukkan cara menggunakanchange-tags-for-resource.
- AWS CLI
-
Perintah berikut menambahkan tag bernama
ownerke sumber daya pemeriksaan kesehatan yang ditentukan oleh ID:aws route53 change-tags-for-resource --resource-typehealthcheck--resource-id6233434j-18c1-34433-ba8e-3443434--add-tagsKey=owner,Value=mybossPerintah berikut menghapus tag bernama
ownerdari sumber daya zona host yang ditentukan oleh ID:aws route53 change-tags-for-resource --resource-typehostedzone--resource-idZ1523434445--remove-tag-keysowner-
Untuk detail API, lihat ChangeTagsForResource
di Referensi AWS CLI Perintah.
-
Contoh kode berikut menunjukkan cara menggunakancreate-health-check.
- AWS CLI
-
Untuk membuat pemeriksaan kesehatan
create-health-checkPerintah berikut membuat pemeriksaan kesehatan menggunakan referensi pemanggil2014-04-01-18:47dan konfigurasi berformat JSON dalam file:C:\awscli\route53\create-health-check.jsonaws route53 create-health-check --caller-reference2014-04-01-18:47--health-check-config file://C:\awscli\route53\create-health-check.jsonSintaks 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 catatan sumber daya Route 53, gunakan
change-resource-record-setsperintah.Untuk informasi selengkapnya, lihat Amazon Route 53 Health Checks dan DNS Failover di Panduan Pengembang Amazon Route 53.
-
Untuk detail API, lihat CreateHealthCheck
di Referensi AWS CLI Perintah.
-
Contoh kode berikut menunjukkan cara menggunakancreate-hosted-zone.
- AWS CLI
-
Untuk membuat zona yang dihosting
create-hosted-zonePerintah berikut menambahkan zona host bernamaexample.commenggunakan referensi2014-04-01-18:47pemanggil. Komentar opsional mencakup spasi, sehingga harus dilampirkan dalam tanda kutip:aws route53 create-hosted-zone --nameexample.com--caller-reference2014-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.
-
Untuk detail API, lihat CreateHostedZone
di Referensi AWS CLI Perintah.
-
Contoh kode berikut menunjukkan cara menggunakandelete-health-check.
- AWS CLI
-
Untuk menghapus pemeriksaan kesehatan
delete-health-checkPerintah berikut menghapus pemeriksaan kesehatan denganhealth-check-iddarie75b48d9-547a-4c3d-88a5-ae4002397608:aws route53 delete-health-check --health-check-ide75b48d9-547a-4c3d-88a5-ae4002397608-
Untuk detail API, lihat DeleteHealthCheck
di Referensi AWS CLI Perintah.
-
Contoh kode berikut menunjukkan cara menggunakandelete-hosted-zone.
- AWS CLI
-
Untuk menghapus zona yang dihosting
delete-hosted-zonePerintah berikut menghapus zona yang dihosting denganiddariZ36KTIQEXAMPLE:aws route53 delete-hosted-zone --idZ36KTIQEXAMPLE-
Untuk detail API, lihat DeleteHostedZone
di Referensi AWS CLI Perintah.
-
Contoh kode berikut menunjukkan cara menggunakanget-change.
- AWS CLI
-
Untuk mendapatkan status perubahan pada kumpulan rekaman sumber daya
get-changePerintah berikut mendapatkan status dan informasi lain tentangchange-resource-record-setspermintaan yang memilikiIddari/change/CWPIK4URU2I5S:aws route53 get-change --id/change/CWPIK4URU2I5S-
Untuk detail API, lihat GetChange
di Referensi AWS CLI Perintah.
-
Contoh kode berikut menunjukkan cara menggunakanget-health-check.
- AWS CLI
-
Untuk mendapatkan informasi tentang pemeriksaan kesehatan
get-health-checkPerintah berikut mendapatkan informasi tentang pemeriksaan kesehatanhealth-check-idyang memiliki02ec8401-9879-4259-91fa-04e66d094674:aws route53 get-health-check --health-check-id02ec8401-9879-4259-91fa-04e66d094674-
Untuk detail API, lihat GetHealthCheck
di Referensi AWS CLI Perintah.
-
Contoh kode berikut menunjukkan cara menggunakanget-hosted-zone.
- AWS CLI
-
Untuk mendapatkan informasi tentang zona yang dihosting
get-hosted-zonePerintah berikut mendapatkan informasi tentang zona yang dihosting denganiddariZ1R8UBAEXAMPLE:aws route53 get-hosted-zone --idZ1R8UBAEXAMPLE-
Untuk detail API, lihat GetHostedZone
di Referensi AWS CLI Perintah.
-
Contoh kode berikut menunjukkan cara menggunakanlist-health-checks.
- AWS CLI
-
Untuk membuat daftar pemeriksaan kesehatan yang terkait dengan AWS akun saat ini
list-health-checksPerintah berikut mencantumkan informasi terperinci tentang 100 pemeriksaan kesehatan pertama yang terkait dengan AWS akun saat ini. :aws route53 list-health-checksJika Anda memiliki lebih dari 100 pemeriksaan kesehatan, atau jika Anda ingin mencantumkannya dalam kelompok yang lebih kecil dari 100, sertakan
--maxitemsparameternya. Misalnya, untuk membuat daftar pemeriksaan kesehatan satu per satu, gunakan perintah berikut:aws route53 list-health-checks --max-items1Untuk melihat pemeriksaan kesehatan berikutnya, ambil nilai
NextTokendari respons ke perintah sebelumnya, dan sertakan dalam--starting-tokenparameter, misalnya:aws route53 list-health-checks --max-items1--starting-tokenZ3M3LMPEXAMPLE-
Untuk detail API, lihat ListHealthChecks
di Referensi AWS CLI Perintah.
-
Contoh kode berikut menunjukkan cara menggunakanlist-hosted-zones-by-name.
- AWS CLI
-
Perintah berikut mencantumkan hingga 100 zona yang dihosting yang diurutkan berdasarkan nama domain:
aws route53 list-hosted-zones-by-nameOutput:
{ "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 yang diurutkan berdasarkan nama, dimulai dengan
www.example.com:aws route53 list-hosted-zones-by-name --dns-namewww.example.comOutput:
{ "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" }-
Untuk detail API, lihat ListHostedZonesByName
di Referensi AWS CLI Perintah.
-
Contoh kode berikut menunjukkan cara menggunakanlist-hosted-zones.
- AWS CLI
-
Untuk membuat daftar zona yang dihosting yang terkait dengan AWS akun saat ini
list-hosted-zonesPerintah berikut mencantumkan informasi ringkasan tentang 100 zona host pertama yang terkait dengan AWS akun saat ini. :aws route53 list-hosted-zonesJika Anda memiliki lebih dari 100 zona yang dihosting, atau jika Anda ingin mencantumkannya dalam grup yang lebih kecil dari 100, sertakan
--max-itemsparameternya. Misalnya, untuk membuat daftar zona yang dihosting satu per satu, gunakan perintah berikut:aws route53 list-hosted-zones --max-items1Untuk melihat informasi tentang zona host berikutnya, ambil nilai
NextTokendari respon ke perintah sebelumnya, dan sertakan dalam--starting-tokenparameter, misalnya:aws route53 list-hosted-zones --max-items1--starting-tokenZ3M3LMPEXAMPLE-
Untuk detail API, lihat ListHostedZones
di Referensi AWS CLI Perintah.
-
Contoh kode berikut menunjukkan cara menggunakanlist-query-logging-configs.
- AWS CLI
-
Untuk membuat daftar konfigurasi pencatatan kueri
list-query-logging-configsContoh berikut mencantumkan informasi tentang 100 konfigurasi pencatatan kueri pertama di AWS akun Anda, untuk zonaZ1OX3WQEXAMPLEyang dihosting.aws route53 list-query-logging-configs \ --hosted-zone-idZ1OX3WQEXAMPLEOutput:
{ "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 Mencatat kueri DNS di Panduan Pengembang Amazon Route 53.
-
Untuk detail API, lihat ListQueryLoggingConfigs
di Referensi AWS CLI Perintah.
-
Contoh kode berikut menunjukkan cara menggunakanlist-resource-record-sets.
- AWS CLI
-
Untuk mencantumkan kumpulan rekaman sumber daya di zona yang dihosting
list-resource-record-setsPerintah berikut mencantumkan informasi ringkasan tentang 100 set catatan sumber daya pertama di zona host tertentu. :aws route53 list-resource-record-sets --hosted-zone-idZ2LD58HEXAMPLEJika zona yang dihosting berisi lebih dari 100 kumpulan catatan sumber daya, atau jika Anda ingin mencantumkannya dalam grup yang lebih kecil dari 100, sertakan
--maxitemsparameternya. Misalnya, untuk mencantumkan set catatan sumber daya satu per satu, gunakan perintah berikut:aws route53 list-resource-record-sets --hosted-zone-idZ2LD58HEXAMPLE--max-items1Untuk melihat informasi tentang catatan sumber daya berikutnya yang ditetapkan di zona yang dihosting, ambil nilai
NextTokendari respons ke perintah sebelumnya, dan sertakan dalam--starting-tokenparameter, misalnya:aws route53 list-resource-record-sets --hosted-zone-idZ2LD58HEXAMPLE--max-items1--starting-tokenZ3M3LMPEXAMPLEUntuk melihat semua kumpulan catatan sumber daya dari nama tertentu, gunakan
--queryparameter untuk memfilternya. Misalnya:aws route53 list-resource-record-sets --hosted-zone-idZ2LD58HEXAMPLE--query"ResourceRecordSets[?Name == 'example.domain.']"-
Untuk detail API, lihat ListResourceRecordSets
di Referensi AWS CLI Perintah.
-