diff --git a/helper/runner.go b/helper/runner.go index ffe0fb6..2399007 100644 --- a/helper/runner.go +++ b/helper/runner.go @@ -415,6 +415,9 @@ func decodeVariableBlock(block *hcl.Block) (*Variable, hcl.Diagnostics) { { Name: "sensitive", }, + { + Name: "ephemeral", + }, }, }) if diags.HasErrors() { @@ -438,6 +441,15 @@ func decodeVariableBlock(block *hcl.Block) (*Variable, hcl.Diagnostics) { v.Default = v.Default.Mark(marks.Sensitive) } + if attr, exists := content.Attributes["ephemeral"]; exists { + var ephemeral bool + diags := gohcl.DecodeExpression(attr.Expr, nil, &ephemeral) + if diags.HasErrors() { + return v, diags + } + + v.Default = v.Default.Mark(marks.Ephemeral) + } return v, nil } diff --git a/helper/runner_test.go b/helper/runner_test.go index 88f23af..585ca42 100644 --- a/helper/runner_test.go +++ b/helper/runner_test.go @@ -622,6 +622,20 @@ resource "aws_instance" "foo" { }`, Want: `cty.StringVal("secret").Mark(marks.Sensitive)`, }, + { + Name: "ephemeral variable", + Src: ` +variable "instance_type" { + type = string + default = "secret" + ephemeral = true +} + +resource "aws_instance" "foo" { + instance_type = var.instance_type +}`, + Want: `cty.StringVal("secret").Mark(marks.Ephemeral)`, + }, } for _, test := range tests {