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?
1 reaction

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.

Bài viết liên quan

Khám phá FinOps

Khám phá FinOps - công nghệ đám mây

Nhiều doanh nghiệp ngày nay lựa chọn chuyển sang công nghệ đám mây với hi vọng đạt được lợi thế cạnh tranh so với đối thủ nhờ tiềm năng về hiệu quả cao và tiết kiệm chi phí hơn của công nghệ này.
Microservices Roadmap

Microservices Roadmap

- Kafka, RabbitMQ, Amazon SQS: Efficient and reliable message brokers for seamless communication between microservices.
The Data Analyst Roadmap

The Data Analyst Roadmap

**Database Knowledge**: Gain proficiency in working with databases like MySQL, PostgreSQL, or MongoDB.
Architectural patterns in software design

Architectural patterns in software design

Choose the architecture that aligns with your application's unique needs and goals. Each pattern offers a tailored approach to elevate your software system!
Exploring the Technological Marvel Behind Netflix

Exploring the Technological Marvel Behind Netflix

Ever wondered about the tech wizardry that powers your binge-watching adventures on Netflix?