[PYTHON] Operate Route53 on the command line using AWS-CLI.

Prerequisites

・ Windows terminal (author is win10) ・ Python installed

What to do

Set records on Route 53 on the command line using AWS-CLI

procedure

Check python version

Check if python is included (image is 3.8.1)

>python --version
Python 3.8.1

Install the AWS CLI using pip

> pip3 install awscli

Check the path

where /R c:\ aws

Path setting

Press the Windows button and enter "environment variables" in the search box to search and set the Path displayed above

[Example] Display result: In the case of "c: [user directory] \ Python \ Python37 \ Scripts \ aws" Settings: c: [userdirectory] \ Python \ Python37 \ Scripts ** * There was also an option to set the PATH when installing python. ** **

Check AWS CLI version

>aws --version
aws-cli/1.18.3 Python/3.8.1 Windows/10 botocore/1.15.3

Create a user in IAM

Download accessKeys.csv.

Credential settings

> aws configure

Enter the following.

> AWS Access Key ID [None]: Enter the Access key ID of the csv file
> Secret access key:Enter the Secret access key in the csv file
> Default region name [None]: ap-northeast-1
> Default output format [None]:json

Actually set a record

Create sample.json

{
            "Comment": "CREATE/DELETE/UPSERT a record ",
            "Changes": [{
            "Action": "CREATE",
                        "ResourceRecordSet": {
                                    "Name": "a.example.com",
                                    "Type": "A",
                                    "TTL": 300,
                                    "ResourceRecords": [{ "Value": "4.4.4.4"}]
}}]
}

Use the command ** change-resource-record-sets ** to create a resource record set for your domain in the hosted zone. The value for creating the record is specified in the sample.json file.

Command execution

aws route53 change-resource-record-sets --hosted-zone-id ZXXXXXXXXXX --change-batch file://sample.json

If there are no errors in the JSON file, PENDING is returned as the status with a unique ID.

$ aws route53 change-resource-record-sets --hosted-zone-id ZXXXXXXXXXXX --change-batch file://sample.json
{
    "ChangeInfo": {
        "Status": "PENDING", 
        "Comment": "optional comment about the changes in this change batch request", 
        "SubmittedAt": "2018-07-10T19:39:37.757Z", 
        "Id": "/change/C3QYC83OA0KX5K"
    }
}

To check the status of changes, use the Id value in the change-resource-record-sets response in the API call get-change.

aws route53  get-change --id /change/C3QYC83OA0KX5K

· *** PENDING *** indicates that the change in this request has not yet been propagated to the server. · *** INSYNC *** indicates that changes have been propagated to the server.

Recommended Posts

Operate Route53 on the command line using AWS-CLI.
Syntax highlighting on the command line using Pygments
Keep getting RSS on the command line
You search commandlinefu on the command line
Quickly display the QR code on the command line
Arduino development on the command line: vim + platformio
Convert XLSX to CSV on the command line
Think about the selective interface on the command line
Clone using the dd command
Broadcast on LINE using python
Steps to use the AWS command line interface (Python / awscli) on Mac OS X
Search for large files on Linux from the command line
Using cgo with the go command
Notes on using matplotlib on the server
[Python] I wrote the route of the typhoon on the map using folium
Python standard module that can be used on the command line
Notes on using OpenCL on Linux on the RX6800
Execute the COPY command using python's Psycopg
Look up your Mac's Wi-Fi network name (SSID) on the command line
Correspondence memo when the direction key cannot be used on the python command line
Automatically write admin.py using the django-extensions admin_generator command
Python: Try using the UI on Pythonista 3 on iPad
Frequently used (personally) notes on the tar command
Try using LINE Notify for the time being
The story of misreading the swap line of the top command
My thoughts on python2.6 command line app template
Operate the schedule app using python from iphone
Sound the buzzer using python on Raspberry Pi 3!
Create a GUI on the terminal using curses
How to pass arguments when invoking python script from blender on the command line
How to create an article from the command line
How to write a GUI using the maya command
Open Chrome version of LINE from the command line [Linux]
Try using the temperature sensor (LM75B) on the Raspberry Pi.
Drawing on Jupyter using the plot function of pandas
Post to your account using the API on Twitter
Execute the command on the web server and display the result
Make Python segfault on one line without using ctypes
I want to automate ssh using the expect command!
Multiply PDF by OCR on command line on Linux (Ubuntu)
(Remember quickly) How to use the LINUX command line
I tried to notify the honeypot report on LINE