AWS S3 Bucket Guide
This is a guide to help you get started on creating an S3 bucket in AWS and allowing you to access this bucket in your React project.
First and most importantly, sign up for a free AWS account at https://aws.amazon.com/.
Next, let’s follow this handy guide to create an S3 bucket provided by a little company called Amazon.
You will also need to create an access key. Complete step 2 in this guide:
https://transloadit.com/docs/faq/how-to-set-up-an-amazon-s3-bucket/
In order to connect AWS to your program, you need to install dotenv:
Then in your API/backend project, you need set up a .env file with your Amazon credentials. It should look like this:
AWS_S3_BUCKET=<Your Bucket Name>
AWS_ACCESS_KEY_ID=<Your Access Key>
AWS_SECRET_ACCESS_KEY=<Your Secret Access Key>
But first, you need to make your S3 bucket public so that you can access it. Follow this guide:
With all of these steps, you should be able to fetch to your S3 bucket without getting this error message:
UnhandledPromiseRejectionWarning: MissingRequiredParameter: Missing required key ‘Bucket’ in params
The last bit of knowledge that I wish to impart to you is that you need to include .env in your .gitignore file before you push up your code to Github or you will get a nasty email from Amazon saying that your account is compromised and you have 24 hours to fix this. If this happens, you have to remove the .env file from your Github repository, delete your access keys and make new ones to put in your .env files, and you need to change your AWS password. Not that I had to go through that or anything.
Thanks for reading!