[JAWS-UG CLI] Lambda:#3 バージョンの発行、確認


前提条件
========


Lambdaへの権限
--------------

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


AWS CLI
-------

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

* AWS CLI 1.9.0

```bash:コマンド:
aws --version
```

```text:結果(例):
      aws-cli/1.9.0 Python/2.7.5 Darwin/13.4.0 botocore/1.3.0
```


0. 準備
=======


変数の確認
----------

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

```bash:変数の確認:
aws configure list
```

```text:結果(例):
            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関数名の決定
-----------------------

```bash:コマンド:
aws lambda list-functions \
        --query 'Functions[].FunctionName'
```

```json:結果(例):
      [
        "HelloWorld"
      ]
```

```bash:変数の設定:
LAMBDA_FUNC_NAME='HelloWorld'
```


2. バージョンの発行
===================

```bash:変数の設定:
LAMBDA_VER_DESC='This is the 1st version.'
```

```bash:変数の確認:
cat << ETX

        LAMBDA_FUNC_NAME:  ${LAMBDA_FUNC_NAME}
        LAMBDA_VER_DESC:  "${LAMBDA_VER_DESC}"

ETX
```

```bash:コマンド:
aws lambda publish-version \
        --function-name ${LAMBDA_FUNC_NAME} \
        --description "${LAMBDA_VER_DESC}"
```

```json:結果(例):
      {
        "CodeSha256": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx=",
        "FunctionName": "HelloWorld",
        "CodeSize": 350,
        "MemorySize": 128,
        "FunctionArn": "arn:aws:lambda:ap-northeast-1:XXXXXXXXXXXX:function:HelloWorld:2",
        "Version": "1",
        "Role": "arn:aws:iam::XXXXXXXXXXXX:role/lambdaBasicExecution",
        "Timeout": 3,
        "LastModified": "2015-10-26T01:23:45.678+0000",
        "Handler": "HelloWorld.handler",
        "Runtime": "nodejs",
        "Description": "This is the 1st version."
      }
```


3. バージョンの確認
===================

```bash:コマンド:
aws lambda list-versions-by-function \
        --function-name ${LAMBDA_FUNC_NAME}
```

```json:結果(例):
      {
        "Versions": [
          {
              "Version": "$LATEST",
              "CodeSha256": "WnGd6iPBS0rGCJor4zyuOaGBtzQ3I/OgHerXWqZzbL8=",
              "FunctionName": "HelloWorld",
              "MemorySize": 128,
              "CodeSize": 350,
              "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-26T03:08:28.302+0000",
              "Runtime": "nodejs",
              "Description": "Hello World with AWS Lambda function."
          },
          {
              "Version": "1",
              "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."
          }
        ]
      }
```


完了
====