-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathserverless.yml
More file actions
158 lines (153 loc) · 4.62 KB
/
serverless.yml
File metadata and controls
158 lines (153 loc) · 4.62 KB
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
service: code-and-coffee-service
frameworkVersion: "3"
useDotenv: true
plugins:
- serverless-offline
provider:
name: aws
runtime: nodejs18.x
stage: ${opt:stage}
region: us-east-1
stackName: code-and-coffee-service-${opt:stage}
iam:
role:
permissionsBoundary: ${env:PERMISSION_BOUNDARY_ARN}
httpApi:
name: code-and-coffee-service-${opt:stage}
logs:
restApi: true
package:
individually: true
patterns:
- "!*/**"
- "!*"
functions:
lambda:
handler: build/bundle.handler
timeout: 30
package:
patterns:
- "./build/bundle.cjs"
events:
- httpApi:
path: /{proxy+}
method: get
- httpApi:
path: /{proxy+}
method: post
- httpApi:
path: /{proxy+}
method: delete
- httpApi:
path: /{proxy+}
method: put
environment:
MEETUP_API_BASE_URL: ${env:MEETUP_API_BASE_URL}
SETTINGS_BASE_URL: ${env:SETTINGS_BASE_URL}
API_KEY: ${env:API_KEY}
GH_API_BASE_URL: ${env:GH_API_BASE_URL}
GH_AUTH_KEY: ${env:GH_AUTH_KEY}
EMAIL_APP_URL: ${env:EMAIL_APP_URL}
resources:
Description: Code and Coffee Service ${opt:stage}
Resources:
HttpApiLogGroup:
Type: AWS::Logs::LogGroup
Properties:
LogGroupName: /aws/http-api/code-and-coffee-service-${opt:stage}
RetentionInDays: 7
WebResourcesBucket:
Type: AWS::S3::Bucket
Properties:
BucketName: code-and-coffee-service-web-resources-${opt:stage}-${env:RANDOM_SEED}
CorsConfiguration:
CorsRules:
- AllowedOrigins:
- "*"
AllowedHeaders:
- "*"
AllowedMethods:
- GET
CloudFrontDistribution:
Type: "AWS::CloudFront::Distribution"
Properties:
DistributionConfig:
Comment: code-and-coffee-service-${opt:stage}
Origins:
- DomainName: !Sub ${HttpApi}.execute-api.${AWS::Region}.amazonaws.com
Id: api-gateway
CustomOriginConfig:
HTTPPort: 80
HTTPSPort: 443
OriginProtocolPolicy: https-only
- Id: s3-origin
DomainName: !GetAtt WebResourcesBucket.DomainName
S3OriginConfig:
OriginAccessIdentity: ""
DefaultCacheBehavior:
ForwardedValues:
QueryString: false
TargetOriginId: s3-origin
ViewerProtocolPolicy: redirect-to-https
CachePolicyId: !Ref StandardCachePolicy
Enabled: true
HttpVersion: http2
ViewerCertificate:
AcmCertificateArn: ${env:ACM_CERTIFICATE_ARN}
SslSupportMethod: sni-only
MinimumProtocolVersion: TLSv1.2_2021
CacheBehaviors:
- PathPattern: /info/*
TargetOriginId: api-gateway
CachePolicyId: !Ref StandardCachePolicy
ViewerProtocolPolicy: redirect-to-https
AllowedMethods:
- GET
- HEAD
- OPTIONS
CachedMethods:
- GET
- HEAD
- PathPattern: /api/*
TargetOriginId: api-gateway
CachePolicyId: 4135ea2d-6df8-44a3-9df3-4b5a84be39ad
OriginRequestPolicyId: !Ref StandardOriginRequestPolicy
ViewerProtocolPolicy: redirect-to-https
AllowedMethods:
- HEAD
- DELETE
- POST
- GET
- OPTIONS
- PUT
- PATCH
StandardCachePolicy:
Type: AWS::CloudFront::CachePolicy
Properties:
CachePolicyConfig:
MinTTL: 300
DefaultTTL: 300
MaxTTL: 300
Name: code-and-coffee-service-cache-policy-${opt:stage}-${sls:instanceId}
ParametersInCacheKeyAndForwardedToOrigin:
CookiesConfig:
CookieBehavior: none
EnableAcceptEncodingBrotli: true
EnableAcceptEncodingGzip: true
HeadersConfig:
HeaderBehavior: none
QueryStringsConfig:
QueryStringBehavior: none
StandardOriginRequestPolicy:
Type: AWS::CloudFront::OriginRequestPolicy
Properties:
OriginRequestPolicyConfig:
Name: StandardOriginRequestPolicy-${opt:stage}-${env:RANDOM_SEED}
HeadersConfig:
HeaderBehavior: allExcept
Headers:
- Host
CookiesConfig:
CookieBehavior: all
QueryStringsConfig:
QueryStringBehavior: all