我一直在试图弄清楚为什么我的脚本中的这一步不工作,据我所知,我的用户有权在我们的AWS账户上做所有事情,所以我有点困惑。我想知道是否有一种方法可以从botocore或boto3本身获得回报,从而为您的用户确定缺少的iam权限,而不是找出您需要自己完成的工作的正确权限?boto3给予AccessDenied,有没有办法查找缺少的权限?
最初我曾zone_id配置from here
>>> dns_record = connection.change_resource_record_sets(
... HostedZoneId=zone_id,
... ChangeBatch={
... 'Changes': [
... {
... 'Action': action,
... 'ResourceRecordSet': {
... 'Name': name,
... 'Type': record_type,
... 'TTL': 60,
... 'AliasTarget': {
... 'HostedZoneId': zone_id,
... 'DNSName': destination,
... 'EvaluateTargetHealth': eval_health
... },
... }
... },
... ]
... }
...)
Traceback (most recent call last):
File "<stdin>", line 14, in <module>
File "/usr/lib/python2.7/site-packages/botocore/client.py", line 253, in _api_call
return self._make_api_call(operation_name, kwargs)
File "/usr/lib/python2.7/site-packages/botocore/client.py", line 543, in _make_api_call
raise error_class(parsed_response, operation_name)
botocore.exceptions.ClientError: An error occurred (AccessDenied) when calling the ChangeResourceRecordSets operation: User: arn:aws:iam::1337:user/rumbles is not authorized to access this resource
>>>
>>> print connection, zone_id, action, name, record_type, destination, eval_health
<botocore.client.Route53 object at 0x7f9049d64590> Z117KPS5GTRQ2G UPSERT test-rumbles.domain.com A some-elb-1337.us-east-1.elb.amazonaws.com False
如果我改变zone_id我们AWS域的区域,我得到:
>>> zone_id = "Z2401337RNHANU"
>>>
>>> try:
...
An error occurred (InvalidInput) when calling the ChangeResourceRecordSets operation: Invalid request
{'ResponseMetadata': {'RetryAttempts': 0, 'HTTPStatusCode': 400, 'RequestId': '2bfde962-0e81-11e7-b312-53961dec3e91', 'HTTPHeaders': {'x-amzn-requestid': '2bfde962-0e81-11e7-b312-53961dec3e91', 'date': 'Tue, 21 Mar 2017 21:56:00 GMT', 'content-length': '259', 'content-type': 'text/xml', 'connection': 'close'}}, 'Error': {'Message': 'Invalid request', 'Code': 'InvalidInput', 'Type': 'Sender'}}
我已经在之前查找到这些问题,我知道我必须为这个特定的工作找到正确的IAM许可(假设我在正确的道路上),但我想知道是否有某种方法可以从botocore返回这些信息?我没有花时间手工查看它,我不能得到拒绝我访问返回的IAM规则,除了以某种方式?
或者我在谈论我还没有找到/创建的功能请求?
的你可以尝试从AWS控制台做同样的事情zone_id,通常控制台将返回的内容许可需要。 – mootmoot
我的用户(同一用户)可以在AWS控制台中执行任何操作 – Rumbles
只需确保您使用root/admin来执行这些工作,还是以特定用户身份登录? – mootmoot