terraform-linters / tflint

A Pluggable Terraform Linter
Mozilla Public License 2.0
4.98k stars 357 forks source link

tflint does not recognise `removed` blocks #1994

Closed jamiekt closed 9 months ago

jamiekt commented 9 months ago

Summary

We run super-linter (ghcr.io/super-linter/super-linter:v5) to lint our terraform code. We turn on tflint by setting env var

jobs:
    run-lint:
        env:
            VALIDATE_TERRAFORM_TFLINT: true

Unfortunately its failing right now:

2024-02-27 15:43:52 [INFO]   Linting [TERRAFORM_TFLINT] files...
2024-02-27 15:43:52 [INFO]   ----------------------------------------------
2024-02-27 15:43:52 [INFO]   ----------------------------------------------
2024-02-27 15:43:52 [INFO]   ---------------------------
2024-02-27 15:43:52 [INFO]   File:[/github/workspace/path/to/file.tf]
╷
│ Error: Unsupported block type
│ 
│   on file.tf line 1:
│    1: removed {
│ 
│ Blocks of type "removed" are not expected here. Did you mean "moved"?
╵

removed blocks were added in terraform 1.7 (https://www.hashicorp.com/blog/terraform-1-7-adds-test-mocking-and-config-driven-remove). It would be great if tflint supported linting of files that contain removed blocks.

In the meantime, is it possible to ignore this error? We've tried:

# tflint-ignore: unsupported_block_type

but doing so is not having the desired effect

Command

Unknown, its wrapped up in super-linter

Terraform Configuration

removed {
  from = snowflake_schema_grant.staging_ownership
  # The lifecycle block instructs Terraform not to destroy the underlying resource
  lifecycle {
    destroy = false
  }
}

TFLint Configuration

// https://github.com/terraform-linters/tflint/blob/master/docs/user-guide/config.md
config {
  module = false
  force = false
}

plugin "aws" {
  enabled = true
}

// disable pinned resource rule because we need to use master version of "github.com/org/tf-hf-rds"
rule "terraform_module_pinned_source" {
  enabled = false
}

Output

╷
│ Error: Unsupported block type
│ 
│   on file.tf line 16:
│   16: removed {
│ 
│ Blocks of type "removed" are not expected here. Did you mean "moved"?
╵

TFLint Version

v0.48.0.0 (I think, that's what I'm assuming from this line: https://github.com/super-linter/super-linter/blob/a8150b40c89574adb5f68bf9502b890a236a06b3/Dockerfile#L15)

Terraform Version

1.7

Operating System