DEV Community

Cover image for How to Create an S3 Bucket on AWS and Generate a Pre-Signed URL
Kosisochukwu Ugochukwu
Kosisochukwu Ugochukwu

Posted on

How to Create an S3 Bucket on AWS and Generate a Pre-Signed URL

Introduction
Amazon Web Services (AWS) Simple Storage Service (S3) is a scalable object storage service that is used for a variety of purposes, such as application data storage, static website hosting, and content delivery. One of S3's main features is the ability to produce pre-signed URLs, which allow secure access to your objects without revealing your access credentials. This article will walk you through the steps of creating an S3 bucket and generating a pre-signed URL.

Simple illustration to understand what S3 is in AWS.

Imagine a giant online locker.
Think of S3 to be a large online storage system for storing images, movies, documents, and other types of digital data. Instead of physical items, you store digital files. Amazon Web Services (AWS) hosts this locker on the internet, allowing you to access it from anywhere worldwide as long as you have the correct key.

Before you begin, make sure your AWS account is active.

Step 1: Create an S3 Bucket

  • Login to your AWS management console
  • On the search buttons write S3 and click search

S3

  • Select Create Bucket.

Create Bucket

  • Enter a unique bucket name (e.g., "kosi-storage") and on the top right corner choose the AWS region of your choice, or preferably a region that is nearest to your users.

unique bucket name

Adjust optional settings such as public access configurations, bucket versioning, encryption, bucket key, and optionally add a tag.

  • Public access configurations

Note: This setting controls who can view or use the files in your bucket. Everything can be kept private or accessible just to specified people or applications. Think of it as a Do Not Disturb sign for your files.

public access configurations

  • Bucket Versioning

Note: This is equivalent to keeping a backup of any changes you make to your data. If you mistakenly edit or delete something, you can recover the previous versions.
For the sake of the tutorial we choose click on disable

Bucket Versioning

  • Tags

Similar to labels, tags are applied to your bucket to help keep it organized. For instance, you could add a tag that reads Project A or Important Files so you can quickly identify what the bucket is for.

Tags

  • Default Encryption

Encryption is similar to using a password to lock your files. This option ensures that all of your files are automatically locked, preventing unauthorized users from accessing and using them.

  • Bucket Key

This is an efficient approach to save money and time when locking and unlocking files (encryption). It works by minimizing the number of times AWS has to check the "key" for the lock.

Bucket Key

  • Explore the object lock on the advanced settings then click on create bucket

click on create bucket

  • We have successfully created a bucket. Next, click on the newly created bucket. Instead of uploading directly, start by creating a folder to organize the files into the appropriate location before uploading them.

created a bucket

Step 2: Create a folder

  • Click on Create a folder

Create a folder

  • Name the folder kosinachi docs and scroll down to click on Create folder to save it.

kosinachi docs

Create folder to save it

  • Folder successfully created

Folder successfully created

Note: You can create more folders using the same step

Step 3: Upload

  • Click on the created folder kosinachi docs Image description
  • Click on Upload

Click on upload

  • Click on Add files

add files

  • File added scroll down and click upload File uploaded

Image description

  • File uploaded successfully

File uploaded successfully

Step 3: Create a Pre-Signed URL

Note: A pre-signed URL provides temporary access to a specific S3 object without revealing your AWS credentials.

  • Open the image file uploaded to the kosinachi docs folder

uploaded

  • Click on Object actions in the top-right corner. In the dropdown menu, select Share with a pre-signed URL

Share with a pre-signed URL

  • Set the duration for the pre-signed URL by choosing the number of minutes or hours you want it to remain valid. For tutorial sake, we choose 3 minutes.
  • Click on Create pre-signed URL

Set the duration

A pre-signed URL for the “content uploaded” has been created and copied to your clipboard.

A presigned URL

  • Paste the URL into a browser to verify that it works.

Paste the URL

This article is simple and straightforward, showing us how to create an S3 Bucket in AWS and generate a Pre-Signed URL for it. You can apply this process to any other files you’ve uploaded.

Conclusion
Creating an S3 bucket and generating pre-signed URLs on AWS is a straightforward and effective way to securely share things. This functionality offers temporary, secure access to your S3 resources. By following the steps shown above, you may effectively manage your S3 storage and securely share data.

Top comments (0)