kakakakakku blog

Weekly Tech Blog: Keep on Learning!

LocalStack で AWS サポートへの問い合わせを API で操作できる「AWS Support API」を試そう

AWS サポートへの問い合わせを API で操作できる「AWS Support API」は気になるけどビジネスプラン以上じゃないと使えなくて気軽に試せないじゃーん😇と悩んでいる人がいたら LocalStack をおすすめしたい❗️実は LocalStack(無料版)で一部の AWS Support API がサポートされている💡

(あくまで練習として)問い合わせし放題だぁぁぁ〜 \( 'ω')/

docs.aws.amazon.com

現在「5種類」の API がサポートされている📝

docs.localstack.cloud

LocalStack で AWS Support API を試す💪

今回は LocalStack AWS CLI(awslocal コマンド)で試す.ちなみに東京リージョンで AWS Support API を実行する場合はバージニア北部リージョン (us-east-1) を指定する必要がある点は注意すること🚨

docs.aws.amazon.com

👾 support describe-cases

awscli.amazonaws.com

最初は問い合わせ0件になっている👌

$ awslocal support describe-cases --region us-east-1 | jq .
{
  "cases": []
}

👾 support create-case

awscli.amazonaws.com

問い合わせできた👌

$ awslocal support create-case --region us-east-1 \
    --subject '[TEST CASE-Please ignore] LocalStack Support API テスト1' \
    --communication-body '東京リージョンの EC2(i-***)について質問です。' \
    --language ja | jq .
{
  "caseId": "case-12345678910-2020-4hJ2i1J38FbKAeh2"
}

$ awslocal support create-case --region us-east-1 \
    --subject '[TEST CASE-Please ignore] LocalStack Support API テスト2' \
    --communication-body '東京リージョンの EC2(i-***)について質問です。' \
    --language ja | jq .
{
  "caseId": "case-12345678910-2020-KMmj62hbE43e578a"
}

$ awslocal support describe-cases --region us-east-1 | jq .
{
  "cases": [
    {
      "caseId": "case-12345678910-2020-4hJ2i1J38FbKAeh2",
      "displayId": "foo_display_id",
      "subject": "[TEST CASE-Please ignore] LocalStack Support API テスト1",
      "status": "pending-customer-action",
      "submittedBy": "moto@moto.com",
      "timeCreated": "2024-09-27T05:25:30.764608",
      "recentCommunications": {
        "communications": [
          {
            "caseId": "case-12345678910-2020-4hJ2i1J38FbKAeh2",
            "body": "東京リージョンの EC2(i-***)について質問です。",
            "submittedBy": "moto@moto.com",
            "timeCreated": "2024-09-27T05:25:30.764612",
            "attachmentSet": [
              {
                "fileName": "support_file.txt"
              }
            ]
          }
        ],
        "nextToken": "foo_next_token"
      },
      "language": "ja"
    },
    {
      "caseId": "case-12345678910-2020-KMmj62hbE43e578a",
      "displayId": "foo_display_id",
      "subject": "[TEST CASE-Please ignore] LocalStack Support API テスト2",
      "status": "pending-customer-action",
      "submittedBy": "moto@moto.com",
      "timeCreated": "2024-09-27T05:25:52.411090",
      "recentCommunications": {
        "communications": [
          {
            "caseId": "case-12345678910-2020-KMmj62hbE43e578a",
            "body": "東京リージョンの EC2(i-***)について質問です。",
            "submittedBy": "moto@moto.com",
            "timeCreated": "2024-09-27T05:25:52.411096",
            "attachmentSet": [
              {
                "fileName": "support_file.txt"
              }
            ]
          }
        ],
        "nextToken": "foo_next_token"
      },
      "language": "ja"
    }
  ]
}

ちなみにドキュメントに以下のように書いてあって,今回は subject[TEST CASE-Please ignore] と付けてある📝

If you call the CreateCase operation to create test support cases, then we recommend that you include a subject line, such as TEST CASE-Please ignore. After you're done with your test support case, call the ResolveCase operation to resolve it.

👾 support resolve-case

awscli.amazonaws.com

問い合わせを解決できた👌

$ awslocal support resolve-case --region us-east-1 \
    --case-id case-12345678910-2020-4hJ2i1J38FbKAeh2 | jq .
{
  "initialCaseStatus": "reopened",
  "finalCaseStatus": "resolved"
}

$ awslocal support describe-cases --region us-east-1 | jq .
{
  "cases": [
    {
      "caseId": "case-12345678910-2020-KMmj62hbE43e578a",
      "displayId": "foo_display_id",
      "subject": "[TEST CASE-Please ignore] LocalStack Support API テスト2",
      "status": "reopened",
      "submittedBy": "moto@moto.com",
      "timeCreated": "2024-09-27T05:25:52.411090",
      "recentCommunications": {
        "communications": [
          {
            "caseId": "case-12345678910-2020-KMmj62hbE43e578a",
            "body": "東京リージョンの EC2(i-***)について質問です。",
            "submittedBy": "moto@moto.com",
            "timeCreated": "2024-09-27T05:25:52.411096",
            "attachmentSet": [
              {
                "fileName": "support_file.txt"
              }
            ]
          }
        ],
        "nextToken": "foo_next_token"
      },
      "language": "ja"
    }
  ]
}

$ awslocal support describe-cases --region us-east-1 \
    --include-resolved-cases | jq .
{
  "cases": [
    {
      "caseId": "case-12345678910-2020-4hJ2i1J38FbKAeh2",
      "displayId": "foo_display_id",
      "subject": "[TEST CASE-Please ignore] LocalStack Support API テスト1",
      "status": "unassigned",
      "submittedBy": "moto@moto.com",
      "timeCreated": "2024-09-27T05:25:30.764608",
      "recentCommunications": {
        "communications": [
          {
            "caseId": "case-12345678910-2020-4hJ2i1J38FbKAeh2",
            "body": "東京リージョンの EC2(i-***)について質問です。",
            "submittedBy": "moto@moto.com",
            "timeCreated": "2024-09-27T05:25:30.764612",
            "attachmentSet": [
              {
                "fileName": "support_file.txt"
              }
            ]
          }
        ],
        "nextToken": "foo_next_token"
      },
      "language": "ja"
    },
    {
      "caseId": "case-12345678910-2020-KMmj62hbE43e578a",
      "displayId": "foo_display_id",
      "subject": "[TEST CASE-Please ignore] LocalStack Support API テスト2",
      "status": "resolved",
      "submittedBy": "moto@moto.com",
      "timeCreated": "2024-09-27T05:25:52.411090",
      "recentCommunications": {
        "communications": [
          {
            "caseId": "case-12345678910-2020-KMmj62hbE43e578a",
            "body": "東京リージョンの EC2(i-***)について質問です。",
            "submittedBy": "moto@moto.com",
            "timeCreated": "2024-09-27T05:25:52.411096",
            "attachmentSet": [
              {
                "fileName": "support_file.txt"
              }
            ]
          }
        ],
        "nextToken": "foo_next_token"
      },
      "language": "ja"
    }
  ]
}

👾 support describe-services

未実装🙅‍♂️

$ awslocal support describe-services --region us-east-1
An error occurred (InternalFailure) when calling the DescribeServices operation: The describe_services action has not been implemented

👾 describe-severity-levels

未実装🙅‍♂️

$ awslocal support describe-severity-levels --region us-east-1
An error occurred (InternalFailure) when calling the DescribeSeverityLevels operation: The describe_severity_levels action has not been implemented

まとめ

LocalStack(無料版)で AWS Support API を試せるよ❗️という紹介でした \( 'ω')/

実際に問い合わせるときはガイドラインも確認しましょう〜📝

aws.amazon.com