sajad torkamani

Note: The below are notes for my own usage: Please view this video for a generic overview.

Create IAM user

Create an IAM user with the AmazonS3FullAccess permission policy. Take note of the access key and secret access key (you’ll need these for your .env file).

Create S3 bucket

Create a S3 bucket. Take note of the name and region.

Add bucket policy:

Paste the following:

{
  "Id": "Policy1727609148545",
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "Stmt1727609145222",
      "Action": [
        "s3:GetObject"
      ],
      "Effect": "Allow",
      "Resource": "arn:aws:s3:::<mybucket-name>/<path-to-public-folders>/*",
      "Principal": "*"
    }
  ]
}

here:

Save changes.

Test S3 uploads

Update AWS_* variables in .env.

Ensure your FILESYSTEM_DISK is set to s3.

Do something to upload to S3 and verify it works as intended.

Sources & further reading

Tagged: Laravel