This repository was archived by the owner on May 27, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserverless.yml
More file actions
173 lines (159 loc) · 6.02 KB
/
serverless.yml
File metadata and controls
173 lines (159 loc) · 6.02 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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
service: serverless-react-ssr
frameworkVersion: '>=1.9.0 <2.0.0'
custom:
stage: ${opt:stage, self:provider.stage}
client:
bucketName: ${env:APP_DOMAIN_NAME}
distributionFolder: dist
webpack:
includeModules:
forceInclude:
- react-dom # required through react-apollo (renderToStringWithData)
packager: yarn
webpackConfig: ./config/webpack/webpack.config.server.js
package:
individually: true
plugins:
- serverless-finch
- serverless-webpack # https://github.com/serverless-heaven/serverless-webpack#usage-with-serverless-offline
- serverless-offline
- serverless-patches
provider:
name: aws
region: us-east-1
runtime: nodejs8.10
deploymentBucket: ${env:ARTIFACTS_BUCKET}
environment:
API_DOMAIN_NAME: ${env:API_DOMAIN_NAME}
STAGE: ${self:custom.stage}
functions:
website:
name: serverless-react-${self:custom.stage}
handler: handler.website
events:
- http:
cors: true
integration: lambda-proxy
method: get
path: /
- http:
cors: true
integration: lambda-proxy
method: get
path: /{proxy+}
resources:
Resources:
ApiGatewayBasePathMapping:
DependsOn: ApiGatewayDomainName
Type: AWS::ApiGateway::BasePathMapping
Properties:
BasePath: ''
DomainName: ${env:APP_DOMAIN_NAME}
RestApiId:
Ref: ApiGatewayRestApi
Stage: ${self:custom.stage}
ApiGatewayDomainName:
Type: AWS::ApiGateway::DomainName
Properties:
CertificateArn: ${env:APP_SSL_CERT_ARN}
DomainName: ${env:APP_DOMAIN_NAME}
ApiGatewayDNSRecords:
Type: AWS::Route53::RecordSetGroup
Properties:
HostedZoneName: ${env:APP_HOSTED_ZONE}.
RecordSets:
- Name: ${env:APP_DOMAIN_NAME}.
Type: A
AliasTarget:
DNSName: {'Fn::GetAtt': ApiGatewayDomainName.DistributionDomainName}
HostedZoneId: Z2FDTNDATAQYW2
- Name: ${env:APP_DOMAIN_NAME}.
Type: AAAA
AliasTarget:
DNSName: {'Fn::GetAtt': ApiGatewayDomainName.DistributionDomainName}
HostedZoneId: Z2FDTNDATAQYW2
ApiGatewayStaticBucket:
Type: AWS::S3::Bucket
Properties:
BucketName: ${env:APP_DOMAIN_NAME}
ApiGatewayResourceStatic:
Type: AWS::ApiGateway::Resource
Properties:
ParentId: {'Fn::GetAtt': [ApiGatewayRestApi, RootResourceId]}
PathPart: 'static'
RestApiId: {Ref: ApiGatewayRestApi}
ApiGatewayResourceStaticProxyVar:
Type: AWS::ApiGateway::Resource
Properties:
ParentId: {Ref: ApiGatewayResourceStatic}
PathPart: '{proxy+}'
RestApiId: {Ref: ApiGatewayRestApi}
ApiGatewayIamRoleExecution:
Type: AWS::IAM::Role
Properties:
AssumeRolePolicyDocument:
Statement:
Effect: Allow
Principal:
Service: [apigateway.amazonaws.com]
Action: [sts:AssumeRole]
Path: '/'
Policies:
- PolicyName: AllowApiGatewayS3Access
PolicyDocument:
Statement:
Effect: Allow
Resource: {'Fn::Join': ['', ['arn:aws:s3:::', {Ref: ApiGatewayStaticBucket}, '/*']]}
Action:
- s3:Get*
- s3:List*
ApiGatewayMethodStaticProxyVarGet:
Type: AWS::ApiGateway::Method
Properties:
AuthorizationType: NONE
HttpMethod: GET
Integration:
CacheKeyParameters:
- method.request.path.proxy
CacheNamespace: ApiGatewayMethodStaticProxyVarGetCacheNS
Credentials: {'Fn::Join': ['', ['arn:aws:iam::', {Ref: AWS::AccountId}, ':role/', {Ref: ApiGatewayIamRoleExecution}]]}
IntegrationHttpMethod: GET
IntegrationResponses:
- StatusCode: 200
ResponseParameters:
method.response.header.Timestamp: integration.response.header.Date
method.response.header.Content-Length: integration.response.header.Content-Length
method.response.header.Content-Type: integration.response.header.Content-Type
- StatusCode: 400
SelectionPattern: '4\d{2}'
ResponseParameters:
method.response.header.Content-Length: integration.response.header.Content-Length
method.response.header.Content-Type: integration.response.header.Content-Type
- StatusCode: 500
SelectionPattern: '5\d{2}'
ResponseParameters:
method.response.header.Content-Length: integration.response.header.Content-Length
method.response.header.Content-Type: integration.response.header.Content-Type
PassthroughBehavior: WHEN_NO_MATCH
RequestParameters:
integration.request.path.proxy: method.request.path.proxy
Type: AWS
Uri: {'Fn::Join': ['', ['arn:aws:apigateway:', {Ref: AWS::Region}, ':s3:path/${env:APP_DOMAIN_NAME}', '/{proxy}']]}
MethodResponses:
- StatusCode: 200
ResponseParameters:
method.response.header.Timestamp: integration.response.header.Date
method.response.header.Content-Length: integration.response.header.Content-Length
method.response.header.Content-Type: integration.response.header.Content-Type
- StatusCode: 400
ResponseParameters:
method.response.header.Content-Length: integration.response.header.Content-Length
method.response.header.Content-Type: integration.response.header.Content-Type
- StatusCode: 500
ResponseParameters:
method.response.header.Content-Length: integration.response.header.Content-Length
method.response.header.Content-Type: integration.response.header.Content-Type
RequestParameters:
method.request.path.proxy: true
ResourceId: {Ref: ApiGatewayResourceStaticProxyVar}
RestApiId: {Ref: ApiGatewayRestApi}