This repository was archived by the owner on Jul 2, 2021. 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
93 lines (87 loc) · 2.67 KB
/
serverless.yml
File metadata and controls
93 lines (87 loc) · 2.67 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
service: frontend
provider:
name: aws
runtime: nodejs8.10
region: us-east-1
stage: ${opt:stage, self:custom.defaultStage}
# The following line is for testing local deploys
# profile: ${self:custom.profiles.${self:provider.stage}, 'default'}
endpointType: REGIONAL
deploymentBucket:
name: "pinster-serverless-deploy-${self:custom.profiles.${self:provider.stage}}"
custom:
defaultStage: dev
profiles:
dev: dev
prod: prod
reactBucket: "app-${self:provider.stage}.pinster.io"
resources:
Resources:
WebsiteBucket:
Type: AWS::S3::Bucket
Properties:
BucketName: ${self:custom.reactBucket}
AccessControl: PublicRead
WebsiteConfiguration:
IndexDocument: index.html
ErrorDocument: index.html
WebsiteBucketPolicy:
Type: AWS::S3::BucketPolicy
Properties:
Bucket:
Ref: WebsiteBucket
PolicyDocument:
Statement:
- Sid: PublicReadForGetBucketObjects
Effect: Allow
Principal: '*'
Action: s3:GetObject
Resource: "arn:aws:s3:::${self:custom.reactBucket}/*"
WebsiteCloudfront:
Type: AWS::CloudFront::Distribution
DependsOn:
- WebsiteBucket
Properties:
DistributionConfig:
Aliases:
- ${self:custom.reactBucket}
Comment: Cloudfront Distribution pointing to S3 bucket
Origins:
- DomainName: "${self:custom.reactBucket}.s3.amazonaws.com"
Id: S3Origin
CustomOriginConfig:
HTTPPort: '80'
HTTPSPort: '443'
OriginProtocolPolicy: http-only
Enabled: true
HttpVersion: 'http2'
DefaultRootObject: index.html
DefaultCacheBehavior:
AllowedMethods:
- GET
- HEAD
Compress: true
TargetOriginId: S3Origin
ForwardedValues:
QueryString: true
Cookies:
Forward: none
ViewerProtocolPolicy: redirect-to-https
PriceClass: PriceClass_100
ViewerCertificate:
AcmCertificateArn: arn:aws:acm:us-east-1:582149114309:certificate/4527b2fc-14a6-417c-a35c-82f5426e516a
SslSupportMethod: sni-only
WebsiteDNSName:
Type: AWS::Route53::RecordSetGroup
Properties:
HostedZoneName: pinster.io.
RecordSets:
- Name: "app-${self:provider.stage}.pinster.io"
Type: CNAME
TTL: 900
ResourceRecords:
- Fn::GetAtt:
- WebsiteCloudfront
- DomainName
plugins:
- serverless-pseudo-parameters