Registering, changing, and deleting records to Route 53 using AWS CLI

Registering, changing, and deleting records to Route 53 using AWS CLI

Share Everywhere

Table of contents

Note:

I verified the use of the parameter “–dns-name” in the command [aws route53 list-hosted-zones-by-name], The returned result did not meet the request. Example:

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

{
    "HostedZones": [
        {
            "Id": "/hostedzone/Z01404082JK1xxxxx",
            "Name": "dev.luvina.lixx.",
            "CallerReference": "19fc7ef0-58bb-4c14-b086-cd3c7fbbb838",
            "Config": {
                "Comment": "dev.luvina.lixx",
                "PrivateZone": false
            },
            "ResourceRecordSetCount": 14
        }
    ],
    "DNSName": "example.com",
    "IsTruncated": false,
    "MaxItems": "100" 
}

You can search for the zone ID from the host zone name by using the command [aws route53 list-hosted-zones] that specifies the parameter [–query] as shown in the sample below. [1]

Please note that you need to add [.] To the end of the domain name specified in the –query condition. Example: [example.com] → [example.com.]

Sample 1:

aws route53 list-hosted-zones --query "HostedZones[?Name=='example.com.'].Id" --output text

To register / change / delete records, please use the AWS CLI command [aws route53 change-resource-record-sets] as shown in the sample below. [2]

Sample 2:

aws route53 change-resource-record-sets --hosted-zone-id <YOUR_HOSTED_ZONE_ID> --change-batch file://example.json

The contents of the [example.json] file should look like this:

{
  "Comment": "optional comment about the changes in this change batch request",
  "Changes": 
  [
    {
      "Action": "CREATE",
      "ResourceRecordSet": 
      {
        "Name": "example.com",
        "Type": "A",
        "TTL": 3600,
        "ResourceRecords": 
        [
          {
            "Value": "xx.x.x.xx" 
          }
        ]
      }
    }
  ]
}

References:

[1] list-hosted-zones

https://awscli.amazonaws.com/v2/documentation/api/latest/reference/route53/list-hosted-zones.html

[2] change-resource-record-sets

https://awscli.amazonaws.com/v2/documentation/api/latest/reference/route53/change-resource-record-sets.html

Bạn thấy bài viết này như thế nào?
0 reactions

Add new comment

Restricted HTML

  • Allowed HTML tags: <a href hreflang> <em> <strong> <cite> <blockquote cite> <code> <ul type> <ol start type> <li> <dl> <dt> <dd> <h2 id> <h3 id> <h4 id> <h5 id> <h6 id>
  • Lines and paragraphs break automatically.
  • Web page addresses and email addresses turn into links automatically.
Image CAPTCHA
Enter the characters shown in the image.

Bài viết liên quan

Cùng mình đập hộp xem bên trong có gì nhé.

Câu chuyện học AWS nên học từ đâu và trở thành AWS Community Builder

Sau 2 tháng đăng ký làm thành viên của AWS Community Builder thì hôm nay mình đã nhận được quà của AWS từ Singapore.
Ngoài ra còn có rất nhiều câu chuyện và chia sẻ kỹ thuật hữu ích nữa

Ngoài ra còn có rất nhiều câu chuyện và chia sẻ kỹ thuật hữu ích nữa

Năm nay mình có dịp trở lại với Singapore, một đất nước rất xanh, sạch, và đẹp, ở đâu cũng thấy mọi người tập thể dục ngoài trời
Democratize analytics and machine learning with no-code AWS services

Democratize analytics and machine learning with no-code AWS services

Access to all data for fast analytics at scale is key for 360-degree projects involving data engineers
Train ML models quickly and cost-effectively with Amazon SageMaker

Train ML models quickly and cost-effectively with Amazon SageMaker

Training machine learning models at scale often requires significant investments
Go beyond insights to predictive analytics with Amazon Redshift ML and Amazon SageMaker Canvas

Go beyond insights to predictive analytics with Amazon Redshift ML and Amazon SageMaker Canvas

Organizations are managing more data than ever before, and data use is only continuing to expand.