-
Notifications
You must be signed in to change notification settings - Fork 10k
Description
Current Terraform Version
Terraform v0.12.0-alpha4 (2c36829d3265661d8edbd5014de8090ea7e2a076)
+ provider.random v2.0.0-5-g612dff2-dev
Use-cases
I'd like to be able to use resource_type.*.id
to get a list of the id
of every resource of a type; currently, you can only do this for resources that have a count
attribute (or eventually for_each
, I guess). Sometimes, you have a bunch of resources you want to declare explicitly because they don't necessarily have very much in common, but you still want to refer to them all from another resource.
My explicit use-case is the third-party auth0
provider. I've got a bunch of auth0_client
resources that all have their own custom configuration. Then, I've got an auth0_connection
resource which represents our actual identity provider (an LDAP server). In creating the auth0_connection
resource, I need to pass a list of auth0_client
ids that that connection will be used for. And I'd love to get that list of ids by simply writing auth0_client.*.client_id
. But that's not possible.
Attempted Solutions
This didn't work:
resource "random_id" "foo" {
byte_length = 1
}
resource "random_id" "bar" {
byte_length = 1
}
output "example" {
value = "${random_id.*.hex}"
}
I got this error:
$terraform validate
Error: Invalid reference
on test.tf line 12, in output "example":
12: value = "${random_id.*.hex}"
A reference to a resource type must be followed by at least one attribute
access, specifying the resource name.
A similar attempt with random_id[*].hex
also failed.