Create S3 Static Website! Step-by-Step Guide Using AWS CLI!

In this article, I'll be setting up an S3 bucket website. I'll also verify the website is accessible and working as expected. S3 bucket websites are excellent for hosting single-page, customer-facing content, as they are easy to set up and offer the same high availability and scalability as S3.
1. Login to EC2 instance via SSH
First, open a terminal session and log in to the provided EC2 instance via SSH using the credentials provided on the lab page:

ssh -i <key_name.pem> ec2-user@<PUBLIC IP>
2. Create an S3 Bucket from AWS CLI
Create an S3 bucket in the us-east-1 region using the S3 API. Replace <UNIQUE_BUCKET_NAME> with a unique bucket name:

aws s3api create-bucket --bucket <UNIQUE_BUCKET_NAME> --acl public-read --region us-east-1

3. Modify the Newly Created Bucket to Be an S3 Website Bucket
Enable the "Static website hosting" property of your bucket and provide the index.html page with this AWS S3 API CLI command:

aws s3 website s3://<UNIQUE_BUCKET_NAME> --index-document index.html
4. Modify Provided S3 Policy File and Use It to Modify the Bucket Policy
Open the policy_s3.json file and copy the following json file content:

    "Statement": [
            "Sid": "PublicReadGetObject",
            "Effect": "Allow",
             "Principal": "*",
             "Action": "s3:GetObject",
            "Resource": "arn:aws:s3:::<UNIQUE_BUCKET_NAME>/*"

Save and exit the file. Then, use the S3 policy file to modify the bucket policy so your objects are publicly accessible:

aws s3api put-bucket-policy --bucket <UNIQUE_BUCKET_NAME> --policy file://policy_s3.json

5. Clone our website from Github and Upload Files to S3 Website Bucket
Install Git and clone the website repository:

sudo apt-get install git
git clone
cd designer

Upload all the files to your S3 website bucket:
aws s3 cp ./ s3://<UNIQUE_BUCKET_NAME> --recursive

6. Verify Your S3 Static Website Is Working
Enter the S3 website URL for your bucket in the browser to ensure it's working. You can also test it from the terminal using the curl command:

curl http://<UNIQUE_BUCKET_NAME>

7. Delete all Objects from an S3 Bucket
To delete all the objects from an S3 bucket, use the --recursive option after the specified bucket name as shown below:

aws s3 rm s3://<UNIQUE_BUCKET_NAME> --recursive

8. Delete the S3 Bucket
To delete the bucket, use the following command:

aws s3 rb s3://<UNIQUE_BUCKET_NAME>

9. Force Delete All Objects from an S3 Bucket
If you want to force delete all objects from an S3 bucket, use the following command:

aws s3 rm s3://<UNIQUE_BUCKET_NAME> --recursive --force

You have successfully completed the steps. 
Created with