I am trying to use an S3 bucket to redirect from one website to another. The redirect from "http://example.com" works, but I can’t get the redirect from "https://example.com", "http://www.example.com" or "https://www.example.com" to work.
I have an S3 bucket called "example.com". I then created a Cloudfront distribution, attached the custom SSL certificate, and added "example.com" and "www.example.com" as Alternate Domain Names.
I’m getting this access denied message:
I’m assuming that I am not doing something correctly on the policy settings for the S3 bucket. Any guidance?
I am using the following bucket policy:
I am not currently using the "Access Control List".
2
Answers
For the Cloudfront Distribution redirection to https, it is necessary to configure ACM SSL certificates. provision a certificate exactly for the subdomain.example.com and use the same alternate domain name subdomain.example.com unless there would be an SSL handshake error.
Basically, there are 2 approaches that you can setup CloudFront with S3.
For testing, you can try the Public approach, but for better secure, you can follow the approach from Zeeshan comment.