-
Notifications
You must be signed in to change notification settings - Fork 0
/
serverless.yml
120 lines (110 loc) · 3.5 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
service: serverless-aws-template
useDotenv: true
frameworkVersion: '3'
configValidationMode: error
plugins:
- serverless-plugin-scripts
provider:
name: aws
region: ap-southeast-2
runtime: nodejs20.x
deploymentMethod: direct
apiGateway:
shouldStartNameWithService: true
logRetentionInDays: 14
deploymentBucket:
blockPublicAccess: true # Prevents public access via ACLs or bucket policies.
serverSideEncryption: AES256
tags: # Tags that will be added to each of the deployment resources
ProvisionedBy: ${self:custom.commonTags.provisionedBy}
Project: ${self:custom.commonTags.project}
stackTags: # Optional CF stack tags
ProvisionedBy: ${self:custom.commonTags.provisionedBy}
Project: ${self:custom.commonTags.project}
tags: # service wide tags
ProvisionedBy: ${self:custom.commonTags.provisionedBy}
Project: ${self:custom.commonTags.project}
Owner: Ackama
stage: ${opt:stage, 'staging'}
# These environment vars are installed into **all** functions in the service
environment:
NODE_OPTIONS: '-r source-map-support/register'
SLACK_WEBHOOK_URL: ${env:SLACK_WEBHOOK_URL}
custom:
resources:
prefix: ${self:service}-${self:provider.stage}
#uploadsBucket: ${self:custom.resources.prefix}-uploads
commonTags:
provisionedBy: Serverless
project: serverless-aws-template
outDir: ${file(./tsconfig.build.json):compilerOptions.outDir}
prepareForPacking: &prepareForPacking |
npm run --silent build
scripts:
hooks:
'before:package:createDeploymentArtifacts': *prepareForPacking
'before:deploy:function:packageFunction': *prepareForPacking
package:
patterns:
- '!**/*'
- 'package.json'
- 'node_modules/**'
- '!node_modules/@types/**'
- '!**/tsconfig*.json'
- '!**/*.d.ts'
- '!**/*.gradle'
- '!**/*.h'
- '!**/*.html'
- '!**/*.java'
- '!**/*.m'
- '!**/*.map'
- '!**/*.md'
- '!**/*.npmignore'
- '!**/*.pbxproj'
- '!**/*.pem'
- '!**/*.podspec'
- '!**/*.ts'
- '!**/*.tsbuildinfo'
- '!**/*.txt'
- '!**/*.un~'
- '!**/*.xcworkspacedata'
- '!**/*.xml'
- '!**/*.yml'
- '!**/Makefile'
- '!**/node_modules/.package-lock.json'
- ${self:custom.outDir}/**/*
functions:
api-lambda:
handler: ${self:custom.outDir}/api-lambda/index.handler
tags:
Purpose: An example of a lambda thats invoked by URL via API Gateway
events:
- http:
path: /send
method: post
cloudwatch-lambda:
handler: ${self:custom.outDir}/cloudwatch-lambda/index.handler
tags:
Purpose: An example of a lambda thats invoked by CloudWatch log events
events:
- cloudwatchLog:
logGroup: '/aws/lambda/${self:service}-${opt:stage, self:provider.stage}-scheduled-lambda'
filter: '"source: ''aws.events''"'
scheduled-lambda:
handler: ${self:custom.outDir}/scheduled-lambda/index.handler
tags:
Purpose: An example of a lambda thats invoked by a cron schedule
events:
- schedule:
# run every day at 17:00 UTC (04:00 -> 06:00 in NZ)
rate: cron(0 17 * * ? *)
sns-lambda:
handler: ${self:custom.outDir}/sns-lambda/index.handler
tags:
Purpose: An example of a lambda thats invoked by some SNS topics
events:
# https://serverless.com/framework/docs/providers/aws/events/sns/
# to use a pre-existing SNS, provide an arn as the events name, or via the `arn` property
- sns: my-sns-topic
#resources:
# Resources: ${file(./resources.yml)}