Created
August 3, 2016 16:36
-
-
Save rotemtam/b4474f732674a9fd5884719d8c5bdf3e to your computer and use it in GitHub Desktop.
Add a CNAME record in Route53 using python boto3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import boto3 | |
client = boto3.client('route53') | |
def add_cname_record(source, target): | |
try: | |
response = client.change_resource_record_sets( | |
HostedZoneId='<hosted zone id>', | |
ChangeBatch= { | |
'Comment': 'add %s -> %s' % (source, target), | |
'Changes': [ | |
{ | |
'Action': 'UPSERT', | |
'ResourceRecordSet': { | |
'Name': source, | |
'Type': 'CNAME', | |
'TTL': 300, | |
'ResourceRecords': [{'Value': target}] | |
} | |
}] | |
}) | |
except Exception as e: | |
print e |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If you use Route53Client for PHP, copy this code and change variables
You can also wait for the answer from route53