Referring to resources named with variables in Terraform

I was fundamentally misunderstanding how modules worked.

Terraform does not support interpolation in resource names (see the relevant issues), but that doesn't matter in my case, because the resources of each instance of a module are in the instance's namespace. I was worried about resource names colliding, but the module system already handles that.


The picture below shows what is going on.

The terraform documentation does not make their use of "NAME" clear versus the "name" values that are used for the actual resources created by the infrastructure vender (like, AWS or Google Cloud).

Additionally, it isn't always "name=, but sometimes, say, "endpoint= or even "resource_group_name= or whatever.

And there are a couple of ways to generate multiple "name" values -- using count, variables, etc., or inside tfvar files and running terraform apply -var-file=foo.tfvars

terraform resource

Tags:

Terraform