Skip to main content
 首页 » 编程设计

python之如何使用 boto 在 route53 中的 DNS 记录上设置地理位置

2024年10月25日15jpfss

在下面的代码片段中,我将一个值添加到稍后提交的更改集中。

add = changes.add_change('CREATE', url, record_type, ttl=DEFAULT_TTL) 
add.add_value(new_val) 

如何向创建的记录添加地理位置?我可以在 [ http://boto.readthedocs.org/en/latest/ref/route53.html#module-boto.route53.record] 的文档中看到我应该能够通过添加 region="blah"参数来为基于延迟的路由添加区域。但是,我没有看到任何关于地理位置的提及。库是否能够处理地理定位路由策略?还是我只需要坚持延迟路由策略。

请您参考如下方法:

请尝试以下代码段。尝试通过“pip install boto3”安装 boto3

import boto3 
 
client = boto3.client('route53') 
response = client.change_resource_record_sets( 
    HostedZoneId='ZYMJVBD6FUN6S', 
    ChangeBatch={ 
        'Comment': 'comment', 
        'Changes': [ 
            { 
                'Action': 'CREATE', 
                'ResourceRecordSet': { 
                    'Name': 'udara.com', 
                    'Type': 'A', 
                    'SetIdentifier': 'Africa record', 
                    'GeoLocation': { 
                        'ContinentCode': 'AF' 
                    }, 
                    'TTL': 123, 
                    'ResourceRecords': [ 
                        { 
                            'Value': '127.0.0.1' 
                        }, 
                        ], 
                } 
            }, 
            ] 
    } 
)