-
Notifications
You must be signed in to change notification settings - Fork 9.7k
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
providers/aws: CloudFront distribution #1780
Conversation
Thanks for this! 👍 Would you mind adding one extra exported hard-coded attribute, It may sound a bit ridiculous to add an argument that will always return the same value, but:
|
Not at all! I'm currently contemplating whether or not it should support multiple origins though... |
Also looking at the API docs, it may be wise to use resource name Next resources that may follow in the future can be |
How about using So that the DSL becomes something like this: resource "aws_cloudfront" "six" {
default_root_object = "index.html"
origin {
domain_name = "granuldisk.s3.amazonaws.com"
path = "/"
http_port = 80
https_port = 443
protocol_policy = "http-only"
}
origin {
domain_name = "dadada.s3.amazonaws.com"
path = "/"
http_port = 80
https_port = 443
protocol_policy = "http-only"
}
} |
Yes, that is what I initially had and it worked quite well. However most of the other options also apply per origin which resulted in a mess. Implementing multiple origins would result in 100% CloudFront web distribution coverage which would certainly be desirable. I'll make another attempt! |
The only downside of the CloudFront resource exporting zone_id is that it results in an otherwise unnecessary dependancy. But in most cases the Route53 record would be dependant on the distribution anyway. |
Hmm, interesting, can you explain that a bit more? e.g. explain some cases when the dependency can be harmful? |
I've now renamed the resource like you said. Much better! Regarding the dependancy, the only harmful scenario I can think of is a cycle but I do not think that is likely in this case. |
This is very similar issue to what I observed on RDS and Route53 records, both quite annoying, but sometimes you may want to wait. See #1124 and #1097 For the beginning, I'd personally not be bothered and just wait, even 40 mins, as long as all timeouts allow this, we should be safe. |
I see. I'll leave it as it is for now. Regarding the multiple origins: they are order dependant. I'm not sure how to best represent that in HCL. Got any suggestions? |
I've updated this PR with support for multiple origins. There are still challenges regarding the ordering of behaviors. It's not finished yet but I'm getting there! Updated example
|
I haven't tested the functionality, but I like the DSL 👍 |
Current status: I've been very busy with school and work. I will try and find the time to finish this next week! |
Hi and thanks for this job ! know you when this feature will be available ? I need it !! ;) |
AWS docs nitpicks (alphabetical sort + names)
Makefile: make go vet break the build
@AlexanderEkdahl Yes, that is usually what we do, probably better than showing error I assume? Unless you had different solution on mind. 😉 |
Not at all. Only thing remaining now is documentation and general cleanup. |
Hey @AlexanderEkdahl – are you still planning on completing this work? |
Definitely! However, this PR can be closed seeing how far behind my fork is. When finished I'll open another PR. I've got some ideas on how to circumvent the issues with terraform and double nested sets and lack of ordering in HCL. |
OK, thanks for the update @AlexanderEkdahl |
This pull request, and the original issue (#2723) are both closed. @AlexanderEkdahl, is your work still pending a new pull request? |
Work has stalled since HCL keys are unordered. Something which i find to be a weakness but I understand that it would be difficult to make ordered HCL keys compatible with JSON. Also it is not possible to programmatically read attributes from other resources which makes it difficult to solve in other ways. |
I'm not quite sure what do you mean by this - would you mind clarifying it? |
I believe this is backwards |
The problem is that I need nested content inside TypeSet which currently does not work with default values. Also the resources get extremely unwieldy to work with. I haven't given up on a complete CloudFront implementation but I've been very busy with other projects and work 😰 |
:( didn't realize we don't have this yet in Terraform. |
To clarify. My implementation works and I'm using it in one of my projects. It is just not good enough to be, in my opinion, merged into master. However if anyone wants to try and implement this by themselves I would gladly share my expertise. |
I personally would prefer something that works for 80% of use cases (single origin) be merged and iterated upon. I'd be happy to work on this in a week or two when I have more time. |
My initial implementation only supported one origin(see discussions above). I might revise that solution.. |
Hey, I just merged this branch locally and got it building again, seems pretty legit to me. I'd be happy to push my minor changes to get it building somewhere, if it helps get this merged. |
Here's my patch @AlexanderEkdahl @justincampbell https://gist.github.com/dalehamel/090118571e0227acb11b May it help you get this into master 🙏 FYI I just used it to set up a cloudfront distribution, and it worked pretty 👌 aside from one crash for a null pointer dereference. |
Please count this as another vote for getting CloudFront support into Terraform, even if only basic. |
I'm unable to get this building because of updates in the aws sdk. Terraform should really start vendoring its dependencies.. |
The panic that you are seeing is because you haven't whitelisted any cookies and it expects there to be a list of strings. That should be an easy fix in the code. I'm currently looking into it! |
New PR which removes support for multiple origins, applies @dalehamel changes and fixes the panic with whitelisted cookies can be found at #3330 |
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further. |
This is my stab at a CloudFront distribution. It works well and covers most use cases. However there are features that this schema does not support and I would like to hear your opinions on the matter.
CloudFront distributions supports multiple origins which this PR does not. I would gladly hear example where multiple origins are a necessity. Should this resource also support multiple regions or is this enough?Should it be namedaws_cf_distribution
oraws_cf_web_distribution
in order to not be confused with RTMP distributions?Is it even neccessary to wait until fully deployed? The terraform outputs are still correct, the user is however not guaranteed that the endpoint will be serving data correctly. For those unfamiliar with CloudFront, deploying takes 15 minutes.TODO
resourceAwsCloudFrontWebDistributionRead
Example Usage