-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserverless.yml
101 lines (92 loc) · 3.48 KB
/
serverless.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#------------------------------------------------
# Serverless Configuration.
#------------------------------------------------
service: lemon-python-api
# You can pin your service to only deploy with a specific Serverless version
# Check out our docs for more details
# frameworkVersion: "=X.X.X"
plugins:
- serverless-python-requirements
- serverless-wsgi
#------------------------------------------------
# Custom
#------------------------------------------------
custom:
CORE: # Core Configuration.
profile: ${opt:profile, 'none'} # run option `--profile`
region: ${opt:region, 'ap-northeast-2'} # run option `--region` `-r`
stage: ${opt:stage, 'dev'} # run option `--stage` `-s`
env: ${opt:env, 'env.yml'} # run option `--env`
CONF: ${file(./config.js):CONF} # config.js 에서 CONF() 함수 호출하여 가져옴.
wsgi:
app: app.app
packRequirements: false
pythonRequirements:
dockerizePip: non-linux
#------------------------------------------------
# Provider
#------------------------------------------------
provider:
name: aws
profile: ${opt:profile, 'none'}
stage: ${opt:stage, 'dev'}
# you can overwrite defaults here
memorySize: 128
timeout: 30
cfLogs: true
runtime: ${self:custom.CONF.${self:custom.CORE.profile}.runtime, 'python3.6'}
region: ${self:custom.CONF.${self:custom.CORE.profile}.region, self:custom.CORE.region} # profile의 region를 먼저 사용하고, 없으면 실행 옵션값.
# VPC Configuration for Lambda.
vpc:
securityGroupIds: ${self:custom.CONF.${self:custom.CORE.profile}.securityGroupIds}
subnetIds: ${self:custom.CONF.${self:custom.CORE.profile}.subnetIds}
# Lambda function's IAM Role here
iamRoleStatements:
#NOTE! - remove할때 lambda ENI Interface를 제거하지 못해서 블럭당하고 있을때, EC2 콘솔에서 강제 지우기 하면 됨!.. (VPC 안쓰면 관계 없음!)
- Effect: Allow
Action:
- cloudwatch:PutMetricData
- lambda:InvokeFunction
- ec2:CreateNetworkInterface
- ec2:DescribeNetworkInterfaces
- ec2:AttachNetworkInterface
- ec2:DescribeNetworkInterfaces
- ec2:DeleteNetworkInterface
- ec2:DetachNetworkInterface
- ec2:ModifyNetworkInterfaceAttribute
- ec2:ResetNetworkInterfaceAttribute
Resource: "*"
- Effect: Allow
Action:
- dynamodb:Query
- dynamodb:Scan
- dynamodb:GetItem
- dynamodb:PutItem
- dynamodb:UpdateItem
- dynamodb:DeleteItem
- dynamodb:GetRecords
- dynamodb:GetShardIterator
- dynamodb:DescribeStream
- dynamodb:ListStreams
Resource: "arn:aws:dynamodb:${self:provider.region}:*:table/*"
# -------------------------------------------------------
# you can define service wide environment variables here
# WARN! - 환경변수에는 object/null 으로 설정할 수 없음.
environment: ${file(./env/${self:custom.CONF.${self:custom.CORE.profile}.env}):${self:provider.stage}}
#------------------------------------------------
# Functions
#------------------------------------------------
functions:
app:
handler: wsgi.handler
events:
- http: ANY /
- http: 'ANY {proxy+}'
# getUser:
# handler: wsgi.handler
# events:
# - http: 'GET /users/{proxy+}'
# createUser:
# handler: wsgi.handler
# events:
# - http: 'POST /users'