generated from ansible-collections/collection_template
-
Notifications
You must be signed in to change notification settings - Fork 51
Open
Labels
Description
SUMMARY
A common feature of terraform is to use the for_each or count meta.argument in resource definition blocks, to create multiple instances from the same resource block.
I can't see that this is currently supported. Creating an inventory from such a state currently only imports the last instance of the resource definition into the dynamic inventory.
ISSUE TYPE
- Feature Idea
COMPONENT NAME
inventory plugin: terraform_state
ADDITIONAL INFORMATION
Example terraform configuration.
locals {
subnet_ids = toset([
"subnet-abcdef",
"subnet-012345",
])
}
resource "aws_instance" "server" {
for_each = local.subnet_ids
ami = "ami-a1b2c3d4"
instance_type = "t2.micro"
subnet_id = each.key
tags = {
Name = "Server ${each.key}"
}
}
https://developer.hashicorp.com/terraform/language/meta-arguments/for_each#referring-to-instances