How to create S3 bucket on AWS and make it Public : Get Credentials

    • Here is a quick step-by-step guide on how do you create an S3 bucket on AWS and get the credentials to access it. Please consider the official documentation created by AWS itself for the latest changes and updates

    • Official Documentation by AWS to create S3 bucket. Click Here

    • Sign in to the AWS Management Console and open the Amazon S3 console at https://console.aws.amazon.com/s3/

    • After that you can see your console where you can see and explore your AWS services. Go to search bar and search for “S3” and you will find the service like the image below. Click on it and enter to that service

    • firebase_1
    • Search for S3 in the search bar and then click on it.

    • Now click on the create button at the top right corner as seen in the below image, and that will lead you to create the AWS bucket.

    • firebase_1
    • You will find one form where you will enter and select couple of things in that form

    • For the 1st place (as seen in the No.1 red square), enter the name you want to keep for the bucket

    • For the 2nd square, select the region which is the most nearest to you based on your market and your location

    • For the 3rd square, please uncheck that check box as seen in the image so that our files can be accessible with URLS

    • firebase_1
      firebase_1
    • Whenever you check that checkbox, it will ask you to check one more box below that to confirm the public access of your bucket. Please check that box and then scroll down to the page and click on the button at the bottom saying “Create Bucket"

    • After that it will lead you to the page where you can see all of your created bucket with the green notification on the top like below, it means that bucket has been created successfully.

    • firebase_1
    • Once you have created your bucket, click on the bucket you have created and then we have to add some more permission to make the files publicly accessible

    • For that, go to the permission tab on that page as shown in the image below

    • firebase_1
    • Then scroll down to the Bucket policy section and there you will be able to see something like below, we will add few lines there and for that we have to click on the edit button on the top-right corner of that section as you can see the image below

    • firebase_1
    • After clicking on that edit button please add few lines of code shown below in that. Make sure you don’t any kind of other content in it or you won’t be able to save it. Please follow the example below carefully

    • For Example: My Bucket name is “bucket-shortzz“, you will add in that something like below. (Don’t copy and paste it), in that code there is something which needs to be changed with your bucket name

    • Observe the last line of the below code, there is the name of your bucket, please replace it with yours and then add that in that field shown above

    • {
          "Version": "2012-10-17",
          "Statement": [
              {
                  "Sid": "PublicReadGetObject",
                  "Effect": "Allow",
                  "Principal": "*",
                  "Action": "s3:GetObject",
                  "Resource": "arn:aws:s3:::bucket-shortzz/*"
              }
          ]
      } 
      
    • Click on save changes and come back to the permission tab again

    • Now scroll down to that permission where you will find the option “Cross-origin resource sharing (CORS)” same like the policy

    • firebase_1
    • Click on it’s edit button and then add the code below in it and save it. No need to change anything in the code below

    • [
          {
              "AllowedHeaders": [
                  "*"
              ],
              "AllowedMethods": [
                  "GET",
                  "POST",
                  "PUT"
              ],
              "AllowedOrigins": [
                  "*"
              ],
              "ExposeHeaders": [
                  "ETag"
              ],
              "MaxAgeSeconds": 3000
          }
      ] 
      
    • Click on save.

    • Now come back to permission tab and fine the "Object Ownership" tab and click on the edit at right end side, See the image below

    • S3_9
    • Now it will show something like below, where select the "ACLs enabled"

    • Tick the check box before "I acknowledge that ACLs will be restored."

    • And then click on save

    • S3_9
    • Click on save and our bucket is ready to use. But to use it we will need some credentials from AWS.

      1. AWS_ACCESS_KEY_ID

      2. AWS_SECRET_ACCESS_KEY

    • Please follow the steps below to get the credentials listed above.

How to get "AWS_ACCESS_KEY_ID" and "AWS_SECRET_ACCESS_KEY" from AWS console

    • Log in to your AWS console if you are not logged in, go to your account info on the top-right corner of console, click on it it will show you the options like shown on the image below

    • S3_9
    • Click on “My Security Credentials” in those options and it will lead you to the another page

    • On that page go to the “Access keys” section as shown in the image below and there click on that Create Access Key button

    • S3_9
    • As soon as you click on that button, your security credentials will be created. Here you can save your Access Key and Secret key. Make sure to download .csv file as well because you won't be able to see the secret key again

    • S3_9
    • So we have found the credentials to access our AWS S3 bucket

    • Now, you will need 2 more things for the bucket to be accessed and put files in it via APIs.

      1. Region on which bucket is created

      2. Bucket Name

    • These things can be found in the bucket lists, by going to the S3 page. As shown in the image below.

    • S3_9
    • The first one is the bucket name and the 2nd one is the region

    • While collecting the Region, mind well. Only Copy the thing covered in the red box. see example below

    • There is written “Asia Pacific (Mumbai) ap-south-1” in my case. You will copy only “ap-south-1” as region

    • Save all these credentials in one text file to use them whenever required.

We will need a Base URL for the files to be accessed, let's see how to find it.

    • Click on the bucket we have created, and you will find the upload button on the top right corner of the page

    • Click on it and it will show you another page where you can add files to the bucket

    • Upload any demo image in the bucket using that form and then come back again to the bucket listing page

    • Click on the bucket, and there you will see the just uploaded file in the list, click on that file and it show you another page like the image below

    • S3_9
    • In the above image, the underlined URL is the URL using that you can access the files you have just uploaded

    • If your URL is something like, https://bucket-shortzz.s3.ap-south-1.amazonaws.com/nature.jpg

    • Then your Item Base URL will be https://bucket-shortzz.s3.ap-south-1.amazonaws.com/

    • And that’s all, we have got everything needed to work with AWS S3 bucket.

Want to talk with us?