Amman
Amman

Reputation: 317

Terraform: The condition expression must be of type bool

Variable.tf

home_region      = var.home_region

code.tf

resource compute abc

count = local.home_region ? 1 : 0

compartment_id = local.compute_comp_id
--
--
---

Error: Incorrect condition type

 on modules/compute/main.tf line 34, in resource "compute" "abc"   
  34:   count = local.home_region ? 1 : 0   
    |----------------   
    | local.home_region is "us-ashburn-1"   
   
The condition expression must be of type bool.   

What should I do to fix this error?

Upvotes: 3

Views: 5166

Answers (1)

Marcin
Marcin

Reputation: 238081

This means that you need to have some bool expression, such as:

count = local.home_region == "us-ashburn-1" ? 1 : 0

The expression will vary, depending on what you want to test for.

Upvotes: 4

Related Questions