forked from BlockchainZoo/keyhub-vault
-
Notifications
You must be signed in to change notification settings - Fork 1
/
serverless.yml
72 lines (66 loc) · 2.47 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
service: keyhub-vault
frameworkVersion: '>=1.2.0 <2.0.0'
plugins:
- serverless-stack-output
- serverless-s3-sync
custom:
# Bucket name that will host the site
s3Bucket:
sandbox: keyhub-vault-sandbox
prod: keyhub-vault
s3Sync:
- bucketName: ${self:custom.s3Bucket.${self:provider.stage}} # required
localDir: dist # required
followSymlinks: true # optional
defaultContentType: text/html # optional
# acl: public-read # optional
params: # optional
- 'index.html':
# Store index.html permanently in the user browser
CacheControl: 'public, max-age=31536000, s-maxage=600, immutable'
- 'index.js':
# Store PGP public key permanently in the user browser
CacheControl: 'public, max-age=31536000, s-maxage=600, immutable'
- 'js/openpgp.worker.bundle.js':
# Store OpenPGP library permanently in the user browser
CacheControl: 'public, max-age=31536000, s-maxage=600, immutable'
- 'js/main.bundle.js':
# Cache must revalidate main.bundle.js
CacheControl: 'no-cache, no-transform'
- 'js/main.bundle.js.*':
# Cache must revalidate sourcemap & signature of main.bundle.js
CacheControl: 'no-cache, no-transform'
output:
file: cloudfront/stack.ap-southeast-1-${self:provider.stage}.yaml
provider:
name: aws
region: 'ap-southeast-1'
stage: ${opt:stage, 'sandbox'}
resources:
Resources:
## Specifying the S3 Bucket
WebAppS3Bucket:
Type: AWS::S3::Bucket
Properties:
BucketName: ${self:custom.s3Bucket.${self:provider.stage}}
AccessControl: PublicRead
WebsiteConfiguration:
IndexDocument: index.html
ErrorDocument: index.html
## Specifying the policies to make sure all files inside the Bucket are avaialble to CloudFront
WebAppS3BucketPolicy:
Type: AWS::S3::BucketPolicy
Properties:
Bucket: { Ref: WebAppS3Bucket }
PolicyDocument:
Statement:
- Sid: PublicReadGetObject
Effect: Allow
Principal: '*'
Action:
- s3:GetObject
Resource: arn:aws:s3:::${self:custom.s3Bucket.${self:provider.stage}}/*
## In order to print out the hosted domain via `serverless info` we need to define the DomainName output for CloudFormation
Outputs:
WebAppS3BucketDomainName:
Value: { 'Fn::GetAtt': ['WebAppS3Bucket', 'DomainName'] }