-
Notifications
You must be signed in to change notification settings - Fork 73
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
fix: Fixed regression in tags with dynamic values #511
fix: Fixed regression in tags with dynamic values #511
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, can you try to get test coverage added here? This should work:
resource "aws_s3_bucket" "a" {
tags = {
NotFoo = "bar"
}
}
resource "aws_s3_bucket" "b" {
tags = aws_s3_bucket.a.tags
}
Where Foo
is a required tag. There should be an issue on the first resource, but not the second. Even if we managed to figure out map key evaluation a la for_each
, this kind of reference would always be unknown. And shouldn't run up against issues with lack of support for reading data sources.
You could probably do the same with the provider
block's default_tags
block, although it'll get slightly contrived. You'd probably have to have a provider alias b
used with aws_s3_bucket.b
and set the tags
in that provider instead of on the resource.
Another option might be to use the sensitive()
function, since sensitive values are handled by TFLint in a similar way to unknown/null values, as detailed in EvaluateExpr
's docs.
On it! |
So, this fails
With
Also, neither functions nor locals seem to be available using the test local runner. Putting in here for visibility https://github.com/hashicorp/terraform/blob/main/internal/terraform/eval_for_each.go |
Ok, thanks for trying/confirming. A But I just verified that this only works when a
However, if you change your |
See terraform-linters/tflint-plugin-sdk#64 for the tracking issue that explains why the tests behave different than a real run in which the CLI communicates with the ruleset plugin over RPC. Terraform tackled a similar issue and added a dependency on the Terraform CLI for the provider acceptance testing package, where it used to be a custom runner for testing, IIRC skipping RPC and calling the provider directly via its Go API. They switched to a more "E2E" style that writes each test step's config to a temporary directory and invokes a real Terraform CLI that targets a provider binary built to a temp directory. Even though their previous test runner was more comprehensive than TFLint's, they made the switch for similar reasons—differing behavior between tests and real CLI-driven Terraform runs. |
- Fixed the error when using dynamic values in tags without the usage of default_tags that showed issues even though the tag Key was present - Added debug logs Signed-off-by: Jorge Reus <[email protected]>
68b1ac4
to
dea5bcc
Compare
You were completely right @bendrucker! Using Added two testcases one for not wholly known and one for completely uknown, LMK if anything has to be changed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work here!
Fixes #510
This fixes the regression when using dynamic values, in a sense.
The root cause is the runner API not recognizing the values, this PR only ignores the error and continues, which was the behavior in 0.23.x