我已经编写了一个python脚本,它根据传递的servicename(如ec2、rds等)标记资源。 我还标记了循环5个服务(ec2、rds、iam、cloudwatch、dynamodb)的“所有”。大约有650个ARN需要标记。 我知道每个.tag_resources()调用不超过20个ARN。这个问题我已经用20个批量解决了
但是,当返回值包含“ErrorCode:Throttling”时,表示AWS端点拒绝调用
你对解决这个问题有什么建议?我试过了。sleep()但还是有问题
编辑: 当排除“cloudwatch”时,它的工作性能良好
以下是执行get.resource()调用的helper函数的代码:
def __tagHelper(self,arns,n,tags):
batches = chunks(arns,n) # arns is a list containing 650 object, n = 20
failedTagTrys=[]
for batch in batches: # batch is of size 20
response = self.client.tag_resources(
ResourceARNList=batch,
Tags=tags
)
failedTagTrys.append(response['FailedResourcesMap'])
# Clean up the list by removing empty dictionaries
cleaned_FailedTagTrys=list(filter(None, failedTagTrys))
return cleaned_FailedTagTrys
我通过使用AWS资源组API绕过了这个问题
相关问题 更多 >
编程相关推荐