Iâve been trying to figure this out for the past two days. There definitely is a bug because the output of âaws_s3_bucket.redirect-bucket.website_endpointâ is correct, but Terraform origin â domain_name results in InvalidArgument: The parameter Origin DomainName does not refer to a valid S3 bucket.
did you managed to find a solution? I am thinking to âdowngradeâ the aws provider version to version 3.0 where aws_s3_bucket.redirect.website_endpoint is not deprecatedâŚ
Thank you for sharing the issue here, I was running into the same problem, that my bucket was not redirecting because the âdomain_name = aws_s3_bucket.www_bucket.bucket_regional_domain_nameâ, instead of using the website endpoint.
I changed it manually in the management console, which is quite clumsy
I ignored the warning messages, and used the website endpoint in the script. When receiving the following error message, I just âterraform applyâ again, and then it worked:
Error: creating CloudFront Distribution: InvalidArgument: The parameter Origin DomainName does not refer to a valid S3 bucket.
found this thread and 'dsosbornâs anwer - thankâs for sharing! And what actually mattered to me, was using the endpoint of the website configuration. I hadnât seen or tried that before. And this is actually accepted by my terraform version v1.4.0 without warning or error messages.
You find my repo (in progress) here: GitHub - d-wrede/AWS_capstone_project
I recommend you looking at it, if you need an updated version (May 2023).
@subaquatic-pierre , thank you for raising this; it was rather hard to find. The problem described in this thread exactly describes the problem I was having.
Here is the solution that worked for me:
Set the distributionâs origin domain name equal to the website bucketâs regional domain name, as most online resources suggest.
Set the distributionâs default root object equal to the website bucketâs index file name (excluding a preceding forward slash - this is something I had tried before, but I included a forward slash).