ついに本題ですw
昨日ローカルから実行したpythonをlambdaに上げていきます!
layers作成
昨日pip installしたこの子達をlayersに固めていきます。
pip install -t . httplib2
pip install -t . oauth2client
pip install -t . google-api-python-client
で、cloudformationでデプロイ
templateはこちら
AWSTemplateFormatVersion: '2010-09-09'
Transform: 'AWS::Serverless-2016-10-31'
Description: api gw, lambda, layers and sqs
Parameters:
Env:
Type: String
Default: dev
Resources:
getGoogleCalendar:
Type: 'AWS::Serverless::Function'
Properties:
FunctionName: !Sub 'getGoogleCalendar-${Env}'
Handler: lambda_function.lambda_handler
Runtime: python3.7
CodeUri: src/getGoogleCalendar
Description: !Sub 'getGoogleCalendar-${Env}'
Environment:
Variables:
ENV: !Sub ${Env}
MemorySize: 1024
Timeout: 60
Role: !Sub 'arn:aws:iam::${AWS::AccountId}:role/service-role/slackBotRole'
Tags:
Env: dev
project: lineBot
Layers:
- !Ref layerGcp
layerGcp:
Type: AWS::Serverless::LayerVersion
Properties:
Description: python modules Layer
ContentUri: ./layer/gcp
CompatibleRuntimes:
- python3.7
- python3.6
で、デプロイ
コンソールからテスト実行。
うーん…。
これは、ただのpip install -tではだめなやつかも…。
dockerさんの出番のやつかな…。
続きは夜!