首页 文章

尝试创建或Upsert Route53 A记录时出现InvalidInput错误

提问于
浏览
6

当我运行这个boto3创建或upsert A记录时,我得到错误:

文件 “./metakube.py”,线路523,在post_create self.route53_update_alias_record(self.fugu_editor_external_dns,fugu_elb_identifier)文件 “./metakube.py”,线508,在route53_update_alias_record 'EvaluateTargetHealth':假文件“/家/ pairaccount /.virtualenvs/fugui-devops/local/lib/python2.7/site-packages/botocore/client.py “线路236,在_api_call回报self._make_api_call(OPERATION_NAME,kwargs)文件” /home/pairaccount/.virtualenvs /fugui-devops/local/lib/python2.7/site-packages/botocore/client.py”,线路500,在_make_api_call提高ClientError(parsed_response,OPERATION_NAME)botocore.exceptions.ClientError:调用时发生错误(InvalidInput) ChangeResourceRecordSets操作:无效的请求

基于boto3文档,这看起来像是正确的输入 . 我们也尝试了一些不同的变体,但是当我们尝试使用下面的方法创建或Upsert A记录时,我们会收到此错误 . 我们有一个类似的方法,调用 change_resource_record_sets 删除A记录,它工作正常 .

有什么需要纠正的想法?

def route53_update_alias_record(self, external_dns_name, load_balancer_identifier):
    route53_client = boto3.client('route53')
    hosted_zone_id = self.get_hosted_zone_id(route53_client)

    response = route53_client.change_resource_record_sets(
        HostedZoneId=hosted_zone_id,
        ChangeBatch={
            'Comment': 'upsert alias record',
            'Changes': [
                {
                    'Action': 'UPSERT',
                    'ResourceRecordSet': {
                        'Name': external_dns_name,
                        'Type': 'A',
                        'Region': 'us-east-1',
                        'AliasTarget': {
                            'DNSName': load_balancer_identifier,
                            'HostedZoneId': 'Z3DZXE0Q79N41H',
                            'EvaluateTargetHealth': False
                        }
                    }
                }
            ]
        }
    )
    self.logger.info("Delete route53 alias {} response: {}".format(external_dns_name, response))

1 回答

  • 2

    你需要TTL

    喜欢 :

    response = client.change_resource_record_sets(
            HostedZoneId=hostedzoneid,
            ChangeBatch={
                'Comment': 'add record',
                'Changes': [
                    {
                        'Action': 'UPSERT',
                        'ResourceRecordSet': {
                            'Name': name,
                            'Type': 'A',
                            'TTL': ttl,
                            'ResourceRecords': [
                                {
                                    'Value': value
                                }
                            ]
                        }
                    }
                ]
            }
        )
    

相关问题