Open vazome opened 1 month ago
Thanks for this report! If you are viewing this issue and would like to indicate your interest, please use the 👍 reaction on the issue description to upvote this issue. We also welcome additional use case descriptions. Thanks again!
I've relabelled this as an enhancement instead of a bug.
There are three kinds of modules: local, registry and remote. Generating configuration for registry and remote based modules from the root module is not something that will ever be possible. It does seem possible that we could add support for generating configuration within local modules.
It's worth noting there are considerable complications with this given the -generate-config-out
command points to a single file location. We'd need to update that to allow specifying the file within the local module, and then also make sure there aren't import blocks requesting configuration generation across multiple modules as the file will only be written to a single module. Potentially, the flag could support multiple file locations with a requirement that every module that wants to generate config needs to have a file included.
A workaround here would be to generate the configuration at the root level, and then move the generated configuration into the local module, before rerunning the plan command to connect the import block up to the correct module.
If you're interested in this as a feature, please give a 👍 reaction to the original comment!
Terraform Version
Terraform Configuration Files
Debug Output
https://gist.github.com/vazome/d639adc98c0999d0edae4abf80f4a816
Expected Behavior
Terraform creates resource configuration file for the given import
Actual Behavior
│ Error: Configuration for import target does not exist │ │ on main.tf line 15, in import: │ 15: to = module.azure-rg.azurerm_resource_group.rg-databricks │ │ The configuration for the given import target module.azure-rg.azurerm_resource_group.rg-databricks does not exist. All target │ instances must have an associated configuration to be imported.
Steps to Reproduce
terraform plan -generate-config-out=generated_resources.tf
Additional Context
This issue seems to be covered in this Japanese blog
References
No response