forked from lesspod/lesspod-2.0
-
Notifications
You must be signed in to change notification settings - Fork 0
/
serverless.yml
104 lines (98 loc) · 3.01 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
service: lesspod-2 # 1. Edit whole service name
provider:
name: aws
runtime: nodejs8.10
stage: ${opt:stage, 'dev'}
region: ${opt:region, 'us-east-1'} # 2. Edit AWS region name
environment:
NODE_ENV: production
BUCKET_NAMESPACE: lp2mumabc # 3. Specify a new AWS S3 bucket namespace for bundled assets and static assets (should be unique)
ASSETS_BUCKET_NAME: ${self:provider.environment.BUCKET_NAMESPACE}-assets-${opt:stage, 'dev'}
STATIC_BUCKET_NAME: ${self:provider.environment.BUCKET_NAMESPACE}-static-${opt:stage, 'dev'}
ASSETS_BUCKET_URL: https://s3.${self:provider.region}.amazonaws.com/${self:provider.environment.ASSETS_BUCKET_NAME}
STATIC_BUCKET_URL: https://s3.${self:provider.region}.amazonaws.com/${self:provider.environment.STATIC_BUCKET_NAME}
custom:
webpack:
# webpackConfig: ./folder/my-webpack.config.js
customDomain:
domainName: 'lesspod.org' # 4. Specify a new domain name to be created
stage: ${opt:stage, 'dev'}
basePath: ''
certificateName: 'lesspod.org' # 5. Enter the certificate name in AWS Certificate Manager (us-east-1) for https connection
createRoute53Record: true
#endpointType: 'regional'
serverless-offline:
port: 3000
s3Sync:
- bucketName: ${self:provider.environment.ASSETS_BUCKET_NAME}
localDir: .nuxt/dist/client
- bucketName: ${self:provider.environment.STATIC_BUCKET_NAME}
localDir: static
package:
exclude:
- src/**
include:
- serverless.yml
functions:
nuxt-renderer:
handler: handler.render
memorySize: 512
timeout: 30
events:
- http:
path: /
method: ANY
cors: true
- http:
path: /{proxy+}
method: ANY
cors: true
resources:
Resources:
AssetsBucket:
Type: AWS::S3::Bucket
Properties:
BucketName: ${self:provider.environment.ASSETS_BUCKET_NAME}
AssetsBucketPolicy:
Type: AWS::S3::BucketPolicy
Properties:
Bucket:
Ref: AssetsBucket
PolicyDocument:
Version: "2012-10-17"
Statement: [
{
Action: ['s3:GetObject'],
Effect: 'Allow',
Resource: {
Fn::Join: ['', ['arn:aws:s3:::', { Ref: 'AssetsBucket' }, '/*']],
},
Principal: '*'
},
]
StaticBucket:
Type: AWS::S3::Bucket
Properties:
BucketName: ${self:provider.environment.STATIC_BUCKET_NAME}
StaticBucketPolicy:
Type: AWS::S3::BucketPolicy
Properties:
Bucket:
Ref: StaticBucket
PolicyDocument:
Version: "2012-10-17"
Statement: [
{
Action: ['s3:GetObject'],
Effect: 'Allow',
Resource: {
Fn::Join: ['', ['arn:aws:s3:::', { Ref: 'StaticBucket' }, '/*']],
},
Principal: '*'
},
]
plugins:
# - serverless-webpack
- serverless-s3-sync
- serverless-domain-manager
- serverless-offline