-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserverless.yml
163 lines (156 loc) · 4.66 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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
service: sigo-companies
package:
individually: true
custom:
company:
sns:
name: CompanyCreated
sqs:
name: CompanyEmailQueue
warmup:
enabled: false # Whether to warm up functions by default or not
folderName: '_warmup' # Name of the folder created for the generated warmup
cleanFolder: false
memorySize: 128
package:
individually: true
exclude: # exclude additional binaries that are included at the serverless package level
- ../**
- ../../**
include:
- ./**
timeout: 20
prewarm: false # Run WarmUp immediately after a deploymentlambda
functionsDirectory: src/4-framework/functions
webpack:
webpackConfig: './webpack.config.js' # Name of webpack configuration file
includeModules:
forceInclude:
- mysql2
forceExclude:
- aws-sdk
packager: 'npm' # Packager that will be used to package your external modules
serverless-offline:
port: 3000
contentCompression: 1024
stages:
- dev
- hml
- prod
provider:
name: aws
runtime: nodejs12.x
stage: ${opt:stage, 'dev'}
region: ${opt:region, 'us-east-2'}
profile: ${opt:profile, 'portal-sigo'}
memorySize: 128
timeout: 30
apiGateway:
restApiId: ${ssm:restApiId}
restApiRootResourceId: ${ssm:restApiRootResourceId}
iamRoleStatements:
- Effect: Allow
Action:
- 'lambda:InvokeFunction'
Resource: 'arn:aws:lambda:#{AWS::Region}:#{AWS::AccountId}:function:${self:service}-${opt:stage, self:provider.stage}-*'
- Effect: Allow
Action:
- 'ssm:GetParameter'
- 'ssm:GetParameters'
- 'ssm:GetParameterHistory'
- 'ssm:GetParametersByPath'
- 'ssm:DescribeParameters'
Resource: 'arn:aws:ssm:#{AWS::Region}:#{AWS::AccountId}:parameter/*'
- Effect: Allow
Action:
- 'kms:Decrypt'
Resource: 'arn:aws:kms:#{AWS::Region}:#{AWS::AccountId}:key/alias/aws/ssm'
- Effect: 'Allow'
Action:
- sns:Publish
Resource: '*'
- Effect: 'Allow'
Action:
- ses:SendEmail
Resource: '*'
- Effect: Allow
Action:
- sqs:ReceiveMessage
Resource: 'arn:aws:sqs:#{AWS::Region}:#{AWS::AccountId}:*'
- Effect: Allow
Action:
- dynamodb:DescribeTable
- dynamodb:Query
- dynamodb:GetItem
- dynamodb:PutItem
- dynamodb:UpdateItem
- dynamodb:DeleteItem
- dynamodb:BatchWriteItem
# permission to create table if not exists
- dynamodb:CreateTable
# stream permissions
- dynamodb:DescribeStream
- dynamodb:GetRecords
- dynamodb:GetShardIterator
- dynamodb:ListStreams
- dynamodb:Scan
Resource: 'arn:aws:dynamodb:#{AWS::Region}:#{AWS::AccountId}:table/*'
package:
excludeDevDependencies: true
exclude:
- .git/**
- .vscode/**
environment:
STAGE: ${self:provider.stage}
ACCOUNT_ID: '#{AWS::AccountId}'
REGION: ${self:provider.region}
REST_API_BASE_URL: ${ssm:restApiBaseUrl}
APP_BASE_URL: ${ssm:appBaseUrl}
TOKEN_SECRET_KEY: ${ssm:tokenSecretKey}
functions:
- ${file(${self:custom.functionsDirectory}/company/_handlers.yml)}
- ${file(${self:custom.functionsDirectory}/standard/_handlers.yml)}
- ${file(${self:custom.functionsDirectory}/compliance/_handlers.yml)}
plugins:
- serverless-stage-manager
- serverless-api-compression
- serverless-webpack
- serverless-offline
- serverless-pseudo-parameters
- serverless-plugin-warmup
resources:
Resources:
CompanyCreatedTopic:
Type: AWS::SNS::Topic
Properties:
TopicName: ${self:custom.company.sns.name}
EmailQueue:
Type: AWS::SQS::Queue
Properties:
QueueName: ${self:custom.company.sqs.name}
MessageRetentionPeriod: 600 #1 hour days in retention message
VisibilityTimeout: 300
EmailQueuePolicy:
Type: AWS::SQS::QueuePolicy
Properties:
PolicyDocument:
Version: '2012-10-17'
Statement:
-
Effect: Allow
Principal: "*"
Action: SQS:SendMessage
Resource:
- Fn::GetAtt: [EmailQueue, Arn]
Condition:
ArnEquals:
aws:SourceArn: arn:aws:sns:#{AWS::Region}:#{AWS::AccountId}:${self:custom.company.sns.name}
Queues:
- Ref: EmailQueue
CompanyCreatedSubscription:
Type: AWS::SNS::Subscription
Properties:
Protocol: sqs
Endpoint:
Fn::GetAtt: [EmailQueue, Arn]
TopicArn: arn:aws:sns:#{AWS::Region}:#{AWS::AccountId}:${self:custom.company.sns.name}