我编写了一个python脚本,该脚本基于传递的服务名(例如ec2,rds等)标记资源。 我还标记了通过5个服务(ec2,rds,iam,cloudwatch,dynamodb)循环的“全部”。大约有650个ARN要标记。 我知道eacht .tag_resources()调用最多需要20个arn。我已经通过使用大小为20的批处理解决了这个问题。
但是,当返回值包含'ErrorCode:Throttling'时,意味着AWS终端节点拒绝该呼叫。
您对解决此问题有何建议?我用time.sleep()尝试过,但是仍然有问题。
编辑: 排除“ cloudwatch”时,可以正常运行。
这是执行get.resource()调用的辅助函数的代码:
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
答案 0 :(得分:0)
我通过使用AWS Resource Groups API绕过了这个问题。