I am writing a provider and are able to terraform import in my ressources but get these errors, when I try to import in a for_each ressource.
Do I have to take additional preparations to achieve an import in a for_each ressource?
resource "bam_txt_record" "txt_records" {
for_each = {for i, v in var.txt_records: "v.fqdn" => v }
fqdn = each.value.fqdn
config_name = each.value.config_name
view_name = each.value.view_name
comment = each.value.comment
ttl = each.value.ttl
text = each.value.text
}
resource "bam_txt_record" "testdomain" {
fqdn = "testdomaein"
ttl = 60
comment = "comment"
config_name = "EXTERN"
view_name = "extern"
text = "testext"
}
Working: terraform import ‘bam_txt_record.testdomaint’ 28028185
Not working: terraform import ‘bam_txt_record.txt_records[“testdomain”]’ 28028185
No Errors, says successfully imported without writing anything to state:
2023-10-04T16:16:51.678+0200 [INFO] provider.terraform-provider-bam: Test: tf_provider_addr=dmTECH/dns/bam tf_req_id=468ebcb1-556b-04ab-e2b4-ddb1d2acab03 tf_rpc=ConfigureProvider @caller=/Users/marco.helmerich/git/bam-provider/internal/provider/provider.go:204 @module=bam timestamp=2023-10-04T16:16:51.678+0200
2023-10-04T16:16:51.682+0200 [INFO] Writing state output to:
Import successful!
The resources that were imported are shown above. These resources are now in
your Terraform state and will henceforth be managed by Terraform.