-
Notifications
You must be signed in to change notification settings - Fork 6
Fix redirect on the Apex domain to WWW domain #5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Hi @tnleeuw, I tried applying this set of changes but I'm afraid it's still not working for me. I'm still getting 403 AccessDenied. 😕 Is it possible that the naked-domain distribution needs access to the www-domain bucket? At the moment we use the same According to this thread we might not even need two buckets... but I would leave that for later. |
That is odd because it worked for me after just applying the plan using updated module... I'll have to investigate this. I'll get back on this after I've done some investigation. |
In the properties of your "Naked domain" bucket, what is the target that it is redirecting to? In the TF files we configure it to redirect to whatever the ID is of the other bucket. If that would make it somehow redirect to the actual bucket endpoint URL, that would be a problem since that's a private bucket. However when I look at the configuration of the bucket in my AWS account it redirects to the WWW domain - which is good. The fact that the Origin Access Identity is shared for both buckets and CloudFront distributions doesn't seem to cause any issues for me. I'll try recreating the site from scratch (I'm still in a testing phase with this site so there's no problem yet for me to bring it down and back up). |
@dhinus I tested with 2 different origin access identities but this doesn't make a difference. This is a weird and annoying issue and I've had this happen before - even before I started making any changes to the module code, with version 1.2. That was what even triggered me to look further and make changes. Very vexing that it seems to happen unreliably as I now have 1 working domain, and 1 broken domain, yet they look very similar. (I used different modules to create those two domains and the working domain is created with this particular module!) |
Interesting, I'll investigate a bit more on my side as well. A few notes:
|
That is different from my setup already, though created with the same Terraform code... Perhaps because I created the buckets with a later version of the code?? What if you manually change the redirect of the naked domain? |
I tried manually applying the suggestion from the Reddit thread you linked @dhinus, but this didn't work for me either.
So that doesn't appear to be a solution either. I'm not sure what to do now, since some of the distributions seem to work and others seem to fail without me being able to pinpoint the relevant differences. In any case for the site I'm now working on, we actually probably don't even need the redirection for most domains but in trying to be helpful I haven't actually properly solved an issue. |
This should fix issue #4, the regression caused by my previous PR.
After re-applying I again get the expected redirect from the naked domain to the WWW domain.
Hopefully it works for you as well. Since I modified the ID of the policy (so it's unique, just in case this matters for AWS for this policy type), the plan should show changes to 2 resources.