-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserverless.yml
145 lines (132 loc) · 4.16 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
service: laravel-bref-template
provider:
name: aws
region: eu-central-1
runtime: provided.al2
stage: production
environment:
APP_NAME: Bref-Test
APP_ENV: ${self:provider.region}
APP_DEBUG: false
APP_KEY: ${ssm:/laravel-bref-template-production/APP_KEY}
CACHE_DRIVER: dynamodb
SESSION_DRIVER: dynamodb
DYNAMODB_CACHE_TABLE: !Ref CacheTable
QUEUE_CONNECTION: sqs
SQS_QUEUE: !Ref SqsQueue
DB_HOST: your-database-url
DB_DATABASE: your-database-name
DB_USERNAME: ${ssm:/laravel-bref-template-production/DB_USERNAME}
DB_PASSWORD: ${ssm:/laravel-bref-template-production/DB_PASSWORD}
ASSET_URL: !Join [ '', [ 'https://', !GetAtt AssetsBucket.RegionalDomainName ] ]
MIX_ASSET_URL: !Join [ '', [ 'https://', !GetAtt AssetsBucket.RegionalDomainName ] ]
RELEASE_HASH: ${env:RELEASE_HASH} # You could use this for sentry release tracking for example
iamRoleStatements:
- Effect: Allow
Action: [ sqs:SendMessage, sqs:DeleteMessage ]
Resource: !GetAtt SqsQueue.Arn
- Effect: Allow
Action: [ dynamodb:GetItem, dynamodb:PutItem, dynamodb:UpdateItem, dynamodb:DeleteItem ]
Resource: !GetAtt CacheTable.Arn
# Configure our API Gateway HTTP API to enable request logging. This is optional.
logs:
httpApi:
format: '{"requestId":"$context.requestId","httpMethod":"$context.httpMethod","status":"$context.status","path":"$context.path","responseLatency":"$context.responseLatency","integrationLatency":"$context.integrationLatency"}'
package:
exclude:
- .env
- node_modules/**
- public/storage/**
- public/css/**
- public/js/**
- resources/assets/**
- storage/**
- tests/**
functions:
web:
# name: ${self:service}-${self:provider.stage}-web
handler: public/index.php
memorySize: 1024
timeout: 5 # in seconds (API Gateway has a timeout of 29 seconds)
reservedConcurrency: 5 # This compares to "capacity" in Vapor
layers:
- ${bref:layer.php-80-fpm}
events:
- httpApi: '*'
# Also configure our warmer
- schedule:
rate: rate(5 minutes)
input:
warmer: true
concurrency: 1
artisan:
# name: ${self:service}-${self:provider.stage}-artisan
handler: artisan
memorySize: 1024
timeout: 120 # in seconds
layers:
- ${bref:layer.php-80} # PHP
- ${bref:layer.console} # The "console" layer
events:
- schedule:
rate: rate(1 minute)
input: '"schedule:run --ansi --no-interaction --quiet"'
worker:
# name: ${self:service}-${self:provider.stage}-worker
handler: worker.php
memorySize: 1024
timeout: 20 # in seconds
reservedConcurrency: 5
layers:
- ${bref:layer.php-80}
events:
- sqs:
arn: !GetAtt SqsQueue.Arn
batchSize: 1
plugins:
- ./vendor/bref/bref
resources:
Resources:
# Website assets
AssetsBucket:
Type: AWS::S3::Bucket
Properties:
BucketName: laravel-bref-template-assets
AccelerateConfiguration:
AccelerationStatus: Enabled
CorsConfiguration:
CorsRules:
- AllowedHeaders: [ "*" ]
AllowedMethods: [ GET ]
AllowedOrigins: [ "*" ]
# Policy to make website assets publicly readable
AssetsBucketPolicy:
Type: AWS::S3::BucketPolicy
Properties:
Bucket: !Ref AssetsBucket
PolicyDocument:
Statement:
- Effect: Allow
Principal: '*' # everyone
Action: 's3:GetObject' # to read
Resource: 'arn:aws:s3:::laravel-bref-template-assets/*'
# The SQS queue
SqsQueue:
Type: AWS::SQS::Queue
Properties:
VisibilityTimeout: 30 # Job duration + safety margin
# Cache table
CacheTable:
Type: AWS::DynamoDB::Table
Properties:
TableName: laravel-bref-template-cache
AttributeDefinitions:
- AttributeName: key
AttributeType: S
KeySchema:
- AttributeName: key
KeyType: HASH
BillingMode: PAY_PER_REQUEST
TimeToLiveSpecification:
AttributeName: expires_at
Enabled: true