2017-08-25 18 views
1

我有多个AWS账户,需要使用自动方式(CLI或SDK)来确定账户是否有高级支持订阅。是否有自动方式查看AWS账户是否有高级支持订阅

本质上我想知道我是否可以使用Trusted Advisor的cloudwatch事件触发特定帐户的Lambda函数。

CLI上我可以运行:

aws support <command> 

,并会得到如果未启用高级支持一个错误,但有一个更好的方式来发现这一点?

回答

2

我还没有尝试过,但可以使用Boto3 SDK(Python)。来源:AWS Support

import boto3 

client = boto3.client('support') 

这些是可用的方法:

  • describe_cases()
  • describe_communications()
  • describe_services()
  • describe_severity_levels()
  • describe_trusted_advisor_check_refresh_statuses()
  • describe_trusted_advisor_check_result()
  • describe_trusted_advisor_check_summaries()
  • describe_trusted_advisor_checks()
  • refresh_trusted_advisor_check()
  • resolve_case()

我只是尝试一些的API。所有这些都由于缺乏高级支持而失败。所以,你运气不好。

>>> client.describe_services() 
botocore.exceptions.ClientError: An error occurred (SubscriptionRequiredException) when calling the DescribeServices operation: AWS Premium Support Subscription is required to use this service. 

>>> client.describe_trusted_advisor_checks(language='en') 
botocore.exceptions.ClientError: An error occurred (SubscriptionRequiredException) when calling the DescribeTrustedAdvisorChecks operation: AWS Premium Support Subscription is required to use this service. 
+0

我可以像cli一样使用它,但是在没有高级支持的情况下运行帐户时,它会引发botocore异常。我可以在代码中处理异常,它会告诉我它是否已启用,但我想知道是否有更好的方法来确定是否启用高级支持 – tkwargs

+0

@tkwargs我刚更新了我的答案。看起来没有更好的方法来检查。 – helloV

相关问题