-
Notifications
You must be signed in to change notification settings - Fork 32
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
terraform: estimation of HCL module directory #45
Conversation
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.
I'm not sure to be entirely able to review this PR as there are many pieces of code that I don't get. Which makes me think, it might be worth commenting more the function & also provide example of the data we are dealing with/extracting.
Otherwise the set of tests are pretty good, I feel like it's missing a couple of those:
- Remote module(s) - all seem local ATM (could be a TODO)
- Types seem simple - I don't see map/sliced but I'm not sure those have an impact cost wise?
- There are no modules in modules (local nor remote)
if rv.ProviderConfigRef != nil { | ||
providerKey = rv.ProviderConfigRef.String() | ||
} | ||
provider := providers[providerKey] |
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.
Can only be found I guess?
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.
Since it's an interface{}
, it will be nil
if not found in the map. This is then checked later down: https://github.com/cycloidio/terracost/pull/45/files/5583ecf7da89196e5d59e1c64f1d5838d13148e3..4e0d5949fce9e0218d1f2b9f0f9184dc967e4952#diff-d88d3b92409f1211e4b636160025511bac9b8ab47d7c06375fd0092f53cf5763R69
if !val.IsKnown() { | ||
continue | ||
} | ||
switch val.Type() { |
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.
No need to deal with maps or slices?
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.
IMO there's no need, I can't think of any resource that would use them for any cost-related attributes. For sure we don't support any ATM. Though there's bool
missing that I will add.
Yep, I tried to document it in the most important places but I will add some more. WDYM by the example? There is the Terraform module example in
There is no support for remote modules, only local at the moment. IMO for the first version, we can skip it and add it in later. Correct me if I'm wrong but I think all https://github.com/cycloid-community-catalog stacks use only local modules?
Yes, at least for the resources we support there's only simple values or blocks (that are handled correctly.)
Thanks, I will add this! |
A vast majority of them indeed. So I agree we can still skip them for now - might be good if we are able to highlight it somewhere FE/BE.
I mean within the codes comment to say the input is from X of the form |
I added some more comments but if there are some places that I missed that would benefit from better doc, please mark them |
The new functionality includes extraction of resources from HCL modules in the form of local directories.
The EstimateHCL function estimates the plan costs based on an HCL module directory.
This PR adds support for the estimation of HCL files in the form of a local Terraform module directory. It closes #29.
Limitations:
These limitations might be fine for the first version of the support.