Quantcast
Channel: Terraform - HashiCorp Discuss
Viewing all articles
Browse latest Browse all 11417

Create resources conditionally without using count

$
0
0

A well known technique to control the conditional creation of resources is to use something like:

count = var.create_resource ? 1 : 0

and I tried this with the Azure provider on resources such as:

resource "azuread_service_principal_password" "auth" {
  service_principal_id = azuread_service_principal.auth.id
  value                = random_string.password.result
  end_date_relative    = "240h"
}

The problem with this is that because there is no for_each loop involved terraform plan instructed me to use an index on (for example) value = random_string.password.result, the problem being that this does not like an index. My question is therefore this, how can I achieve the same result as using count but without using count.

1 post - 1 participant

Read full topic


Viewing all articles
Browse latest Browse all 11417

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>