-
Notifications
You must be signed in to change notification settings - Fork 360
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Plugins fail when evaluating an attribute with a heredoc value #1029
Comments
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Folks, refrain from "+1" comments that don't add new information to the issue. You can keep up to date by subscribing to the thread and register your interest in the issue by adding a 👍🏻 to the original post. |
Not gonna have time to fix this right this second, but leaving behind some bread crumbs. This minimal heredoc case passes: locals {
heredoc = <<EOF
Here!
EOF
} Failure happens when the AWS plugin is introduced: resource "aws_ecr_lifecycle_policy" "test" {
policy = <<EOF
{}
EOF
} With output:
The originally submitted configuration is not valid on its own and therefore triggers a different error if evaluated:
The issue reporting the "Reference to undeclared input variable" is a separate one. |
@bendrucker You may try to use |
Are you suggesting that as a workaround? That's certainly well and good, I don't write literal JSON in heredocs either. But users should generally refrain from updating rather than rewriting their code. Or are you saying there's another issue? |
Moving the heredoc to locals and then referencing the value works. I had to remove the variables from the configuration before submitting it. With proper values the errors is the same. |
TFLint doesn't evaluate locals at the moment (#571) so that will prevent TFLint from evaluating the attribute at all. If this is acceptable, disabling the |
I see, was not aware of that. I tried disabling the rule but my problem is I call tflint in a CI environment for multiple terraform configurations some of which are not for AWS and don't have this rule. I think for now I will stay with locals setup until there is a fix. Thanks for the info! |
Nope, just a quick workaround. |
In your above breadcrumbs comment you mentioned the minimal heredoc case passes, but that's set in a locals block and your stating a local's block isn't evaluated by tflint. So there may be an issue with the minimal case test. I'm assuming this error is going to pop up anywhere someone tries to use heredoc outside of locals block and referencing it. Just for reference I'm getting the same error with a different resource.
|
The notable bit about that repro is that it shows that the issue comes from evaluating the attribute value rather than when parsing the doc. That can be inferred from the error too but isn't necessarily obvious. And yes this will apply equally to any rule that tries to evaluate a heredoc expression. |
This seems to be an HCL issue when parsing heredoc as an expression. If you are interested in the implementation, please see here as well. hashicorp/hcl#441 As a workaround, I think there's a way to always add a newline at the end when the plugin parses the expression, and I would like to hear opinions from the HCL dev team about this. |
Hey @bendrucker I have the same problem while upgrading to terraform 0.13.
And it is very convenient for us. But it fails with tflint 0.23. I moved
It seems to work. Best regards, |
I have an issue with a ecr_lifecycle_policy defined with a heredoc.
Version
It was working fine on v0.22.0
The text was updated successfully, but these errors were encountered: