Skip to content
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

Support for Terraform modules #325

Open
1 task done
rlmartin opened this issue Jul 17, 2023 · 1 comment
Open
1 task done

Support for Terraform modules #325

rlmartin opened this issue Jul 17, 2023 · 1 comment
Labels
enhancement New feature or request

Comments

@rlmartin
Copy link
Contributor

rlmartin commented Jul 17, 2023

Description

I am working on a CDKTF Construct that uses a Terraform module for some of its resources. I was going to take the same approach with the module "dependency" as the recommended approach for providers - which seems to be to reference pre-built providers as peer dependencies of the construct. Does this seem like a reasonable approach?

If this is the right approach, I was looking for the established pattern to produce pre-built modules based on existing Terraform modules. I found the project-cdktf-hybrid-construct, which seems like a first attempt, but it appears only lightly maintained - plus does not include the nice auto-upgrade feature provided by this template for providers.

As such, I was considering considering tweaking this project template to also support Terraform modules. I don't have a strong opinion on whether it is a fork of this repo vs an alternative configuration option - would take any input. The necessary change seems somewhat minor - I think I could even take it on myself and submit a PR. But before doing that work I wanted to see if people feel like this is the right direction.

I think the thing that I don't intuitively understand is where Terraform dependencies will result in conflicts - and how to avoid/manage that. For example, the pre-built library that is generated for the Terraform module will most likely depend on one or more Terraform providers. If the repo using the pre-built module library uses the same provider in a pre-built manner but that provider is built from a different Terraform provider version than the one in the pre-built module - will this be a problem?

References

No response

Help Wanted

  • I'm interested in contributing a fix myself

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment
@rlmartin rlmartin added the enhancement New feature or request label Jul 17, 2023
@rlmartin rlmartin changed the title Support for terraform modules Support for Terraform modules Jul 17, 2023
@ansgarm
Copy link
Contributor

ansgarm commented Aug 4, 2023

Hi @rlmartin 👋

While we currently don't have concrete plans for publishing pre-built modules ourselves, we'd probably start with duplicating this Projen template into a new repository and adjusting it to the needs for Terraform modules (which probably would mean simplifying some things and adjusting others, like e.g. the upgrade flow). Even if we currently don't have plans for pre-built modules, we'd still welcome you taking a stab at this and would be open to give feedback and be there for any questions that might pop up. But we also can't promise that we'd continue the work you start.

The dependency problem you mention is a hard one that still needs a solution 😅 However, modules don't require the provider to be present when their bindings are generated and compiled, so we could even shift that responsibility to the user. Specifying a peerDependency would probably be the best UX, but a user could still use locally generated bindings with an incompatible version 😄 So yeah, this needs some deeper thoughts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants