2017-08-25 17 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

相關問題