Closed andreibodi22 closed 18 hours ago
Hi @andreibodi22, generating configuration from an import block with a for_each
is unfortunately not currently supported. Including the for_each
increases the complexity of the config generation a great deal, as Terraform must work out a data structure to share the referenced data for each instance of the target resource.
However, you can still use the import
block alongside a for_each
if you wrote the resource block yourself, or split the alerts into separate import blocks.
Terraform Version
Terraform Configuration Files
Debug Output
Expected Behavior
I wanted to ask if this is a bug in my Terraform version or if it’s really not possible to do this. I wouldn’t want to just import them and then copy the configuration from the state file; I’d like to use the import block.
Actual Behavior
I can't import multiple resources at once with for_each and use terraform
terraformplan -generate-config-out=prometheus_alerts.tf.
Steps to Reproduce
terraform init terraform plan -generate-config-out=prometheus_alerts.tf
Additional Context
No response
References
No response