# Interpolation-only expressions are deprecated in Terraform v0.12.14

**URL:** <https://discuss.hashicorp.com/t/interpolation-only-expressions-are-deprecated-in-terraform-v0-12-14/55803>\
**Category:** Terraform\
**Created:** [July 7, 2023, 7:13am UTC](https://discuss.hashicorp.com/t/interpolation-only-expressions-are-deprecated-in-terraform-v0-12-14/55803 "2023-07-07T07:13:30Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![simon.mandy](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/simon.mandy/32/16508_2.png) [@simon.mandy](https://discuss.hashicorp.com/u/simon.mandy)\
**Post date:** [July 7, 2023, 7:13am UTC](https://discuss.hashicorp.com/t/interpolation-only-expressions-are-deprecated-in-terraform-v0-12-14/55803/1 "2023-07-07T07:13:30Z")

</div>

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 now 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

If I can make 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.

---

<div class="post-metadata">

**Author:** ![simon.mandy](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/simon.mandy/32/16508_2.png) [@simon.mandy](https://discuss.hashicorp.com/u/simon.mandy)\
**Post date:** [July 7, 2023, 9:06am UTC](https://discuss.hashicorp.com/t/interpolation-only-expressions-are-deprecated-in-terraform-v0-12-14/55803/2 "2023-07-07T09:06:20Z")

</div>

Solved as below,

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

```

Had to put var inside parenthesis.

---

<div class="post-metadata">

**Author:** ![maxb](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/maxb/32/26655_2.png) [@maxb](https://discuss.hashicorp.com/u/maxb)\
**Post date:** [July 7, 2023, 9:47am UTC](https://discuss.hashicorp.com/t/interpolation-only-expressions-are-deprecated-in-terraform-v0-12-14/55803/3 "2023-07-07T09:47:51Z")

</div>

Um, those aren’t parentheses…

Parentheses are not needed.

You simply write `var.key` with no additional punctuation at all.

---

<div class="post-metadata">

**Author:** ![simon.mandy](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/simon.mandy/32/16508_2.png) [@simon.mandy](https://discuss.hashicorp.com/u/simon.mandy)\
**Post date:** [July 7, 2023, 9:58am UTC](https://discuss.hashicorp.com/t/interpolation-only-expressions-are-deprecated-in-terraform-v0-12-14/55803/4 "2023-07-07T09:58:19Z")

</div>

Sorry edited the post.  
var.key within {} will throw terraform plan error  
“var.key” within {} wont error, but value for var.key wont get replaced.  
(var.key) within {} worked well.

---

<div class="post-metadata">

**Author:** ![maxb](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/maxb/32/26655_2.png) [@maxb](https://discuss.hashicorp.com/u/maxb)\
**Post date:** [July 7, 2023, 10:01am UTC](https://discuss.hashicorp.com/t/interpolation-only-expressions-are-deprecated-in-terraform-v0-12-14/55803/5 "2023-07-07T10:01:43Z")

</div>

Oh, I see.

It is not normal to have to use parentheses when dealing with an ‘interpolation-only expressions’ warning - however this is a special case because it is specifically in the context of an object key.

---

<div class="post-metadata">

**Author:** ![apparentlymart](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/apparentlymart/32/702_2.png) [@apparentlymart](https://discuss.hashicorp.com/u/apparentlymart)\
**Post date:** [July 7, 2023, 3:19pm UTC](https://discuss.hashicorp.com/t/interpolation-only-expressions-are-deprecated-in-terraform-v0-12-14/55803/6 "2023-07-07T15:19:25Z")

</div>

Indeed… this is a special exception in the language grammar because the most common situation is to write literal object attribute names, whereas a dynamic attribute name based on a reference to something else is less common.

For that reason, in this situation Terraform will treat an identifier there as a literal attribute name be default, but allows using other expression types as long as it isn’t ambiguous whether a literal name or reference was intended. Adding parentheses is one way to remove the ambiguity without changing the meaning of the expression, and so IIRC the error message for this situation recommends using parenthesis as shown above.
