Referring to resources named with variables in Terraform

后端 未结 2 805
广开言路
广开言路 2021-02-12 21:49

I\'m trying to create a module in Terraform that can be instantiated multiple times with different variable inputs. Within the module, how do I reference resources when their na

2条回答
  •  北海茫月
    2021-02-12 22:41

    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

提交回复
热议问题