github.com/terraform-linters/tflint@v0.51.2-0.20240520175844-3750771571b6/tflint/test-fixtures/module_with_count_for_each/module.tf (about)

     1  variable "config" {
     2    type = object({ instance_type = string })
     3    default = null
     4  }
     5  
     6  module "count_is_zero" {
     7    source = "./module"
     8    count = var.config != null ? 1 : 0
     9  
    10    instance_type = var.config.instance_type
    11  }
    12  
    13  module "count_is_one" {
    14    source = "./module"
    15    count = var.config != null ? 0 : 1
    16  
    17    instance_type = "t2.micro"
    18  }
    19  
    20  module "count_is_two" {
    21    source = "./module"
    22    count = var.config != null ? 0 : 2
    23  
    24    instance_type = "t${count.index}.micro"
    25  }
    26  
    27  variable "instance_types" {
    28    type = list(string)
    29    default = []
    30  }
    31  
    32  module "for_each_is_empty" {
    33    source = "./module"
    34    for_each = var.instance_types
    35  
    36    instance_type = each.value
    37  }
    38  
    39  variable "instance_types_with_default" {
    40    type = list(string)
    41    default = ["t2.micro", "t3.nano"]
    42  }
    43  
    44  module "for_each_is_not_empty" {
    45    source = "./module"
    46    for_each = var.instance_types_with_default
    47  
    48    instance_type = each.value
    49  }