AWS S3 offers a free tier that includes 5GB of storage, 20,000 GET requests, 2,000 PUT requests, and 15GB of data transfer out per month for the first 12 months. To host a website in S3 for free, you can follow these steps:
- Create an AWS account if you haven't already done so.
- Navigate to the S3 console and create a new bucket with a globally unique name. Note that the name you choose will be part of the website URL, so it should be something easy to remember and type.
- Select the newly created bucket and open the Properties tab. Under the "Static website hosting" section, choose "Use this bucket to host a website" and enter the name of the index document (e.g., index.html).
- Upload your website files to the bucket. You can do this by selecting the bucket, clicking on the "Upload" button, and following the prompts to select your files.
- Once your files are uploaded, select the bucket again and open the Permissions tab. Under the "Bucket policy" section, click on "Edit" and paste in the following policy:
{
"Version":"2012-10-17",
"Statement":[{
"Sid":"PublicReadGetObject",
"Effect":"Allow",
"Principal": "*",
"Action":["s3:GetObject"],
"Resource":["arn:aws:s3:::your-bucket-name/*"
]
}
]
}
Error:
You either don’t have permissions to edit the bucket
policy, or your bucket policy grants a level of public access that
conflicts with your Block Public Access settings. To edit a bucket
policy, you need s3:PutBucketPolicy
permissions. To review which Block Public Access settings are turned on, view your account and bucket settings. Learn more about Identity and access management in Amazon S3
--will need to switch off the bucket policy
- Create a new Route 53 hosted zone or use an existing one to create a DNS record that maps your domain name to the S3 bucket website endpoint.
- In Route 53, create a new record set with the following configuration:
- Name: The name of your domain, such as
example.com
. - Type: Select "A - IPv4 address".
- Alias: Select "Yes" and choose your S3 bucket website endpoint from the dropdown list.
- Name: The name of your domain, such as
- Save your changes in Route 53 and wait for the DNS changes to propagate, which can take up to 48 hours.
Once the DNS changes have propagated, you should be able to access your S3 bucket website at the specified domain name.
Note that some additional configuration may be required depending on your specific use case, such as configuring SSL/TLS encryption, setting up redirects, or restricting access to your S3 bucket.
-Click on the bucket to see the objects
-Click on the object to get the url, use the url to load the browser
When setting up a custom domain for an AWS S3 bucket, you generally do not need to enter an IP address. Instead, you can create a CNAME record that points to the S3 bucket's endpoint.
For example, to set up a custom domain for an S3 bucket located in the eu-central-1 region, you can follow these steps:
In your AWS S3 console, select the S3 bucket you want to use for your website.
Click on the "Properties" tab and then click on the "Static website hosting" option.
In the "Static website hosting" page, note down the S3 bucket endpoint URL, which should be in the format of
bucketname.s3-website-region.amazonaws.com
.Go to your GoDaddy account, select the domain you want to use for your website, and click on "Manage DNS".
Create a new CNAME record and enter your desired subdomain in the "Name" field (e.g. www), and then enter the S3 bucket endpoint URL in the "Points to" field.
For example, for an S3 bucket with endpoint mywebsite.s3-website.eu-central-1.amazonaws.com
, you can create a CNAME record with "www" as the name and mywebsite.s3-website.eu-central-1.amazonaws.com
as the value.
- Save the changes and wait for the DNS records to propagate, which can take some time.
No comments:
Post a Comment