Check A-Record Status using Boto Route53 after creation

443 views Asked by At

i looking for a method to get the status of a record (A-NAME) just created with route53. This is the code:

    changes = ResourceRecordSets(conn, "ZONEID")
    change = changes.add_change("STRING FOR ADD NEW SUBDOMAIN")
    change.add_value(MY_IP)
    action = changes.commit()
    j=json.loads(json.dumps(action))
    status = j['ChangeResourceRecordSetsResponse']['ChangeInfo']['Status']
    while status == 'PENDING':
         time.sleep(5)
         action.update() #THIS ACTION RETURN "NONE" and not update the previous state

Obviously if print the status variable it result always "PENDING"

Can anyone help me? Thanks in advance.

1

There are 1 answers

0
Ruben Alves On BEST ANSWER

I went through the same problem and this is how I have solved.

Assuming that you have the ID of the A Record and it's C2T9LA0WQGXVUX in the us-west-1 region, then we have:

import boto.route53
record_id = 'C2T9LA0WQGXVUX'
REGION = 'us-west-1'
AWS_S3_ACCESS_KEY_ID = 'my aws key'
AWS_S3_SECRET_ACCESS_KEY = 'my secret key'


connection = boto.route53.connect_to_region(REGION,
    aws_access_key_id=AWS_S3_ACCESS_KEY_ID,
    aws_secret_access_key=AWS_S3_SECRET_ACCESS_KEY
)

record_status = connection.get_change(change_id=record_id)

The response will be something like:

{u'GetChangeResponse': {u'ChangeInfo': {u'Status': u'INSYNC', u'SubmittedAt': u'2017-07-10T13:05:29.350Z', u'Id': u'/change/C2T9LA0WQGXVUX'}}}

So, you can get the status with:

print record_status['GetChangeResponse']['ChangeInfo']['Status']