Help us understand the problem. What is going on with this article?

[JAWS-UG CLI] API Gateway: #2 RestAPIの削除

More than 3 years have passed since last update.

前提条件

API Gatewayへの権限

API Gatewayに対してフル権限があること。

AWS CLI

以下のバージョンで動作確認済

  • AWS CLI 1.9.8
コマンド
aws --version

結果(例):

  aws-cli/1.9.8 Python/2.7.5 Darwin/13.4.0 botocore/1.3.0

0. 準備

0.1. リージョンの決定

変数の設定

.. parsed-literal::

export AWS_DEFAULT_REGION='\ |AWS_DEFAULT_REGION|\ '

0.2. 変数の確認

プロファイルが想定のものになっていることを確認します。

変数の確認
aws configure list
結果(例)
            Name                    Value             Type    Location
            ----                    -----             ----    --------
         profile       administrator-prjz-mbp13        env    AWS_DEFAULT_PROFILE
      access_key     ****************XXXX shared-credentials-file
      secret_key     ****************XXXX shared-credentials-file
          region                ap-northeast-1        env    AWS_DEFAULT_REGION

プロファイルが想定のものになっていることを確認します。

0.3. 対象APIの指定

コマンド
aws apigateway get-rest-apis \
        --query 'items[].name'
結果(例)
[
        "MyDemoAPI"
]
変数の指定
APIGW_API_NAME='MyDemoAPI'
コマンド
APIGW_API_ID=$( \
        aws apigateway get-rest-apis \
          --query "items[?name == \`${APIGW_API_NAME}\`].id" \
          --output text \
      ) \
        && echo ${APIGW_API_ID}
結果(例)
      xxxxxxxxxx

1. 事前作業

削除する前にかならず、削除対象の確認をしてください。

コマンド
aws apigateway get-rest-api \
        --rest-api-id ${APIGW_API_ID}
結果(例)
      {
        "id": "xxxxxxxxxx",
        "name": "MyDemoAPI",
        "description": "This is my API for demonstration purposes",
        "createdDate": 1445947998
      }

2. APIの削除

変数の確認
cat << ETX

        APIGW_API_ID: ${APIGW_API_ID}

ETX
コマンド
aws apigateway delete-rest-api \
        --rest-api-id ${APIGW_API_ID}
結果
(戻り値なし)

3. 事後確認

コマンド
aws apigateway get-rest-api \
        --rest-api-id ${APIGW_API_ID}
結果
A client error (NotFoundException) occurred when calling the GetRestApi operation: Invalid REST API identifier specified

完了

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした