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

[JAWS-UG CLI] Lambda:#9 関数の削除

More than 3 years have passed since last update.

前提条件

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

0. 準備

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

0.2. Lambda関数名の指定

変数の設定
LAMBDA_FUNC_NAME='<削除する関数名>'

1. 事前作業

削除する前に必ず削除対象を確認します。

コマンド
aws lambda get-function \
        --function-name ${LAMBDA_FUNC_NAME}
結果(例)
      {
        "Code": {
          "RepositoryType": "S3",
          "Location": "https://awslambda-ap-ne-1-tasks.s3-ap-northeast-1.amazonaws.com/snapshots/XXXXXXXXXXXX/HelloWorld-3115238c-44ee-41c2-b532-f6020f2bf0c3?x-amz-security-token=AQoDYXdzEEUa4APGqQOubNBnePimgbAdIHODsCsAzIHH8AbLSCMoOEXKZnv7nwxTbyHUJDFWlS4ip7H8QiQvMm57anN3xPB91kxv%2F5HM3xGSr6FGHgAprmQygm9mazeQ3u%2F0GZPofC92puBuzJRnsI2lgSpb6SHfjzHWlIPprqEsoOjt%2BWi%2B2%2BsSq99VsdueuUT733ECKQPcrk8209ua3oieVaRin0SKO5A295tpXUYvU26xyL6tma473yVaAj2yZhaLr07DqDFy%2F5C1xMGblGPDw27TNp%2FaYxzzVcokRnlo8qwoIz%2FrBphD2jeASVaLPNsjt8G5ZJVkSMulQsY0dXJwDWEPa06bq6rS9kOsaTvw47jWFinP9vejODMfKS9%2FMVP2Y%2FIQw4TuWHLvma1jyEtRigwMiAUI6NuwhmEO0q5GNL%2F%2B7N8E%2BNnKX9JTdZcCUM4E%2BimrTgjLFG7wd9QycM10Qwy1jT0o%2FvTi7uoYXbdgR0BQAK1fxnx6PavjCcDz2snKkkDNC4pNwMD72PXLgRqhqS%2Boa2PL%2BksAM%2BPYUW%2BmEc7UNjXWlBWzXYOE1TqJm3Ky2ftRpLxKVRUFn2ulXU6k5%2Ff8TersEiELUZmiXnY6iQMk9CU9xv%2BtH1YQyiMWXH06uLYsBQwftLkgpNODsQU%3D&AWSAccessKeyId=ASIAJ3ZW5ATJXE4RAWIA&Expires=1445001835&Signature=Xx5hXCV526PgCAZDI6ftyBnai2o%3D"
      },
      "Configuration": {
          "Version": "$LATEST",
          "CodeSha256": "oFDGE+7AezYdHQmRD8t50JSY0J0nsv4GnA6ChP1nqXs=",
          "FunctionName": "HelloWorld",
          "MemorySize": 128,
          "CodeSize": 350,
          "FunctionArn": "arn:aws:lambda:ap-northeast-1:XXXXXXXXXXXX:function:HelloWorld",
          "Handler": "HelloWorld.handler",
          "Role": "arn:aws:iam::XXXXXXXXXXXX:role/lambda_basic_execution",
          "Timeout": 3,
          "LastModified": "2015-10-16T13:08:22.581+0000",
          "Runtime": "nodejs",
          "Description": "A starter AWS Lambda function."
        }
      }

2. 削除

2.1. 関数の削除

変数の確認
cat << ETX

        LAMBDA_FUNC_NAME:  ${LAMBDA_FUNC_NAME}

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

2.2. 関数の確認

コマンド
aws lambda get-function \
        --function-name ${LAMBDA_FUNC_NAME}
結果(例)
      A client error (ResourceNotFoundException) occurred when calling the GetFunction operation: Function not found: arn:aws:lambda:ap-northeast-1:XXXXXXXXXXXX:function:HelloWorld

完了

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