diff --git a/terraform/evaluator.go b/terraform/evaluator.go index 8ecc8cb30..410fbe4a5 100644 --- a/terraform/evaluator.go +++ b/terraform/evaluator.go @@ -1,3 +1,6 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: BUSL-1.1 + package terraform import ( @@ -301,6 +304,10 @@ func (d *evaluationData) GetTerraformAttr(addr addrs.TerraformAttr, rng hcl.Rang workspaceName := d.Meta.Env return cty.StringVal(workspaceName), diags + case "applying": + // terraform.applying always returns false in TFLint + return cty.BoolVal(false).Mark(marks.Ephemeral), nil + case "env": // Prior to Terraform 0.12 there was an attribute "env", which was // an alias name for "workspace". This was deprecated and is now diff --git a/terraform/evaluator_test.go b/terraform/evaluator_test.go index cc747277f..fc3d9cfa2 100644 --- a/terraform/evaluator_test.go +++ b/terraform/evaluator_test.go @@ -170,6 +170,13 @@ variable "string_var" { want: `cty.StringVal("default")`, errCheck: neverHappend, }, + { + name: "terraform.applying", + expr: expr(`terraform.applying`), + ty: cty.Bool, + want: `cty.False.Mark(marks.Ephemeral)`, + errCheck: neverHappend, + }, { name: "interpolation in string", config: `