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.
Topik
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-setsintah berikut membuat kumpulan catatan sumber daya menggunakanhosted-zone-idZ1R8UBAEXAMPLEdan JSON-formatted konfigurasi dalam fileC:\awscli\route53\change-resource-record-sets.json:aws 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 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" } }, {...} ] }-
Untuk detail API, lihat ChangeResourceRecordSets
di Refer AWS CLI ensi Perintah.
-
Contoh kode berikut menunjukkan cara menggunakanchange-tags-for-resource.
- AWS CLI
-
Perintah berikut menambahkan tag bernama
ownerke sumber healthcheck 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 yang dihosting yang ditentukan oleh ID:aws route53 change-tags-for-resource --resource-typehostedzone--resource-idZ1523434445--remove-tag-keysowner-
Untuk detail API, lihat ChangeTagsForResource
di Refer AWS CLI ensi Perintah.
-
Contoh kode berikut menunjukkan cara menggunakancreate-health-check.
- AWS CLI
-
Untuk membuat pemeriksaan kesehatan
Per
create-health-checkintah berikut membuat pemeriksaan kesehatan menggunakan referensi pemanggil2014-04-01-18:47dan JSON-formatted konfigurasi 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 rekaman sumber daya Route 53, gunakan
change-resource-record-setsperintah.Untuk informasi selengkapnya, lihat Pemeriksaan Kesehatan Amazon Route 53 dan Failover DNS di Panduan Pengembang Amazon Route 53.
-
Untuk detail API, lihat CreateHealthCheck
di Refer AWS CLI ensi Perintah.
-
Contoh kode berikut menunjukkan cara menggunakancreate-hosted-zone.
- AWS CLI
-
Untuk membuat zona yang dihosting
Per
create-hosted-zoneintah berikut menambahkan zona yang dihosting bernamaexample.commenggunakan referensi2014-04-01-18:47pemanggil. Komentar opsional menyertakan 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 Refer AWS CLI ensi Perintah.
-
Contoh kode berikut menunjukkan cara menggunakandelete-health-check.
- AWS CLI
-
Untuk menghapus pemeriksaan kesehatan
Per
delete-health-checkintah berikut menghapus pemeriksaan kesehatan dengan ahealth-check-idof:e75b48d9-547a-4c3d-88a5-ae4002397608aws route53 delete-health-check --health-check-ide75b48d9-547a-4c3d-88a5-ae4002397608-
Untuk detail API, lihat DeleteHealthCheck
di Refer AWS CLI ensi Perintah.
-
Contoh kode berikut menunjukkan cara menggunakandelete-hosted-zone.
- AWS CLI
-
Untuk menghapus zona yang dihosting
Per
delete-hosted-zoneintah berikut menghapus zona yang dihosting denganiddariZ36KTIQEXAMPLE:aws route53 delete-hosted-zone --idZ36KTIQEXAMPLE-
Untuk detail API, lihat DeleteHostedZone
di Refer AWS CLI ensi Perintah.
-
Contoh kode berikut menunjukkan cara menggunakanget-change.
- AWS CLI
-
Untuk mendapatkan status perubahan pada kumpulan rekaman sumber daya
Per
get-changeintah berikut mendapatkan status dan informasi lain tentangchange-resource-record-setspermintaanIdyang 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-checkintah 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 Refer AWS CLI ensi Perintah.
-
Contoh kode berikut menunjukkan cara menggunakanget-hosted-zone.
- AWS CLI
-
Untuk mendapatkan informasi tentang zona yang dihosting
Per
get-hosted-zoneintah berikut mendapatkan informasi tentang zona yang dihostingiddenganZ1R8UBAEXAMPLE:aws route53 get-hosted-zone --idZ1R8UBAEXAMPLE-
Untuk detail API, lihat GetHostedZone
di Refer AWS CLI ensi Perintah.
-
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-checksintah 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
--maxitemsparameter. Misalnya, untuk mencantumkan 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 Refer AWS CLI ensi Perintah.
-
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-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 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 Refer AWS CLI ensi Perintah.
-
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-zonesintah 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-itemsparameter. Misalnya, untuk membuat daftar zona yang dihosting satu per satu, gunakan perintah berikut:aws route53 list-hosted-zones --max-items1Untuk melihat informasi tentang zona yang dihosting berikutnya, ambil nilai
NextTokendari respons ke perintah sebelumnya, dan sertakan dalam--starting-tokenparameter, misalnya:aws route53 list-hosted-zones --max-items1--starting-tokenZ3M3LMPEXAMPLE-
Untuk detail API, lihat ListHostedZones
di Refer AWS CLI ensi Perintah.
-
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-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 Pencatatan kueri DNS di Panduan Pengembang Amazon Route 53.
-
Untuk detail API, lihat ListQueryLoggingConfigs
di Refer AWS CLI ensi Perintah.
-
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-setsintah berikut mencantumkan informasi ringkasan tentang 100 set rekaman sumber daya pertama di zona yang dihosting tertentu. :aws route53 list-resource-record-sets --hosted-zone-idZ2LD58HEXAMPLEJika zona yang dihosting berisi lebih dari 100 set rekaman sumber daya, atau jika Anda ingin mencantumkannya dalam grup yang lebih kecil dari 100, sertakan
--maxitemsparameter. Misalnya, untuk mencantumkan kumpulan rekaman sumber daya satu per satu, gunakan perintah berikut:aws route53 list-resource-record-sets --hosted-zone-idZ2LD58HEXAMPLE--max-items1Untuk melihat informasi tentang rekaman 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 set rekaman sumber daya dari nama tertentu, gunakan
--queryparameter untuk menyaringnya. Contoh:aws route53 list-resource-record-sets --hosted-zone-idZ2LD58HEXAMPLE--query"ResourceRecordSets[?Name == 'example.domain.']"-
Untuk detail API, lihat ListResourceRecordSets
di Refer AWS CLI ensi Perintah.
-