In this post, we will see what is Amazon S3 service and how to get started with it.
What is Amazon S3?
Amazon Simple Storage Service (Amazon S3) is storage for the internet. With Amazon S3 you can store any amount of data and access it from anywhere on the web.
You can use the Amazon S3 service via AWS management console, AWS SDK and AWS command line interface(CLI). Under the hood Amazon S3 is exposed as a web service and Amazon provides many different options to use it.
To get started with Amazon S3 or any of the AWS services, you must activate your AWS account.
Activate your AWS account
- Open https://aws.amazon.com/ and then choose Create an AWS Account.
- Follow the online instructions to complete the signup.
After activating your AWS account, login to AWS management console.
Create S3 bucket
In the AWS management console, navigate to the S3 service under storage category.
- After opening the S3 console click on Create bucket.
- Choose a unique DNS-compliant bucket name. The S3 bucket name that you choose must be unique across all existing bucket names in Amazon S3.
Note : You can not use the same bucket name used in the above example since S3 bucket names must be unique.
- For the Region, choose Asia Pacific (Mumbai) or any other region where you want your bucket to reside.
- Click Create. You should have your bucket created by now.
Add an Object to S3 bucket
- To add an object to bucket, select the bucket that you have just created. In our case its admin-s3-rayfocus.
- Click on Upload button.
- Then click on Add files and select the file that you want to upload. In our case we will add a HTML file.
- After selecting the file, Click Upload button.
- Now you have added the object to your bucket.
Note : To create index.html
- Copy the below html content and save it with filename as index.html.
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<h1>Welcome to Amazon Simple Storage Service</h1>
<p>Have a great day!</p>
View an Object in S3 bucket
- Click on the bucket that you have just created.
- After opening the bucket, select the checkbox next to the Object that you have uploaded.
- Click on Download button.
Host a Static website using S3
- To host a static website using S3, click on the bucket you have created.
- Click the tab Properties and select Static website hosting.
- For the index document, type the Object name index.html created earlier. Click Save.
- Copy the endpoint
- Click on the Object index.html and select Make public.
- You have now granted the public access for the Object in your bucket.
Access the S3 Static website
- Paste the endpoint in the browser address bar and access it.
- You should see the below html page rendered.
Delete an Object from S3 bucket
- To delete an object, select the checkbox next to it.
- In the Delete objects dialog box click Delete.
- This will delete the Object from your S3 bucket.
Delete S3 bucket
- To delete S3 bucket, click the bucket icon next to the name of the bucket.
- Now click Delete bucket.
- In the Delete bucket dialog box, type in the name of the bucket that you want to delete. Click Confirm.
- This will delete the S3 bucket.
What next? Integrating S3 with other AWS services
You can integrate Amazon S3 with other AWS services like Route 53 and Cloud front.
- If you have custom domain name, configure Route 53 to point to the S3 static website endpoint.
- Integrate S3 with Cloud front to speed up your static and dynamic web content distribution for users.
Now you know how to use the Amazon S3 service and to host a static website using it. If you have any questions or concerns post it the comments section.