Skip to content

Latest commit

 

History

History
90 lines (66 loc) · 2.92 KB

storage.md

File metadata and controls

90 lines (66 loc) · 2.92 KB

External storage

Some times you want to add an external storage for your avatars, photos, or documents.

This is useful in particular if you install Monica on a stateless volatile instance, like Heroku, Platform.sh, etc.

We currently only support AWS S3 driver as external storage.

Add an external storage

1. Create AWS S3 storage

  1. Go to the S3 console
  2. Add a new bucket
    • Allow public access for the bucket. This is mandatory for now.
  3. Save the name and location of the bucket in AWS_BUCKET and AWS_DEFAULT_REGION variables
AWS_BUCKET=my-bucket
AWS_DEFAULT_REGION=eu-west-3

You can also use AWS CLI to create the bucket:

aws s3 mb s3://my-bucket

2. Create a user

  1. Create a new user via the console.

  2. Add the strategy for S3 access, for instance AmazonS3FullAccess is a good choice:

    • add the user to a group with the right strategy
    • or attach the strategy directly.
  3. Save credentials of the user in AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY variables

AWS_ACCESS_KEY_ID=AKXA3E2NYF7NPDJVQSOU
AWS_SECRET_ACCESS_KEY=aASalDme6wB8kGC7Xla6K3pI+FiFylpCVnGCmdnD

You can also use AWS CLI to set credentials:

aws iam create-user --user-name user-monica-test
aws iam attach-user-policy --user-name user-monica-test --policy-arn arn:aws:iam::aws:policy/AmazonS3FullAccess
aws iam create-access-key --user-name user-monica-test

Output:

{
    "AccessKey": {
        "UserName": "user-monica-test",
        "AccessKeyId": "AKIAXE2N0F6NIMZXLCGB",
        "Status": "Active",
        "SecretAccessKey": "Lh5ValIoe9xlfrhkpqiZOub1TFFo4qn1sAdFvlOM",
        "CreateDate": "2020-04-12T11:35:06+00:00"
    }
}

Then save AccessKeyId and SecretAccessKey in AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY variables.

3. Set environment variables

Don't forget to set this variable to use S3 storage:

DEFAULT_FILESYSTEM=s3

(Optional) Use another S3 provider

AWS_ENDPOINT variable can be used to define a S3-compatible provider other than Amazon, like Digitalocean or Minio. example: AWS_ENDPOINT=https://nyc3.digitaloceanspaces.com

Move avatars to S3 storage

If you previously used local storage and want to move all avatars to a new S3 storage, use monica:moveavatars command once to move all files:

php artisan monica:moveavatars