forked from laravel/laravel
-
Notifications
You must be signed in to change notification settings - Fork 1
/
serverless.yml
166 lines (144 loc) · 4.19 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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
service: ${env:SLS_SERVICE, 'app'}
useDotenv: true
provider:
name: aws
region: us-east-1
stage: ${opt:stage, 'dev'}
architecture: arm64
memorySize: 512
logRetentionInDays: 90
deploymentBucket:
blockPublicAccess: true
name: ${self:service}.${aws:region}.deploys
environment:
# Application Settings
BREF_BINARY_RESPONSES: true
# Laravel settings
APP_NAME: ${env:APP_NAME, 'Laravel'}
APP_URL: 'https://${param:domain}'
APP_KEY: bref-ssm:/${param:UUID}/APP_KEY
APP_ENV: ${param:env}
APP_DEBUG: ${param:debug}
MAINTENANCE_MODE: ${param:maintenance, null}
# Cache, Session, and Queue Settings
CACHE_DRIVER: dynamodb
DYNAMODB_CACHE_TABLE: !Ref CacheTable
SESSION_DRIVER: dynamodb
QUEUE_CONNECTION: sqs
SQS_QUEUE: ${construct:jobs.queueUrl}
SQS_REGION: ${aws:region}
# Storage Settings
FILESYSTEM_DISK: s3
AWS_BUCKET: ${construct:storage.bucketName}
FILESYSTEM_DISK_PUBLIC: s3_public
AWS_BUCKET_PUBLIC: ${construct:assets.assetsBucketName}
# Database Settings
DB_HOST: bref-ssm:/${param:UUID}/DB_HOST
DB_PORT: bref-ssm:/${param:UUID}/DB_PORT,3306
DB_DATABASE: bref-ssm:/${param:UUID}/DB_DATABASE
DB_USERNAME: bref-ssm:/${param:UUID}/DB_USERNAME
DB_PASSWORD: bref-ssm:/${param:UUID}/DB_PASSWORD
# Mailer Settings
MAIL_HOST: bref-ssm:/${param:UUID}/MAIL_HOST
MAIL_PORT: bref-ssm:/${param:UUID}/MAIL_PORT
MAIL_USERNAME: bref-ssm:/${param:UUID}/MAIL_USERNAME
MAIL_PASSWORD: bref-ssm:/${param:UUID}/MAIL_PASSWORD
MAIL_ENCRYPTION: bref-ssm:/${param:UUID}/MAIL_ENCRYPTION
MAIL_FROM_ADDRESS: bref-ssm:/${param:UUID}/MAIL_FROM_ADDRESS
MAIL_FROM_NAME: ${env:APP_NAME, 'Laravel'}
# Third-Party Services Settings
GOOGLE_RECAPTCHA_SITE_KEY_V3: bref-ssm:/${param:UUID}/GOOGLE_RECAPTCHA_SITE_KEY_V3
GOOGLE_RECAPTCHA_SECRET_V3: bref-ssm:/${param:UUID}/GOOGLE_RECAPTCHA_SECRET_V3
apiGateway:
binaryMediaTypes:
- '*/*'
iam:
role:
statements:
# SSM Secrets
- Effect: Allow
Resource: arn:aws:ssm:${aws:region}:${aws:accountId}:parameter/${param:UUID}/*
Action:
- ssm:GetParameters
# Laravel Cache (DynamoDB)
- Effect: Allow
Resource: !GetAtt CacheTable.Arn
Action:
- dynamodb:DescribeTable
- dynamodb:Query
- dynamodb:Scan
- dynamodb:GetItem
- dynamodb:PutItem
- dynamodb:UpdateItem
- dynamodb:DeleteItem
plugins:
- ./vendor/bref/bref
- serverless-lift
functions:
laravel:
handler: public/index.php
runtime: ${param:php}-fpm
timeout: 28
events:
- httpApi: '*'
reservedConcurrency: 250
artisan:
handler: artisan
runtime: ${param:php}-console
timeout: 900
events:
- schedule:
name: '${param:UUID}-artisan-schedule-run'
rate: rate(1 minute)
input:
cli: "schedule:run >>/dev/stderr"
constructs:
assets:
type: server-side-website
domain: ${param:domain}
certificate: ${param:certificateArn}
assets:
# '/js/*': public/js
# '/css/*': public/css
'/build/*': public/build
'/robots.txt': public/robots.txt
extensions:
bucket:
Properties:
BucketName: '${param:UUID}-${aws:region}-assets'
storage:
type: storage
extensions:
bucket:
# DeletionPolicy: Retain
Properties:
BucketName: '${param:UUID}-${aws:region}-storage'
AccessControl: Private
jobs:
type: queue
worker:
handler: Bref\LaravelBridge\Queue\QueueHandler
runtime: ${param:php}
timeout: 300
reservedConcurrency: 25
params:
default:
UUID: ${self:service}-${sls:stage}
php: php-${env:BREF_PHP_VERSION, '82'}
domain: ${sls:stage}.${env:SLS_BASE_DOMAIN}
certificateArn: ${env:SLS_CERTIFICATE_ARN}
env: 'staging'
debug: 'true'
production:
domain: ${env:SLS_BASE_DOMAIN}
env: 'production'
debug: 'false'
resources:
- ${file(serverless/resources/cache.yml)}
package:
patterns:
- '!node_modules/**'
- '!public/storage'
- '!resources/assets/**'
- '!storage/**'
- '!tests/**'