Follow these steps to create an Amazon Simple Storage Service (Amazon S3) bucket to host a static website.
A static website is fixed and displays the same content for each user. In contrast, a dynamic website uses advanced programming to provide user interaction and display different content depending on the user's selections.
This lab requires approximately 30 minutes to complete.
To start the lab session, choose Start Lab in the upper-right corner of the page.
The lab session starts.
A timer displays in the upper-right corner of the page and shows the time remaining in the session.
Tip: To refresh the session length at any time, choose Start Lab again before the timer reaches 0:00.
Before continuing, wait until the lab environment is ready. The environment is ready when the lab details appear on the right side of the page and the circle icon next to the AWS link in the upper-left corner turns green.
To return to these instructions, choose the Readme link in the upper-right corner.
To connect to the AWS Management Console, choose the AWS link in the upper-left corner, above the terminal window.
A new browser tab opens and connects you to the AWS Management Console.
Tip: If a new browser tab does not open, a banner or icon is usually at the top of your browser with the message that your browser is preventing the site from opening pop-up windows. Choose the banner or icon, and then choose Allow pop-ups.
Note: You are using the console through the lab environment, so you are not incurring any actual costs. However, in the real world, when using a personal or business account to access the console, users incur charges for use of specific AWS services.
Choose the Services menu, locate the Storage services, and select S3.
Select Create bucket on the right side of the page.
For Bucket name, enter a unique Domain Name System (DNS)-compliant name for your new bucket.
Follow these naming guidelines:
The name must be unique across all existing bucket names in Amazon S3.
The name must only contain lowercase characters.
The name must start with a letter or number.
The name must be between 3 and 63 characters long.
After you create the bucket, you cannot change the name, so choose wisely.
Choose a bucket name that reflects the objects in the bucket. This is because the bucket name is visible in the URL that points to the objects that you’re going to put in your bucket.
For Region, choose the AWS Region where you want the bucket to reside.
Choose a Region close to you to minimize latency and costs, or to address regulatory requirements. Objects stored in a Region never leave that Region unless you explicitly transfer them to another Region.
Uncheck the Block all public access box because you want to be able to test if the website is working.
A warning message similar to Turning off block all public access might result in this bucket and the objects within becoming public appears below the security setting you deselected.
Below the warning, check the box next to I acknowledge that....
Scroll to the bottom of the page, and select Create bucket.
Your new bucket appears in the Buckets list.
Choose the link for your bucket's name, and then select the Permissions tab.
In the Bucket policy section, choose Edit.
To grant public read access for your website, copy the following bucket policy, and paste it in the policy editor.
{
"Version":"2012-10-17",
"Statement":[
{
"Sid":"PublicReadGetObject",
"Effect":"Allow",
"Principal":"*",
"Action":[
"s3:GetObject"
],
"Resource":[
"arn:aws:s3:::example-bucket/*"
]
}
]
}
In the policy, replace example-bucket with the name of your bucket.
Select Save changes.
In this task, you upload an HTML document to your new bucket.
Create an index.html file on your local computer or get it from https://drive.google.com/file/d/1TJxCBZpd1xIm-SCtUfhET9nUhiX_HWlE/view?usp=sharing
In the console, choose the Objects tab.
Upload the index.html file to your bucket.
Choose Upload.
Drag and drop the index.html file onto the upload page.
As an alternative, choose Add files, navigate to the file, and choose Open.
Expand the Properties section.
This section lists the storage classes that are available in Amazon S3. You will learn more about storage classes later, but take a minute to review them now.
Ensure that the Standard storage class is selected.
At the bottom of the page, choose Upload.
Choose Close.
The index.html file appears in the Objects list.
Select the Properties tab, and scroll down to the Static website hosting section.
Choose Edit.
Select Enable.
In the Index document text box, enter index.html
Select Save changes.
Scroll down to the Static website hosting section again, and copy the Bucket website endpoint URL to your clipboard.
Open a new tab in your web browser, paste the URL you just copied, and press Enter.
The Hello World webpage should display. You have successfully hosted a static website using an S3 bucket!
Congratulations! You have completed the lab.
Log out of the AWS Management Console.
In the upper-right corner of the page, choose your user name. Your user name begins with voclabs/user.
Choose Sign Out.
Choose End Lab at the top of this page, and then select Yes to confirm that you want to end the lab.