- Notifications
You must be signed in to change notification settings - Fork9.9k
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 useresource_type.*.id
to get a list of theid
of every resource of a type; currently, you can only do this for resources that have acount
attribute (or eventuallyfor_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-partyauth0
provider. I've got a bunch ofauth0_client
resources that all have their own custom configuration. Then, I've got anauth0_connection
resource which represents our actual identity provider (an LDAP server). In creating theauth0_connection
resource, I need to pass a list ofauth0_client
ids that that connection will be used for. And I'dlove to get that list of ids by simply writingauth0_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 validateError: 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 attributeaccess, specifying the resource name.
A similar attempt withrandom_id[*].hex
also failed.