First open your command-line interface (CLI) and proceed with configuring your details using the following command:
Use the following command to create a bucket:
Replace (BUCKET-NAME) with a globally unique name for your bucket. Make sure it is unique across all existing buckets. To check if the bucket is created, use the command:
Following command will list all the available buckets, and you should see your newly created bucket
To upload files to your bucket, use the command:
Replace (PATH OF LOCAL DIRECTORY) with the path of your local directory containing the website files, and (BUCKET-NAME) with the name of your bucket. To check the uploaded files, use the command:
Following command will list all the files in your bucket.
To enable static website hosting for your bucket, use the command:
Replace (BUCKET-NAME) with your bucket name and (INDEX-DOCUMENT-NAME) with the name of your index document. This command configures the bucket to serve the specified index document and error page.
To make the bucket publicly accessible, use the command:
aws s3api put-public-access-block --bucket BUCKET-NAME --public-access-block-configuration "BlockPublicAcls=false,IgnorePublicAcls=false,BlockPublicPolicy=false,RestrictPublicBuckets=false"
Replace (BUCKET-NAME) with your bucket name. This command disables the restrictions on public access to the bucket.
Create a file using a text editor, such as Notepad, and write your bucket policy in JSON format. Here's an example policy: Replace (BUCKET-NAME) with your bucket name in the policy. Save the file.
Save the file with a .json extension.
Use the following command to upload and attach the policy to your bucket:
Replace (BUCKET-NAME) with your bucket name and (FILE-PATH) with the path to the policy file you created.
The endpoint format for a static website hosted in an S3 bucket is:
Replace (BUCKET-NAME) with your bucket name and (AWS REGION) with your default region (the one you set during configuration). Opening this endpoint will allow you to check if the website is running correctly.