pythonamazon-web-servicesboto3amazon-route53

How to change the name of a record set in Route 53 using python boto3?


I am able to perform actions such as updating the value of a record set in Route 53, but can't find an api to rename an existing record set using python boto3. The Name parameter in the documentation is the Name of the record set which we want to change. How do I specify the new name for the record set?

See: boto3: change_resource_record_sets()


Solution

  • From one of my record files, which I used to update the route53 recordset. Hope it helps

    try:
        route53 = boto3.client('route53')
        route53.change_resource_record_sets(
            HostedZoneId = hosted_zone_id,
            ChangeBatch={
                'Changes': [
                    {
                        'Action': 'UPSERT',
                        'ResourceRecordSet': {
                            'Name': record_name,
                            'Type': 'A',
                            'ResourceRecords': [
                                {
                                    'Value': ipForRecord
                                }
                            ],
                            'TTL': 300
                        }
                    }
                ]
            } 
        )
    
    except Exception as e:
        print 'Exception while updating cloud 53 record'
        print e