-
Notifications
You must be signed in to change notification settings - Fork 9.5k
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
[WIP] provider/aws: CloudFront #3330
Conversation
Works with both custom origins, s3 buckets and s3 website endpoints.
|
@AlexanderEkdahl Awesome! @justincampbell what's left to get this to 🚢 💨 ? |
@AlexanderEkdahl Thanks for re-submitting this! After a first quick look it looks fine, but someone will give it a thorough review before actually merging it in, probably after HashiConf, when most maintainers should be less busy :) |
Thanks for working on this! I thought the previous attempts had been abandoned so I'd started one in #3259, but I'm very happy for you to finish this up instead. :) My attempt supported multiple origins and both S3 and custom origin types, but it annoyed me that this complicated the "easy" case of having just one origin, so I was planning to do another pass at that. If you want to borrow anything from my implementation then you're very welcome to, but getting the simple case merged first is a fine idea too, as long as there is a non-breaking-change path from here to there. |
From what I can see your implementation does not support multiple behaviors and linking them to an origin. Without that multiple origins does not do anything because every request will be routed to the the first origin anyway. This PR support both S3 and custom origins as well. But like you said. Adding support for multiple origins and behaviors wont break old configurations 👊 |
Definitely looking forward to this, I don't need multi origins/behaviors, so would be more than happy with the current implementation 👍 |
Also make sure that this gets updated in the AWS coverage sheet. See #28. |
@radeksimko @catsby @justincampbell Have any of you had any time to review this? |
👍 for Cloudfront support. Kudos to @AlexanderEkdahl |
@radeksimko do you have any update on when do you expect a more thorough review? Would be great to see this merged back. |
Looking forward to seeing Cloudfront supported! |
I've rebased my PR on top of master for your convenience. |
Hi, |
I tried running attached acceptance tests and it has errored out unfortunately:
|
That certainly did not happen when I initially created this. This is the second time the API introduces breaking changes and it only happens with the update method. Creating a resource is not as strict but updating a resource requires every parameter. This could be a problem in the future... I'll look into it! |
return res, nil | ||
} | ||
|
||
func resourceAwsCloudFrontWebDistributionAwsStringLists(in interface{}) []*string { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be probably best to remove this function here and use expandStringList
instead. It does exactly the same thing and we use it in other resources already.
@AlexanderEkdahl I'm waiting for this CloudFront support too. I can free up a developer to complete your work. He recently contributed the |
@ringods speaking for myself, yes please 😄 |
I'm currently working on this. I've updated the tests in accordance with @radeksimko feedback and I'm currently investigating some SSL changes that have been made to the API since last working on this. Gzip compression is also new which should be supported by this resource. |
thanks for all your work on this @AlexanderEkdahl! |
Hi @AlexanderEkdahl, let us know when you'd like us to re-review for you! |
We can ship without this and have it in a follow up PR, if that's easier for you. |
I'm happy to re-review this and also agree with other folks that it's better to ship minimal implementation which works, rather than trying to implement possibly all relevant features in this PR. If you cannot spend more time on this, then letting @ringods / @fromonesrc finish this is also an option. You'd still be very likely listed as the author in git and we'd very likely include the original commits (unless the mentioned guys would have decided to rework it completely from scratch, which I don't think is necessary). |
thanks for the great work @AlexanderEkdahl. I've just tested the feature as part of our infra in a throwaway environment and I thought I'd share my experience/feedback. The PR merges cleanly on top of
Most important though that the resource creation takes ages and resulted in a Terraform crash. I realize that the resource needs to become "Enabled" and CloudFront takes long to create a distribution but it seemed that long creation time was causing the crash. I've uploaded the relevant part of the crash.log to Gist: https://gist.github.com/rgabo/e3b542be97fffd6416f4 Hope this helps and we will keep testing. |
Glad that it worked for you. Regarding multiple origin support it is something that could be added without breaking previous Terraform configurations. Multiple origins would also require multiple behaviors in order to be usable which would be a lot of work. @rgabo Regarding the bucket id, does that also apply for buckets outside the standard region? If that is the case the suffix is indeed unnecessary. There are two problems with developing a Cloudfront provider. The first is that testing takes ages since every operation on a distribution takes approximately 15 minutes. The other problem is that while creating a resource does not require every parameter to be set, updating a resource creates every parameter to be valid. This breaks compatibility whenever Cloudfront changes their API. A possible workaround would be to download the current configuration and merge it before any update... |
If someone else wants to finish this I'm all for it and you can contact me directly if you have any questions. It should only be a matter of adding gzip compression, maybe add another test case, and changing everything according to @radeksimko suggestions which are all legit. |
At work we would like to see support for this as well so I would be happy to take a look at finishing any outstanding functionality and concerns. |
Things that need to be done:
|
We need this here at PBP (very soon, was surprised to see it wasn't in already), so I'm willing to add my increment to the attempt counter. @johnewart have you started any work on this? |
I have and should be able to finish up next week |
@johnewart thanks for the reply. First off, I'd like to acknowledge the efforts of everyone here. After looking the SDK bits for this for the last day or so, I can really say that this is probably the most frustrating part of the AWS SDK that I've worked with so far - the configuration structure is very complicated. That said, I personally have dove into the code the last couple of days and found some concerns:
It's my opinion that the structure of the resource should be changed so that it better matches the CloudFormation resource. Yes, this will take a lot of interpolation for variables that are required in SDK but are not necessarily required to set up the distribution (I'm kind of wondering why length/data pairs were needed in such abundance in the config structure), but if this is to be scalable, and Terraform really does want to stick to API as much as possible, it needs to be done. I did start some work on this that I want to finish - I'm not the biggest fan of work duplication but I hope it will help get people considering how this should look if it's to be scalable. PS: I don't think that anyone should have to go to CloudFormation for something because the Terraform resource can't match its features. Something about that just seems wrong to me. PPS: For testing, and possibly even just setup in general, waiting for the distribution to come online may be unnecessary. I'll annotate what I'm talking about. Also, adding a |
Looks like this is close. Will this be in next release? |
Guys, My refactor is nearly complete. The branch is here: https://github.com/paybyphone/terraform/tree/cloudfront_v3 It is functional, the acceptance tests work (but they have The acceptance tests are pretty much the CloudFormation examples, and cover multiple scenarios:
As there is a lot to cover here, I'd like to let the source speak for itself for now, any feedback is welcome and I'll try and move on it ASAP. Some things I will be implementing shortly:
Feedback is welcome. I'd like @AlexanderEkdahl's efforts to be recognized on this, but the scale of the refactor is pretty vast and there is not much original code left, so I'm not too sure on how to proceed. |
Great, @vancluever! I'd be happy with it shipping without |
Thanks @fromonesrc! This resource is definitely complete on its own - as long as you adhere to the rules in the documentation as to what needs to be a single element only, it should be stable. I'm actually working on a specific Again, need feedback, I can just open a new PR if that would speed things along. |
Guys, I've added #5221 just to streamline merging of my branch. Also the new squash includes some re-factors to ensure it works with the latest TF, and the Waiting with bated breath ;) |
Closing this in favor of #5221– I'll get it reviewed and in as soon as possible |
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. |
Created a new PR as this is a rewritten implementation of my earlier attempt. The only feature not supported are multiple origins and behaviors.
Also worth noting is the fragility of the CloudFront API. Whenever a new attribute is added(DefaultTTL was added this summer) they are optional when creating the resource but not when updating an existing resource. Hopefully this does not happen too often.
previous PR: #1780
@radeksimko @justincampbell @dalehamel