如果我只在新加坡地区有实例,是否可以使用boto3.client('support')?

时间:2016-02-02 06:59:18

标签: python amazon-web-services boto boto3 amazon-iam

这是我的代码,

session = Session(access_key_id='',secret_access_key='',region_name='ap-southeast-1')
conn = session.client('support')
checks = conn.describe_trusted_advisor_checks(language='en')

这给了我以下错误,

Could not connect to the endpoint URL: "https://support.ap-southeast-1.amazonaws.com/"

如此处所述,AWS支持只有一个终点,

http://docs.aws.amazon.com/general/latest/gr/rande.html#awssupport_region

所以我将region_name更改为us-east-1

现在代码看起来,

session = Session(access_key_id='',secret_access_key='',region_name='us-east-1')
conn = session.client('support')
checks = conn.describe_trusted_advisor_checks(language='en')

但现在我面对这个错误,

botocore.exceptions.ClientError: An error occurred (AccessDeniedException) when calling the DescribeTrustedAdvisorChecks operation: User: abc is not authorized to perform: support:

我只在新加坡地区有实例,为什么会出现此错误,我可以使用support,即使我只有Singapore region中的实例且端点为us-east-1

3 个答案:

答案 0 :(得分:2)

AWS Support不是特定于地区的。您需要附加到用户的IAM政策AWSSupportAccess

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Action": ["support:*"],
      "Resource": "*"
    }
  ]
}

请参阅我对类似问题的回答:AccessDeniedException on aws when i'm trying to raise a support ticket

答案 1 :(得分:1)

使用上面的代码时,我必须做3件事才能完成这项工作:

  1. 将区域设置为us-east-1
  2. AWSSupportAccess角色分配给我的用户/群组
  3. 启用AWS Business Support

答案 2 :(得分:0)

我认为您所遇到的错误与您的实例位于ap-southeast-1区域的事实无关。该错误表示您在连接到支持服务时使用的凭据尚未被授予在支持服务中执行操作所需的权限。

检查与您的凭据相关联的政策,并确保其中包含授予support服务访问权限的操作。