LoginSignup
3
3

More than 5 years have passed since last update.

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

Last updated at Posted at 2015-11-23

前提条件

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

完了

3
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
3