-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Import block expansion with for_each not working #34249
Copy link
Copy link
Closed as not planned
Labels
Description
Terraform Version
1.6.3Terraform Configuration Files
this code is inside import.tf file
import {
for_each = {
"bucket1" = "bucket1"
"bucket2" = "bucket2"
}
to = aws_s3_bucket.this[each.key]
id = each.value
}
Debug Output
╷
│ Error: Unsupported argument
│
│ on import-for-each.tf line 8, in import:
│ 8: for_each = {
│
│ An argument named "for_each" is not expected here.
╵
Expected Behavior
I expected both the existing s3 buckets "bucket1" and "bucket2" to be imported at once into our TF workspace.
Actual Behavior
It resulted in an error saying "An argument named "for_each" is not expected here".
But I see this feature to support for_each inside an import block is already merged in
https://github.com/hashicorp/terraform/pull/33932
Steps to Reproduce
- terraform init
- terraform validate
Additional Context
We have around 150 s3 buckets that we need to import into workspace. We are trying to use for_each inside an import block to import all the buckets at once and save a lot of manual work.
Really appreciate your help here
References
Reactions are currently unavailable