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

Utility to autogenerate a terraform module #1518

Open
sed-i opened this issue Feb 13, 2024 · 4 comments
Open

Utility to autogenerate a terraform module #1518

sed-i opened this issue Feb 13, 2024 · 4 comments
Labels
Enhancement New feature or request

Comments

@sed-i
Copy link
Contributor

sed-i commented Feb 13, 2024

What needs to get done

Terraform modules for charms seem to be quite deterministic and repeatable, for example:

If indeed possible, it would be great to enable this for the entire ecosystem with something like

  • charmcraft terraform
  • tox -e terraform

And have it evolve organically with each charm.

Why it needs to get done

A uniform solution for the entire ecosystem, simplifying maintenance overhead for multiple teams.

@sed-i sed-i added the Enhancement New feature or request label Feb 13, 2024
Copy link

Thank you for reporting us your feedback!

The internal ticket has been created: https://warthogs.atlassian.net/browse/CRAFT-2492.

This message was autogenerated

@gatici
Copy link

gatici commented Feb 13, 2024

Thanks @sed-i for opening the issue. That's great idea to generate Terraform modules of each charm by the help of charmcraft. As a Telco team, we manually produced the Terraform modules for each SD-Core charms as we are aiming to replace the bundles with high level Terraform modules.

We tried to keep the things as much as generic to reduce the maintenance cost. For example, used monolithic configuration instead of expanding each config parameters. However, we still need to maintain the relation endpoints manually.

The charms' Terraform modules could be used in the integration tests. Setting a an integration environment and testing the scenarios using Terraform will be quite straightforward.

The Terraform module's structure seems explicit. I hope it will be feasible to generate them automatically.

@Gmerold
Copy link

Gmerold commented Feb 13, 2024

I think it would be really cool to have it. This would significantly minimize the effort of creating modules.
And it should also have a corresponding GitHub action too ;)

Having that said, I see two things worth mentioning:

  1. Creating Terraform modules for bundles - While we could have them generated based on the bundle.yaml, it doesn't make any sense to create a bundle just to replace with a Terraform module :) This part would probably have to stay manual.

  2. Publishing our modules to the public Terraform registry - Generating Terraform modules based on metadata.yaml of the charm means that the Terraform module will live in the charm repo. This means we won't be able to publish our modules to the public Terraform registry (it has specific requirements for the repository name, which we don't meet). To reuse the module, we'll have to source it from Git directly. Probably not a big deal, but worth noting. Perhaps, at some point, Canonical could host a private registry?

@lengau
Copy link
Collaborator

lengau commented Aug 29, 2024

I've never actually created a terraform module so I'm not sure how feasible this is, but looking at the source docs I don't see why not. My main concern is that Charmcraft will probably need to generate pretty opinionated versions of these, and if I used my own novice opinions it would probably produce some bad ones, so I'd like to get stakeholder feedback on it.

Would it be reasonable to use jinja templates to generate the Terraform modules? We're already using them for init, and if can use that we could have relevant user stakeholders (you, @ghislainbourgeois, etc.) take ownership of them and iterate them (with the command being marked as experimental) until you're comfortable that they're stable.

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

4 participants