Replies: 1 comment 3 replies
-
Sounds like you don't want to actually evaluate the expression in question. Expression evaluation is the process of producing an actual value given a context. You just want to inspect syntax: https://pkg.go.dev/github.com/hashicorp/hcl/v2/hclsyntax There are some examples in the |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I am creating a custom tflint rule
tags_local_rule
to check if the attributetags
is set tolocal.tags
so that if the attribute is not set as required, the rule will emit an issue indicating that thetags
attribute should be set tolocal.tags
. This is a business driven pattern I need to enforce. Is there a way (regexp or otherwise) to check iftags=local.tags
and even better convertcty.ObjectVal(map[string]cty.Value{"Module":cty.StringVal("lambda1")})
to a readable format?Expected Behavior
Basically for a Terraform configuration containing multiple resource blocks, when I execute
tags_local_rule
rule, then the rule should traverse blocks to find thetags
attribute andFor each resource block that contains the
tags
attribute, it should check if the value is set tolocal.tags
.Result: Should not emit issue. Should print:
local.tags
matches patternlocal.tags
If the
tags
attribute is not set tolocal.tags
(e.g.tags = var.tags
), the rule should emit an issue indicating that thetags
attribute should be set tolocal.tags
.Result: Should emit issue
The rule should pass if all resource blocks with the
tags
are set tolocal.tags
.Current Behaviour
For each resource block that contains the
tags
attribute, it should check if the value is set tolocal.tags
.Result: Emits below error
If the
tags
attribute is not set tolocal.tags
(e.g.tags = var.tags
), the rule should emit an issue indicating that thetags
attribute should be set tolocal.tags
.Steps to Reproduce
tags_local_rule
variables.tf
main.tf
Beta Was this translation helpful? Give feedback.
All reactions