Tomorrow Will Be A Better Day

Published

- 3 min read

awscliを使って、AWSへのサポート問い合わせを操作する

img of awscliを使って、AWSへのサポート問い合わせを操作する

と言っても、そこまで難しい話ではなく、ドキュメントにちゃんと書いてある。
http://docs.aws.amazon.com/cli/latest/reference/support/index.html
(2020/05/04追記 今はaws cli2が出ているので、本手順は古い内容になります)

新規ケース作成

   aws support create-case
    --subject "test"
    --communication-body "test message"
    --service-code support-api
    --category-code apis
    --severity-code low

問い合わせケースの抜き出し

   aws support describe-cases

レスポンスは以下のようなJSONで返ってくる。

   {
	"cases": [
		{
			"status": "unassigned",
			"recentCommunications": {
				"communications": [
					{
						"body": "test message\n\n",
						"caseId": "【AWSから払い出されるcaseID】",
						"timeCreated": "2014-04-20T12:14:02.000Z",
						"submittedBy": "【問い合わせしたメールアカウント】"
					}
				]
			},
			"ccEmailAddresses": [],
			"language": "en",
			"timeCreated": "2014-04-20T12:14:01.000Z",
			"caseId": "【AWSから払い出されるcaseID】",
			"severityCode": "low",
			"categoryCode": "apis",
			"__type": "CaseDetails",
			"serviceCode": "support-api",
			"submittedBy": "【問い合わせしたメールアカウント】",
			"displayId": "187532481",
			"subject": "test"
		}
	]
}

ちなみに、
http://docs.aws.amazon.com/cli/latest/reference/support/describe-cases.html
を見ると、問い合わせの言語は英語と日本語をサポートしていると書いてある。デフォルトは英語の模様(当然かw)

The ISO 639-1 code for the –language in which AWS provides support. AWS Support currently supports English (“en”) and Japanese (“ja”). Language parameters must be passed explicitly for operations that take them.

問い合わせケースをクローズする

   aws support resolve-case --case-id "【AWSから払い出されたcaseID】"

レスポンスは以下のようなJSONで返ってくる。

   {
	"finalCaseStatus": "resolved",
	"initialCaseStatus": "work-in-progress"
}

AWSを利用していて、「サポート問い合わせも一部自動化したいなあ」と思うことがあるので、こうしたAPIが準備されているのはすごくありがたい。
とはいえ、不用意にケースを作成しまくるとAWS側から怒られるかもしれないので、APIでのサポート問い合わせは計画的にw