Open black-snow opened 1 year ago
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 oismail@hashicorp.com and would love to setup a time to talk :).
@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.
@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.
Is there still no plans to support it within child modules?
https://github.com/hashicorp/terraform/issues/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.
@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? oismail@hashicorp.com
Terraform Version
Use Cases
I love the new import block. Sadly, it seems to be less useful for modules as:
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
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