Python boto3 route53简单错误示例

2024-06-16 12:29:51 发布

您现在位置:Python中文网/ 问答频道 /正文

下面的脚本(简化的、虚构的区域/zoneid)在运行时会给出错误

botocore.errorfactory.InvalidInput: An error occurred (InvalidInput) when calling the ChangeResourceRecordSets operation: Invalid request

#!/usr/bin/python3.3

import boto3

ipaddress = '10.32.24.82'

zoneid = 'Z3GJIR73GHRHXX'
response = boto3.client('route53').change_resource_record_sets(
     HostedZoneId=zoneid,
     ChangeBatch={
       'Comment': 'swarm manager',
       'Changes': [
         {
             'Action': 'UPSERT',
                       'ResourceRecordSet':
                    {
                     'TTL': 600,
                     'Name': 'www.giganticwasteoftime.com.',
                     'SetIdentifier': 'abc1',
                     'Type': 'A'
                     'ResourceRecords':
                         [{'Value': ipaddress}, ],
                    }
         }, ]
    }
)
print(response)

我以前做过成功的python脚本来查询route53,但是我从来没有写过

我在boto3上进行了pip安装更新,但是这些版本的python模块却出现了完全相同的错误: boto3-1.4.4 botocore-1.5.56 docutils-0.13.1 jmespath-0.9.2 python-dateutil-2.6.0 s3transfer-0.1.10


Tags: 脚本an区域response错误errorboto3ipaddress
1条回答
网友
1楼 · 发布于 2024-06-16 12:29:51

这不是pythonlibs的问题,错误来自AWS。从您的请求中省略SetIdentifier,因为您正在创建一个记录;如果域www.gigancwasteoftime.com存在它应该工作。在

来自boto3 docs

SetIdentifier (string)

Weighted, Latency, Geo, and Failover resource record sets only: An identifier that differentiates among multiple resource record sets that have the same combination of DNS name and type. The value of SetIdentifier must be unique for each resource record set that has the same combination of DNS name and type. Omit SetIdentifier for any other types of record sets.

相关问题 更多 >