-2

We have been doing,

node_selector = var.node_group != null ? { “${var.node_group}” = true } : null

and in tfvars we will have, node_selector = “NODEGROUP2” And it works correctly.

Tflint is throwing a warning on it as below, Warning: Interpolation-only expressions are deprecated in Terraform v0.12.14 (terraform_deprecated_interpolation)

Trying to understand what exactly its throwing warning and possible fixes? Is it complaining on “${}” and I have to set to set it as var.node_group ?

setting the line as,

node_selector = var.node_selector != null ? { “var.node_selector” = true } : null

clear the tflint warning, however value is not being replaced for var.node_selector

May be I can make my question much simpler, How do I make below work?

resource "random_pet" "this" {
  keepers = {
    "var.key" = "test"
  }
}

variable "key" {
  type        = string
  description = "test"
  default     = "ami_id"
}

Any thoughts?

Thanks.

Paul Floyd
  • 5,530
  • 5
  • 29
  • 43
Simon
  • 111
  • 1
  • 9
  • Yes, you can use the new syntax: `node_selector = var.node_selector != null ? { var.node_selector = true } : null`. – Marko E Jul 07 '23 at 08:08
  • I am also not sure what is the reason for using `=` sign after the variable, because I think that is not a valid comparison operator. – Marko E Jul 07 '23 at 08:14
  • I solved it by, keepers = { (var.key) = "test" } – Simon Jul 07 '23 at 09:04

1 Answers1

0
resource "random_pet" "this" {
  keepers = {
    (var.key) = "test"
  }
}

Solved as above, had to put the var inside parenthesis.

Simon
  • 111
  • 1
  • 9