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

Config-driven import | generate code for modules, too #33376

Open
black-snow opened this issue Jun 15, 2023 · 5 comments
Open

Config-driven import | generate code for modules, too #33376

black-snow opened this issue Jun 15, 2023 · 5 comments

Comments

@black-snow
Copy link

black-snow commented Jun 15, 2023

Terraform Version

1.5.0

Use Cases

I love the new import block. Sadly, it seems to be less useful for modules as:

  1. import has to be at root level
  2. cannot import into (generate code for) stuff within modules

My use case is not only to import but also have the corresponding code generated (which works fine for top-level resources).
My current workaround is

  • to point the import at top level
  • run plan with code generation
  • move code into module
  • point import to the resource within the module
  • apply

This usually works but involves a lot of manual steps, and I think the block was intended to remove that manual burden. Maybe I'm missing something here.

Attempted Solutions

current workaround s. a.

Proposal

I'd like tf to generate code for modules as well. Ideally, I'd just point the import to a non-existing resource within a module (local one) and the existing file or folder and tf would generate the code and append it to the file or create a file within the given folder.

I may fail for non-local modules, of course.

References

No response

@black-snow black-snow added enhancement new new issue not yet triaged labels Jun 15, 2023
@omarismail
Copy link
Contributor

Hey @black-snow , thank you for this request!

We do intend on supporting import{} natively within modules, but are still working through the design. I'd be happy to chat more about this in detail! Please email me at [email protected] and would love to setup a time to talk :).

@kmoe kmoe removed the new new issue not yet triaged label Jun 19, 2023
@Vermyndax
Copy link

@black-snow could you give a little more data on your workaround? We usually create our Terraform based on community modules only, and have to have a pretty big justification for writing and maintaining our own modules. We'd like to use the new import functionality to bring existing resources into community-based modules, but we don't see an easy way to do this right now.

@black-snow
Copy link
Author

@Vermyndax I don't see how this could currently work. I'd do it manually or write a short pre-processor if it's too much to handle manually.

@TrueCyberAxe
Copy link

Is there still no plans to support it within child modules?

#33474 <--- i have posted a number of scenarios where it would be helpful for us

It's pretty useless as is being limited to the root module, solves a lot of issues with the ability to use it in child modules.

If the issue is "safety", that's why atlas has a built in plan step so you can review the changes before they are applied.

@omarismail
Copy link
Contributor

@TrueCyberAxe @black-snow @Vermyndax

I'd love to chat through this use case more. Could you email me and we can find time to chat? [email protected]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants