-
Notifications
You must be signed in to change notification settings - Fork 0
/
serverless.yml
executable file
·117 lines (111 loc) · 3.34 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
service: nuxt-serverless-ts-issue # 1. Edit whole service name
provider:
name: aws
runtime: nodejs8.10
stage: ${opt:stage, 'staging'}
region: eu-central-1 # 2. Edit AWS region name
deploymentBucket:
name: ${self:provider.environment.BUCKET_NAMESPACE}-assets-${opt:stage, 'staging'}
environment:
NODE_ENV: ${self:custom.ENV.${opt:stage, 'staging'}}
BUCKET_NAMESPACE: nuxt-serverless-ts-issue # 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, 'staging'}
STATIC_BUCKET_NAME: ${self:provider.environment.BUCKET_NAMESPACE}-static-${opt:stage, 'staging'}
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:
customDomain:
domainName: ${opt:stage, 'staging'}.example.com # 4. Specify a new domain name to be created
stage: ${opt:stage, 'staging'}
certificateName: '*.example.com' # 5. Enter the certificate name in AWS Certificate Manager (us-east-1) for https connection
createRoute53Record: true
s3Sync:
- bucketName: ${self:provider.environment.ASSETS_BUCKET_NAME}
localDir: .nuxt/dist/client
- bucketName: ${self:provider.environment.STATIC_BUCKET_NAME}
bucketPrefix: static/
localDir: src/static
ENV:
prod: production
staging: staging
apigwBinary:
types:
- '*/*'
package:
exclude:
- src/**
- coverage/**
- __tests__/**
- .circleci/**
- types/**
- .idea/**
include:
- serverless.yml
- .env
- .env.staging
- .env.prod
- .nuxt/**
- src/static
functions:
nuxt:
handler: index.nuxt
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-apigw-binary
- serverless-dotenv-plugin
- serverless-s3-sync
- serverless-domain-manager