6
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

[JAWS-UG CLI] Lambda:#8 バージョンの削除

Last updated at Posted at 2015-10-26

前提条件

Lambdaへの権限

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

AWS CLI

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

  • AWS CLI 1.9.0
コマンド
aws --version
結果(例)
      aws-cli/1.9.0 Python/2.7.5 Darwin/13.4.0 botocore/1.3.0
  1. 準備
    =======

変数の確認

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

変数の確認
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
  1. 事前作業
    ===========

1.1. Lambda関数名の決定

コマンド
aws lambda list-functions \
        --query 'Functions[].FunctionName'
結果(例)
      [
        "HelloWorld"
      ]
変数の設定
LAMBDA_FUNC_NAME='HelloWorld'

1.2. バージョンの確認

コマンド
aws lambda list-versions-by-function \
        --function-name ${LAMBDA_FUNC_NAME}
結果(例)
      {
        "Versions": [
          {
              "Version": "$LATEST",
              "CodeSha256": "+EAYs8jMYFRBdnsMdFUt2bv//KHE2tkovql6ls+gXoM=",
              "FunctionName": "HelloWorld",
              "MemorySize": 128,
              "CodeSize": 349,
              "FunctionArn": "arn:aws:lambda:ap-northeast-1:XXXXXXXXXXXX:function:HelloWorld:$LATEST",
              "Handler": "HelloWorld.handler",
              "Role": "arn:aws:iam::XXXXXXXXXXXX:role/lambdaBasicExecution",
              "Timeout": 3,
              "LastModified": "2015-10-26T04:41:36.261+0000",
              "Runtime": "nodejs",
              "Description": "Hello World with AWS Lambda function."
          },
          {
              "Version": "2",
              "CodeSha256": "WnGd6iPBS0rGCJor4zyuOaGBtzQ3I/OgHerXWqZzbL8=",
              "FunctionName": "HelloWorld",
              "MemorySize": 128,
              "CodeSize": 350,
              "FunctionArn": "arn:aws:lambda:ap-northeast-1:XXXXXXXXXXXX:function:HelloWorld:2",
              "Handler": "HelloWorld.handler",
              "Role": "arn:aws:iam::XXXXXXXXXXXX:role/lambdaBasicExecution",
              "Timeout": 3,
              "LastModified": "2015-10-26T03:08:28.302+0000",
              "Runtime": "nodejs",
              "Description": "This is the 1st version."
          },
          {
              "Version": "3",
              "CodeSha256": "+EAYs8jMYFRBdnsMdFUt2bv//KHE2tkovql6ls+gXoM=",
              "FunctionName": "HelloWorld",
              "MemorySize": 128,
              "CodeSize": 349,
              "FunctionArn": "arn:aws:lambda:ap-northeast-1:XXXXXXXXXXXX:function:HelloWorld:3",
              "Handler": "HelloWorld.handler",
              "Role": "arn:aws:iam::XXXXXXXXXXXX:role/lambdaBasicExecution",
              "Timeout": 3,
              "LastModified": "2015-10-26T04:41:36.261+0000",
              "Runtime": "nodejs",
              "Description": "Hello World with AWS Lambda function."
          }
        ]
      }

1.3. 削除するバージョンの決定

変数の設定
LAMBDA_FUNC_VER='1'
コマンド
aws lambda list-versions-by-function \
        --function-name ${LAMBDA_FUNC_NAME} \
        --query "Versions[?Version == '${LAMBDA_FUNC_VER}' ]"
結果(例)
      [
        {
          "Version": "1",
          "CodeSha256": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx=",
          "FunctionName": "HelloWorld",
          "MemorySize": 128,
          "CodeSize": 349,
          "FunctionArn": "arn:aws:lambda:ap-northeast-1:XXXXXXXXXXXX:function:HelloWorld:1",
          "Handler": "HelloWorld.handler",
          "Role": "arn:aws:iam::XXXXXXXXXXXX:role/lambda_basic_execution",
          "Timeout": 3,
          "LastModified": "2015-10-26T01:23:45.678+0000",
          "Runtime": "nodejs",
          "Description": "Hello World with AWS Lambda function."
        }
      ]
  1. バージョンの削除
    ===================

2.1. バージョンの削除

変数の確認
cat << ETX

        LAMBDA_FUNC_NAME: ${LAMBDA_FUNC_NAME}
        LAMBDA_FUNC_VER:  ${LAMBDA_FUNC_VER}

ETX
コマンド
aws lambda delete-function \
        --function-name ${LAMBDA_FUNC_NAME} \
        --qualifier ${LAMBDA_FUNC_VER}
結果
      (戻り値なし)

2.2. バージョンの確認

コマンド
aws lambda list-versions-by-function \
        --function-name ${LAMBDA_FUNC_NAME} \
        --query "Versions[?Version == '${LAMBDA_FUNC_VER}' ]"
結果(例)
      []

完了

6
2
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
6
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?