Skip to content

Commit 93b49c0

Browse files
authored
Do not enable the S3 filesystem by default (#37)
* Do not enable the S3 filesystem by default See #79 (comment) Setting the S3 filesystem by default could be confusing because it won't work (the S3 bucket needs to be created and configured). * Document how to use the S3 filesystem in the example `serverless.yml`
1 parent 3e0fc57 commit 93b49c0

File tree

3 files changed

+19
-4
lines changed

3 files changed

+19
-4
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,12 @@ functions:
150150

151151
If you want all CloudWatch log entries to be JSON objects (for example because you want to ingest those logs in other systems), you can edit `config/logging.php` to set the `channels.stderr.formatter` to `Monolog\Formatter\JsonFormatter::class`.
152152

153+
### File storage
154+
155+
When running on Lambda, the filesystem is temporary and not shared between instances. If you want to use the Filesystem API, you will need to use the `s3` adapter to store files on AWS S3.
156+
157+
To do this, set `FILESYSTEM_DISK: s3` either in `serverless.yml` or your production `.env` file and configure the S3 bucket to use in `config/filesystems.php`.
158+
153159
## Usage
154160

155161
### Artisan Console

examples/getting-started/serverless.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ provider:
3232
SQS_QUEUE: ${self:service}-${sls:stage}
3333
DYNAMODB_CACHE_TABLE: ${self:service}-${sls:stage}-cache
3434
MAINTENANCE_MODE: ${param:maintenance, null}
35+
# Use S3 for filesystem storage
36+
FILESYSTEM_DISK: s3
37+
AWS_BUCKET: !Ref StorageBucket
3538
iam:
3639
role:
3740
statements:
@@ -44,6 +47,12 @@ provider:
4447
- Effect: Allow
4548
Resource: arn:aws:ssm:${aws:region}:${aws:accountId}:parameter/${self:service}-${sls:stage}/*
4649
Action: [ssm:GetParameters]
50+
# Allow Lambda to read and write files in the S3 storage bucket
51+
- Effect: Allow
52+
Action: s3:*
53+
Resource:
54+
- !Sub '${StorageBucket.Arn}' # the storage bucket
55+
- !Sub '${StorageBucket.Arn}/*' # and everything inside
4756

4857
plugins:
4958
- ./vendor/bref/bref
@@ -133,3 +142,7 @@ resources:
133142
Properties:
134143
QueueName: ${self:service}-${sls:stage}
135144
VisibilityTimeout: 70
145+
StorageBucket:
146+
Type: AWS::S3::Bucket
147+
Properties:
148+
Description: Storage bucket for the Laravel application

src/BrefServiceProvider.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -139,10 +139,6 @@ protected function fixDefaultConfiguration()
139139
Config::set('session.driver', 'cookie');
140140
}
141141

142-
if (Config::get('filesystems.default') === 'local') {
143-
Config::set('filesystems.default', 's3');
144-
}
145-
146142
if (Config::get('logging.default') === 'stack') {
147143
Config::set('logging.default', 'stderr');
148144
}

0 commit comments

Comments
 (0)