Creating an S3 bucket with the necessary bucket policies setup is one of the most basic and important things that a user must do to use the Laravel eCommerce Amazon S3 Extension.
Using our module, users may connect their Bagisto store to an Amazon S3 bucket. However, in AWS, you must first create a bucket and set up the appropriate bucket policy.
To use with the Laravel eCommerce Amazon S3 Extension, follow the below-mentioned steps to set up S3 bucket policies.
1: Creation of an IAM user
2: Creation of an S3 bucket
3: Bucket Policy Setup
4: CORS Configuration
Creation of an I AM User
(i) Firstly, Sign in to your AWS account and select the I AM service.
(ii) Select Access management | Users from the side navigation menu, and then Add user.
(iii) Set the Username and Access Permissions.
Enter the new username in the User name section, then tick the Programmatic access option in the Access type section to give the user only programmatic access, then click Next: Permissions.
(iv) Select Attach existing policies directly, followed by Create policy. After that, search for Amazon S3 Full Access, check the box, and Select Next: Tags.
(v) Select Next: Review, and finally, Create User after you’re done.
(vi) Download the .CSV file and save the new user’s credentials (Access Key ID and Secret Access Key).
Creation of an S3 Bucket
(i) Select the S3 among the available AWS services or you can search for an S3 service in the search box.
(ii) You are redirected to the S3 dashboard by clicking on S3 in the previous step. Here you may get a list of your buckets across regions and you can also create a new bucket.
For new bucket create, just click on Create bucket as shown below.
(iii) In Create bucket wizard:
- Bucket name: Enter a DNS-compliant name for your bucket in Bucket name.
- AWS Region: Select the AWS Region in which the bucket will be located.
- Block Public Access settings for this bucket: Make sure to uncheck the “Block all public access”.
(iv) At last scroll down to the bottom and click Create bucket.
Your bucket has been created. Note down the name and the region of the bucket since you’ll need it later.
Bucket Policy Setup
There are two things that must be required in order to set up a bucket policy, IAM User ARN and Bucket name.
S3 permissions for the awsexamplebucket1 bucket – an example of a bucket policy.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
{ "Version": "2012-10-17", "Id": "ExamplePolicy01", "Statement": [ { "Sid": "ExampleStatement01", "Effect": "Allow", "Principal": { "AWS": "arn:aws:iam::123456789012:user/Dave" }, "Action": [ "s3:GetObject", "s3:GetBucketLocation", "s3:ListBucket" ], "Resource": [ "arn:aws:s3:::awsexamplebucket1/*", "arn:aws:s3:::awsexamplebucket1" ] } ] } |
CORS Configuration
CORS configuration allows you to set up your bucket to accept cross-origin requests. If you’re using the S3 console to configure CORS, you’ll need to deploy JSON to do so.
Only JSON CORS configurations are supported by the new S3 console.
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 |
[ { "AllowedHeaders": [ "*" ], "AllowedMethods": [ "GET", "HEAD", "PUT", "DELETE", "POST" ], "AllowedOrigins": [ "*" ], "ExposeHeaders": [], "MaxAgeSeconds": 3000 } ] |
Your S3 bucket is now set up to work with Bagisto. Simply browse to AWS Integration in your Bagisto admin if you already have the module installed.
Provide the Access key, Secret key, and the S3 bucket information that you created in the preceding stages.
Save your information, and you’re ready to use Bagisto with an S3 bucket.
You can also check out our Laravel eCommerce Amazon S3 Extension Module and User Guide (https://bagisto.com/en/laravel-ecommerce-amazon-s3-extension/) for more information.
In case of any help, query, or feedback please contact us or raise a ticket.
Thank you for reading this document,
Keep in touch!!