LoginSignup
0

More than 5 years have passed since last update.

Apexを使ってLambdaファンクション(Python)をデプロイするまでの小さなメモ

Last updated at Posted at 2017-04-07

前提

  • OSはUbuntu
  • クレデンシャルを登録していること
  • 「/usr/local/work/test」ディレクトリをプロジェクトのディレクトリとする
  • 「test」という名前のファンクションを作成する
  • コンソールに「hello」を表示するファンクション
  • 環境変数「ENV」を設定

手順

Apexインストール

curl https://raw.githubusercontent.com/apex/apex/master/install.sh | sh

※ただし最新手順は公式サイトを参照
http://apex.run/

手順メモ

# cd /usr/local/work/
# mkdir test
# apex init
※「functions/hello」ディレクトリ、「project.json」が作成される
# rm -rf functions/hello
# mkdir functions/test
# vim functions/test/function.json
# vim functions/test/index.py
# vim project.json
※「nameTemplate」を追記。デプロイされるLambdaファンクション名が「test」となる。(デフォルトではapexのプロジェクト名が付記される)
# apex deploy
function.json
{
  "description": "Test",
  "runtime": "python2.7",
  "handler": "index.lambda_handler"
  "environment":{
    "ENV": "dev"
  }
}
index.py
def lambda_handler(event, context):
    print "test"
project.json
{
  "name": "test",
  "description": "",
  "memory": 128,
  "timeout": 5,
  "role": "arn:aws:iam::xxxxx:role/test_lambda_function",
  "nameTemplate": "{{.Function.Name}}",
  "environment": {}
}

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
0