-
Notifications
You must be signed in to change notification settings - Fork 357
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
Failed to check aws_kms_key_invalid_policy
rule: oversize unknown value refinement
#1791
Comments
Please go ahead and re-format this to use the form properly, removing the duplicate config and version info from the summary and moving the logs into the output block. Single backticks are for inline code and it's very difficult to read without proper 3 backtick blocks. |
Also, we need to be able to reproduce this issue, which means you need to further isolate your configuration so that it's actually runnable. If your template file isn't relevant to reproducing the issue, exclude it. If it is, we need some version of the template as well. |
I reformatted the issue and did some more research. This code is running fine: resource "aws_kms_key" "tf-kms-key-alerting" {
description = "KMS key for encrypting alerting data via SNS"
deletion_window_in_days = 7
key_usage = "ENCRYPT_DECRYPT"
customer_master_key_spec = "SYMMETRIC_DEFAULT"
enable_key_rotation = true
policy = templatefile(
"kms-policy.json.tmpl",
{
K8SACCOUNTID = "012345678901"
HUIDIGACCOUNTID = "012345678902"
}
)
} As soon as I use the data.aws_iam_account_alias.current.aws_iam_account_alias statement, it fails data "aws_iam_account_alias" "current" {}
resource "aws_kms_key" "tf-kms-key-alerting" {
description = "KMS key for encrypting alerting data via SNS"
deletion_window_in_days = 7
key_usage = "ENCRYPT_DECRYPT"
customer_master_key_spec = "SYMMETRIC_DEFAULT"
enable_key_rotation = true
policy = templatefile(
"kms-policy.json.tmpl",
{
K8SACCOUNTID = "012345678901"
HUIDIGACCOUNTID = data.aws_iam_account_alias.current.aws_iam_account_alias
}
)
}
|
Thank you for reporting this. This error may have occurred here. HCL v2.17.0, which is used in TFLint v0.47, introduces the concept of value refinements. However, refinements larger than 1kiB seem to have serialization issues when communicating with plugins. There are several possible workarounds, but perhaps the simplest is to remove all refinements on serialization. Fortunately, I think there are no plugins yet that rely on unknown value refinements. |
This issue has been fixed in the upstream, but for several reasons it is not included in TFLint. See hashicorp/hcl#617 (comment) for details. The current workaround is to disable the rule that raises the error. This problem does not occur if no expression evaluation occurs. Fortunately, this problem shouldn't occur unless you're evaluating huge template files (e.g. JSON) with unknown values at the end. If there are other situations where this problem occurs, please comment on this issue. If the impact of this issue is significant, temporarily removing the refinements can mitigate the impact of the issue. See hashicorp/hcl#616 (comment) |
Summary
After upgrading tflint from 0.46.1 to 0.47.0, we get an "Failed to check
aws_kms_key_invalid_policy
rule: oversize unknown value refinement" based on the code below:Command
tflint
Terraform Configuration
TFLint Configuration
Output
Failed to check `aws_kms_key_invalid_policy` rule: oversize unknown value refinement
The trace logs looks like:
TFLint Version
Terraform Version
Operating System
The text was updated successfully, but these errors were encountered: