-
Notifications
You must be signed in to change notification settings - Fork 12
/
serverless.yml
127 lines (119 loc) · 3.33 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
service: nearspark
provider:
name: aws
runtime: nodejs10.x
region: us-west-1
stage: ${opt:stage, 'dev'}
stackName: nearspark-${opt:stage, 'dev'}
memorySize: 128
timeout: 15
role: ${file(config.json):nearspark-iam-role}
deploymentBucket:
name: ${file(config.json):nearspark-bucket-id}
vpc:
securityGroupIds:
- ${file(config.json):nearspark-security-group}
subnetIds: ${file(config.json):nearspark-subnet-ids}
usagePlan:
quota:
limit: 10000000
period: MONTH
resourcePolicy:
- Effect: Allow
Principal: "*"
Action: execute-api:Invoke
Resource:
- execute-api:/*/*/*
functions:
thumbnail:
handler: index.handler
events:
- http:
method: get
path: "thumbnail/{url}"
request:
parameters:
paths:
url: true
contentHandling: CONVERT_TO_BINARY
resources:
Resources:
NearsparkCloudfrontDNS:
Type: AWS::Route53::RecordSet
Properties:
Name:
Fn::Join:
- ""
- - ${file(config.json):nearspark-dns-prefix}
- ${file(config.json):nearspark-domain}
HostedZoneId: ${file(config.json):nearspark-zone-id}
Type: A
AliasTarget:
DNSName:
Fn::GetAtt: [ NearsparkCloudfrontDistribution, DomainName ]
HostedZoneId: Z2FDTNDATAQYW2
NearsparkCloudfrontDistribution:
Type: AWS::CloudFront::Distribution
Properties:
DistributionConfig:
Origins:
- Id: ApiGateway
DomainName:
Fn::Join:
- ""
- - Ref: ApiGatewayRestApi
- ".execute-api."
- Ref: AWS::Region
- ".amazonaws.com"
CustomOriginConfig:
HTTPPort: 80
HTTPSPort: 443
OriginProtocolPolicy: https-only
OriginSSLProtocols: [ "TLSv1", "TLSv1.1", "TLSv1.2" ]
OriginPath:
Fn::Join:
- ""
- - "/"
- ${self:provider.stage}
Enabled: true
HttpVersion: http2
PriceClass: PriceClass_All
Aliases:
-
Fn::Join:
- ""
- - ${file(config.json):nearspark-dns-prefix}
- ${file(config.json):nearspark-domain}
DefaultCacheBehavior:
AllowedMethods:
- GET
- HEAD
- OPTIONS
CachedMethods:
- GET
- HEAD
TargetOriginId: ApiGateway
ForwardedValues:
QueryString: true
Headers: []
Cookies:
Forward: none
ViewerProtocolPolicy: redirect-to-https
MinTTL: '0'
DefaultTTL: '3600'
ViewerCertificate:
AcmCertificateArn: ${file(config.json):nearspark-cert-arn}
SslSupportMethod: sni-only
# CloudFrontDefaultCertificate: 'true'
plugins:
- serverless-offline
- serverless-apigw-binary
- serverless-apigwy-binary
custom:
apigwBinary:
types:
- '*/*'
Outputs:
NearsparkCloudfrontDistribution:
Value:
Fn::GetAtt: [ NearsparkCloudfrontDistribution, DomainName ]