### Install TFLint on Windows with WinGet Source: https://github.com/terraform-linters/tflint/blob/master/README.md Install TFLint using the WinGet package manager on Windows. ```console winget install -e --id TerraformLinters.tflint ``` -------------------------------- ### Build and Install Plugin Locally Source: https://github.com/terraform-linters/tflint/blob/master/docs/developer-guide/plugins.md These console commands demonstrate how to build a plugin using 'make install', which compiles the plugin and places it in the TFLint plugins directory. It also shows how to verify the installation and check the TFLint version. ```bash $ make install go build mkdir -p ~/.tflint.d/plugins mv ./tflint-ruleset-template ~/.tflint.d/plugins $ tflint -v TFLint version 0.28.1 + ruleset.template (0.1.0) ``` -------------------------------- ### Initialize and Install Plugins Source: https://github.com/terraform-linters/tflint/blob/master/docs/user-guide/plugins.md Run `tflint --init` to automatically install declared plugins. This command fetches release metadata from GitHub, which can be rate-limited. ```console $ tflint --init Installing "foo" plugin... Installed "foo" (source: github.com/org/tflint-ruleset-foo, version: 0.1.0) ``` -------------------------------- ### Install TFLint on Linux Source: https://github.com/terraform-linters/tflint/blob/master/README.md Download the TFLint binary for Linux AMD64, verify its checksum, and install it to the system's PATH. ```console curl -sSLO https://github.com/terraform-linters/tflint/releases/latest/download/tflint_linux_amd64.zip curl -sSLO https://github.com/terraform-linters/tflint/releases/latest/download/checksums.txt gh attestation verify checksums.txt -R terraform-linters/tflint sha256sum --ignore-missing -c checksums.txt unzip tflint_linux_amd64.zip sudo install -c -v tflint /usr/local/bin/ ``` -------------------------------- ### Install Custom TFLint Plugin Source: https://github.com/terraform-linters/tflint/blob/master/README.md Declare a custom plugin in your configuration file to easily install it using the 'tflint --init' command. ```hcl plugin "foo" { enabled = true version = "0.1.0" source = "github.com/org/tflint-ruleset-foo" } ``` -------------------------------- ### JSON Configuration Example Source: https://github.com/terraform-linters/tflint/blob/master/docs/user-guide/config.md The equivalent TFLint configuration in JSON format. This mirrors the HCL example, demonstrating how to set TFLint version, output format, plugin directory, and rule configurations. ```json { "tflint": { "required_version": ">= 0.50" }, "config": { "format": "compact", "plugin_dir": "~/.tflint.d/plugins", "call_module_type": "local", "force": false, "disabled_by_default": false, "ignore_module": { "terraform-aws-modules/vpc/aws": true, "terraform-aws-modules/security-group/aws": true }, "varfile": ["example1.tfvars", "example2.tfvars"], "variables": ["foo=bar", "bar=[\"baz\"]"] }, "plugin": { "aws": { "enabled": true, "version": "0.4.0", "source": "github.com/terraform-linters/tflint-ruleset-aws" } }, "rule": { "aws_instance_invalid_type": { "enabled": false } } } ``` -------------------------------- ### Install TFLint on macOS with Homebrew Source: https://github.com/terraform-linters/tflint/blob/master/README.md Install TFLint using the Homebrew package manager on macOS. ```console brew install terraform-linters/tap/tflint ``` -------------------------------- ### Local Values Example Source: https://github.com/terraform-linters/tflint/blob/master/docs/user-guide/compatibility.md Demonstrates the evaluation of local values, including static, variable, and local references. ```hcl variable "foo" { default = "variable value" } locals { static = "static value" variable = var.foo local = local.static resource = aws_instance.main.arn } local.static # => "static value" local.variable # => "variable value" local.local # => "static value" local.resource # => ignored (unknown) ``` -------------------------------- ### Start TFLint Language Server Source: https://github.com/terraform-linters/tflint/blob/master/docs/user-guide/editor-integration.md Initiate the TFLint language server from the command line. This command enables TFLint to function as a backend for editor integrations. ```console $ tflint --langserver 14:21:51 cli.go:185: Starting language server... ``` -------------------------------- ### HCL Configuration Example Source: https://github.com/terraform-linters/tflint/blob/master/docs/user-guide/config.md An example of TFLint configuration using HCL format. This defines required TFLint version, output format, plugin directory, module call behavior, and specific rule settings. ```hcl tflint { required_version = ">= 0.50" } config { format = "compact" plugin_dir = "~/.tflint.d/plugins" call_module_type = "local" force = false disabled_by_default = false ignore_module = { "terraform-aws-modules/vpc/aws" = true "terraform-aws-modules/security-group/aws" = true } varfile = ["example1.tfvars", "example2.tfvars"] variables = ["foo=bar", "bar=[\"baz\"]"] } plugin "aws" { enabled = true version = "0.4.0" source = "github.com/terraform-linters/tflint-ruleset-aws" } rule "aws_instance_invalid_type" { enabled = false } ``` -------------------------------- ### Example Module Call in HCL Source: https://github.com/terraform-linters/tflint/blob/master/docs/user-guide/calling-modules.md This HCL snippet demonstrates how to define a module call, specifying the source and input variables. ```hcl module "aws_instance" { source = "./module" ami = "ami-b73b63a0" instance_type = "t1.2xlarge" } ``` -------------------------------- ### Manually Install a Plugin Source: https://github.com/terraform-linters/tflint/blob/master/docs/user-guide/plugins.md Use this configuration block to manually install a TFLint plugin. Omit 'source' and 'version' for development or unpublished plugins. ```hcl plugin "foo" { enabled = true } ``` -------------------------------- ### Input Variables Example Source: https://github.com/terraform-linters/tflint/blob/master/docs/user-guide/compatibility.md Demonstrates how TFLint evaluates input variables with a default value. ```hcl variable "instance_type" { default = "t2.micro" } resource "aws_instance" "foo" { instance_type = var.instance_type # => "t2.micro" } ``` -------------------------------- ### Dynamic Block Example Source: https://github.com/terraform-linters/tflint/blob/master/docs/user-guide/compatibility.md Demonstrates the use of a dynamic block for configuring EBS block devices in Terraform. TFLint processes this as-is. ```hcl resource "aws_instance" "dynamic" { dynamic "ebs_block_device" { for_each = toset([ { size = 10 }, { size = 20 } ]) content { volume_size = ebs_block_device.value["size"] # => 10 and 20 } } } ``` -------------------------------- ### TFLint Applying Autofix Source: https://github.com/terraform-linters/tflint/blob/master/docs/user-guide/autofix.md This example demonstrates TFLint's output after applying the --fix option, showing the issue as '[Fixed]'. Autofixing modifies the file to correct the identified problem. ```console $ tflint --fix 1 issue(s) found: Warning: [Fixed] Single line comments should begin with # (terraform_comment_syntax) on main.tf line 1: 1: // locals values 2: locals { ``` -------------------------------- ### TFLint Reporting a Fixable Issue Source: https://github.com/terraform-linters/tflint/blob/master/docs/user-guide/autofix.md This example shows how TFLint identifies a fixable issue, indicated by '[Fixable]' in the output. This issue relates to comment syntax. ```console $ tflint 1 issue(s) found: Warning: [Fixable] Single line comments should begin with # (terraform_comment_syntax) on main.tf line 1: 1: // locals values 2: locals { ``` -------------------------------- ### Recursive Initialization and Version Check Source: https://github.com/terraform-linters/tflint/blob/master/docs/user-guide/working-directory.md The --recursive flag can be combined with other TFLint commands like --init for installing plugins or --version for checking the TFLint version across all modules. ```console $ tflint --recursive --init ``` ```console $ tflint --recursive --version ``` -------------------------------- ### TFLint Output with Module Call Error Source: https://github.com/terraform-linters/tflint/blob/master/docs/user-guide/calling-modules.md This console output shows an example of TFLint reporting an issue found within a module call, including the specific error and its location. ```console $ tflint 1 issue(s) found: Error: instance_type is not a valid value (aws_instance_invalid_type) on template.tf line 5: 5: instance_type = "t1.2xlarge" Callers: template.tf:5,19-31 module/instance.tf:5,19-36 ``` -------------------------------- ### Ignore Specific Modules in Configuration Source: https://github.com/terraform-linters/tflint/blob/master/docs/user-guide/config.md Example of configuring `ignore_module` in HCL to prevent TFLint from analyzing specified module sources, useful for excluding third-party or known modules. ```hcl config { call_module_type = "all" ignore_module = { "terraform-aws-modules/vpc/aws" = true "terraform-aws-modules/security-group/aws" = true } } ``` -------------------------------- ### Initialize Terraform and Run TFLint for Remote Modules Source: https://github.com/terraform-linters/tflint/blob/master/docs/user-guide/calling-modules.md These console commands show the necessary steps to initialize Terraform and then run TFLint to inspect remote modules. ```console $ terraform init $ tflint --call-module-type=all ``` -------------------------------- ### Initialize and Run TFLint with Docker Source: https://github.com/terraform-linters/tflint/blob/master/README.md Run TFLint within a Docker container, initializing plugins and then executing the linter. This overrides the default entrypoint to a shell. ```console docker run --rm -v $(pwd):/data -t --entrypoint /bin/sh ghcr.io/terraform-linters/tflint -c "tflint --init && tflint" ``` -------------------------------- ### Clone and Build TFLint Source: https://github.com/terraform-linters/tflint/blob/master/docs/developer-guide/building.md Clone the TFLint repository and build the binary using Make. The built binary will be available in the 'dist' directory. ```console git clone https://github.com/terraform-linters/tflint.git cd tflint make mkdir -p dist go build -v -o dist/tflint ``` -------------------------------- ### TFLint Help Command Source: https://github.com/terraform-linters/tflint/blob/master/README.md Display the help message for TFLint, showing available options and arguments for usage. ```bash $ tflint --help ``` -------------------------------- ### Inspect Module in Specific Directory Source: https://github.com/terraform-linters/tflint/blob/master/docs/user-guide/working-directory.md Use the --chdir flag to inspect a module located in a different directory than the current one. Configuration files are loaded from the specified directory. ```console $ tflint --chdir=environments/production ``` -------------------------------- ### Run Unit Tests Source: https://github.com/terraform-linters/tflint/blob/master/docs/developer-guide/building.md Execute the unit tests to ensure code changes do not break existing functionality. This command is part of the Make build process. ```console make test ``` -------------------------------- ### Specify Config File with Absolute Path Source: https://github.com/terraform-linters/tflint/blob/master/docs/user-guide/config.md Demonstrates how to use the `--config` flag with an absolute path when running TFLint recursively to ensure the correct configuration file is loaded from the working directory. ```sh tflint --recursive --config "$(pwd)/.tflint.hcl" # or tflint --recursive --config "$(pwd)/.tflint.json" ``` -------------------------------- ### Verify TFLint Version and Loaded Plugins Source: https://github.com/terraform-linters/tflint/blob/master/docs/user-guide/plugins.md Check the TFLint version and confirm that plugins have been loaded correctly. ```console $ tflint -v TFLint version 0.28.1 + ruleset.foo (0.1.0) ``` -------------------------------- ### Run End-to-End (E2E) Tests Source: https://github.com/terraform-linters/tflint/blob/master/docs/developer-guide/building.md Execute the E2E tests to verify the CLI behavior. Ensure the TFLint binary is in your PATH for these tests to run correctly. ```console make e2e ``` -------------------------------- ### Enable All Module Types via CLI Source: https://github.com/terraform-linters/tflint/blob/master/docs/user-guide/config.md Command-line invocation to set the module call type to 'all', overriding configuration file settings. ```console tflint --call-module-type=all ``` -------------------------------- ### Automated Release Command Source: https://github.com/terraform-linters/tflint/blob/master/docs/developer-guide/releasing.md Run this command on the master branch to initiate the automated release process. It accepts a new version as input and handles subsequent steps. ```console $ make release ``` -------------------------------- ### Configure Plugin Authentication for GitHub API Source: https://github.com/terraform-linters/tflint/blob/master/docs/user-guide/plugins.md Use `GITHUB_TOKEN` environment variable for authenticated requests to increase GitHub API rate limits. For GitHub Enterprise Server, use host-specific tokens like `GITHUB_TOKEN_example_com`. ```hcl # GITHUB_TOKEN will be used plugin "foo" { source = "github.com/org/tflint-ruleset-foo" } # GITHUB_TOKEN_example_com will be used preferentially and will fall back to GITHUB_TOKEN if not set. plugin "bar" { source = "example.com/org/tflint-ruleset-bar" } ``` -------------------------------- ### Manually Update Git Submodules Source: https://github.com/terraform-linters/tflint/blob/master/docs/developer-guide/building.md If running Go tests directly (not via 'make test'), you may need to manually initialize and update Git submodules. ```sh git submodule init git submodule update ``` -------------------------------- ### Count Meta-Argument (Multiple) Source: https://github.com/terraform-linters/tflint/blob/master/docs/user-guide/compatibility.md Demonstrates TFLint's support for the 'count' meta-argument to create multiple resources. ```hcl resource "aws_instance" "foo" { count = 2 instance_type = "t${count.index}.micro" # => "t0.micro" and "t1.micro" } ``` -------------------------------- ### Enable Specific Rules with Disabled by Default Source: https://github.com/terraform-linters/tflint/blob/master/docs/user-guide/config.md Configuration snippet showing how to use `disabled_by_default = true` along with explicitly enabling specific rules. This ensures only the listed rules are active. ```hcl config { disabled_by_default = true # other options here... } rule "aws_instance_invalid_type" { enabled = true } rule "aws_instance_previous_type" { enabled = true } ``` -------------------------------- ### Enable Specific Rules via CLI Source: https://github.com/terraform-linters/tflint/blob/master/docs/user-guide/config.md Command-line flags to enable specific rules when `disabled_by_default` is set to true in the configuration. ```console $ tflint --only aws_instance_invalid_type --only aws_instance_previous_type ``` -------------------------------- ### Enable Debug Logging Source: https://github.com/terraform-linters/tflint/blob/master/README.md Run TFLint with the TFLINT_LOG environment variable set to 'debug' to view detailed logs for debugging purposes. ```bash $ TFLINT_LOG=debug tflint ``` -------------------------------- ### Verify TFLint Release with GitHub CLI Source: https://github.com/terraform-linters/tflint/blob/master/README.md Verify the integrity of TFLint release artifacts using GitHub CLI and checksums. ```console gh attestation verify checksums.txt -R terraform-linters/tflint sha256sum --ignore-missing -c checksums.txt ``` -------------------------------- ### Count Meta-Argument (Zero) Source: https://github.com/terraform-linters/tflint/blob/master/docs/user-guide/compatibility.md Shows how TFLint ignores resources when the 'count' meta-argument is zero. ```hcl resource "aws_instance" "foo" { count = 0 instance_type = "invalid" # => ignored because the resource is not created } ``` -------------------------------- ### Verify TFLint Release with Cosign (Deprecated) Source: https://github.com/terraform-linters/tflint/blob/master/README.md Verify TFLint release artifacts using Cosign. Note: Cosign signatures are deprecated. ```console cosign verify-blob --certificate=checksums.txt.pem --signature=checksums.txt.keyless.sig --certificate-identity-regexp="^https://github.com/terraform-linters/tflint" --certificate-oidc-issuer=https://token.actions.githubusercontent.com checksums.txt sha256sum --ignore-missing -c checksums.txt ``` -------------------------------- ### Run TFLint using Docker Source: https://github.com/terraform-linters/tflint/blob/master/README.md Execute TFLint within a Docker container, mounting the current directory for access to Terraform files. ```console docker run --rm -v $(pwd):/data -t ghcr.io/terraform-linters/tflint ``` -------------------------------- ### Module Call with Unknown Source Source: https://github.com/terraform-linters/tflint/blob/master/docs/user-guide/compatibility.md Illustrates a module call where the source is an unknown variable. TFLint will ignore this module. ```hcl variable "module_path" { const = true } module "aws_instance" { source = var.module_path encrypted = false # => ignored } ``` -------------------------------- ### Run TFLint to Ignore All Module Calls Source: https://github.com/terraform-linters/tflint/blob/master/docs/user-guide/calling-modules.md This console command demonstrates how to run TFLint while explicitly ignoring all module calls by setting '--call-module-type=none'. ```console $ tflint --call-module-type=none ``` -------------------------------- ### Unknown Count Meta-Argument Source: https://github.com/terraform-linters/tflint/blob/master/docs/user-guide/compatibility.md Illustrates that TFLint ignores resources when the 'count' meta-argument is unknown. ```hcl variable "count" {} resource "aws_instance" "foo" { count = var.count instance_type = "invalid" # => ignored } ``` -------------------------------- ### Enable Terraform Language Plugin Source: https://github.com/terraform-linters/tflint/blob/master/README.md Declare the Terraform plugin in your .tflint.hcl configuration file to enable rules for Terraform language. ```hcl plugin "terraform" { enabled = true preset = "recommended" } ``` -------------------------------- ### Module Call with Attribute Source: https://github.com/terraform-linters/tflint/blob/master/docs/user-guide/compatibility.md Shows a module call where an attribute is passed, and TFLint analyzes its content to raise issues. Also includes a direct resource configuration for comparison. ```hcl resource "aws_instance" "static" { ebs_block_device { encrypted = false # => Must be encrypted } } module "aws_instance" { source = "./module/aws_instance" encrypted = false # => Must be encrypted } ``` -------------------------------- ### Enable a TFLint Rule Source: https://github.com/terraform-linters/tflint/blob/master/docs/user-guide/config.md Configure TFLint rules using `rule` blocks in the configuration file. Set `enabled = true` to explicitly enable a rule that might be disabled by default. ```hcl rule "terraform_unused_declarations" { enabled = true } ``` -------------------------------- ### Enable a Plugin in TFLint Configuration Source: https://github.com/terraform-linters/tflint/blob/master/docs/developer-guide/plugins.md This HCL snippet shows how to enable a plugin named 'template' in your TFLint configuration file. ```hcl plugin "template" { enabled = true } ``` -------------------------------- ### Set Terraform Variables from CLI Source: https://github.com/terraform-linters/tflint/blob/master/docs/user-guide/config.md Use the `--var-file` CLI flag to specify tfvars files. This flag can be used multiple times to include several files. ```console $ tflint --var-file example1.tfvars --var-file example2.tfvars ``` -------------------------------- ### Enable Recursive Module Inspection Source: https://github.com/terraform-linters/tflint/blob/master/docs/user-guide/working-directory.md Use the --recursive flag to enable inspection of all modules within subdirectories. This performs inspection in parallel by default. ```console $ tflint --recursive ``` -------------------------------- ### Unknown Input Variables Source: https://github.com/terraform-linters/tflint/blob/master/docs/user-guide/compatibility.md Shows how TFLint ignores unknown input variables. ```hcl variable "instance_type" {} resource "aws_instance" "foo" { instance_type = var.instance_type # => ignored } ``` -------------------------------- ### Set Terraform Variables from CLI Values Source: https://github.com/terraform-linters/tflint/blob/master/docs/user-guide/config.md Use the `--var` CLI flag to set individual Terraform variables. This flag can be repeated to set multiple variables. ```console $ tflint --var "foo=bar" --var "bar=[\"baz\"]" ``` -------------------------------- ### Set Terraform Variables from tfvars Files Source: https://github.com/terraform-linters/tflint/blob/master/docs/user-guide/config.md Use the `varfile` configuration to specify multiple tfvars files for setting Terraform variables. TFLint automatically loads `terraform.tfvars` and `*.auto.tfvars` if present. ```hcl config { varfile = ["example1.tfvars", "example2.tfvars"] } ``` -------------------------------- ### Ignore Specific Modules via CLI Source: https://github.com/terraform-linters/tflint/blob/master/docs/user-guide/config.md Command-line flags to specify modules that TFLint should ignore during analysis. ```console $ tflint --ignore-module terraform-aws-modules/vpc/aws --ignore-module terraform-aws-modules/security-group/aws ``` -------------------------------- ### Set Terraform Variables from Values Source: https://github.com/terraform-linters/tflint/blob/master/docs/user-guide/config.md Use the `variables` configuration to set Terraform variables directly with values. This can be done for multiple variables, with values supporting array formats. ```hcl config { variables = ["foo=bar", "bar=[\"baz\"]"] } ``` -------------------------------- ### Configure TFLint to Call All Modules Source: https://github.com/terraform-linters/tflint/blob/master/docs/user-guide/calling-modules.md This HCL configuration block sets the 'call_module_type' to 'all' within TFLint's configuration, enabling inspection of all modules. ```hcl config { call_module_type = "all" } ``` -------------------------------- ### Add Reason for Suppression in HCL Source: https://github.com/terraform-linters/tflint/blob/master/docs/user-guide/annotations.md It is recommended to add a comment explaining the reason for suppressing a rule, especially for temporary suppressions. This improves code maintainability and understanding. ```hcl resource "aws_instance" "foo" { # This instance type is new and TFLint doesn't know about it yet # tflint-ignore: aws_instance_invalid_type instance_type = "t10.2xlarge" } ``` ```hcl resource "aws_instance" "foo" { # tflint-ignore: aws_instance_invalid_type # too new for TFLint instance_type = "t10.2xlarge" } ``` -------------------------------- ### Ignore Inspection for a Specific Module Source: https://github.com/terraform-linters/tflint/blob/master/docs/user-guide/calling-modules.md This console command shows how to use the '--ignore-module' flag with TFLint to exclude a particular module from inspection. ```console $ tflint --ignore-module=./module ``` -------------------------------- ### Configure Specific Version of Bundled Terraform Plugin Source: https://github.com/terraform-linters/tflint/blob/master/docs/user-guide/plugins.md Explicitly declare a plugin block to use a specific version of the bundled Terraform ruleset. This overrides the default bundled version. ```hcl plugin "terraform" { enabled = true preset = "recommended" version = "0.1.0" source = "github.com/terraform-linters/tflint-ruleset-terraform" } ``` -------------------------------- ### Invalid Placement of `tflint-ignore-file` in HCL Source: https://github.com/terraform-linters/tflint/blob/master/docs/user-guide/annotations.md The `tflint-ignore-file` annotation must be placed at the very top of an HCL file. Placing it elsewhere, such as within a resource block or on the same line as resource definition, will result in an error. ```hcl resource "aws_instance" "foo" { # tflint-ignore-file: aws_instance_invalid_type instance_type = "t1.2xlarge" } ``` ```hcl resource "aws_instance" "foo" { instance_type = "t1.2xlarge" } ``` -------------------------------- ### Using `//` Comment Style for Suppression in HCL Source: https://github.com/terraform-linters/tflint/blob/master/docs/user-guide/annotations.md TFLint supports the `//` comment style for annotations in HCL, although Terraform officially recommends using `#`. Ensure the annotation is correctly placed for it to be effective. ```hcl resource "aws_instance" "foo" { // tflint-ignore: aws_instance_invalid_type // too new for TFLint instance_type = "t10.2xlarge" } ``` -------------------------------- ### Add Reason for JSON File Suppression Source: https://github.com/terraform-linters/tflint/blob/master/docs/user-guide/annotations.md You can append arbitrary comments after the `tflint-ignore-file` annotation in JSON. The annotation itself must remain the first part of the comment string. ```json { "//": "tflint-ignore-file: aws_instance_invalid_type # This instance type is new and TFLint doesn't know about it yet", "resource": { "aws_instance": { "foo": { "instance_type": "t2.micro" } } } } ``` -------------------------------- ### Sensitive Input Variables Source: https://github.com/terraform-linters/tflint/blob/master/docs/user-guide/compatibility.md Illustrates that TFLint ignores sensitive input variables to prevent disclosure. ```hcl variable "instance_type" { sensitive = true default = "t2.micro" } resource "aws_instance" "foo" { instance_type = var.instance_type # => ignored } ``` -------------------------------- ### Suppress Multiple Rules in JSON File Source: https://github.com/terraform-linters/tflint/blob/master/docs/user-guide/annotations.md Similar to HCL, you can suppress multiple rules in a JSON file by listing them as a comma-separated string within the `tflint-ignore-file` annotation. ```json { "//": "tflint-ignore-file: aws_instance_invalid_type, other_rule", "resource": { "aws_instance": { "foo": { "instance_type": "t2.micro" } } } } ``` -------------------------------- ### Suppress All Rules in HCL Source: https://github.com/terraform-linters/tflint/blob/master/docs/user-guide/annotations.md Use `tflint-ignore: all` to suppress all TFLint rules for a specific line in HCL. This should be used cautiously and typically for temporary workarounds. ```hcl resource "aws_instance" "foo" { # tflint-ignore: all instance_type = "t1.2xlarge" } ``` -------------------------------- ### Disable a TFLint Rule Source: https://github.com/terraform-linters/tflint/blob/master/docs/user-guide/config.md Use `rule` blocks to disable rules that are enabled by default. Set `enabled = false` to turn off the rule's enforcement. ```hcl rule "aws_instance_previous_type" { enabled = false } ``` -------------------------------- ### Suppress Entire File in JSON Source: https://github.com/terraform-linters/tflint/blob/master/docs/user-guide/annotations.md In Terraform JSON configurations, use a top-level comment property `"//": "tflint-ignore-file: "` to suppress an entire file. This annotation must be the first element within the comment property string. ```json { "//": "tflint-ignore-file: aws_instance_invalid_type", "resource": { "aws_instance": { "foo": { "instance_type": "t2.micro" } } } } ``` -------------------------------- ### Suppress Entire File in HCL Source: https://github.com/terraform-linters/tflint/blob/master/docs/user-guide/annotations.md Use the `tflint-ignore-file` annotation at the top of an HCL file to disable all TFLint checks for that entire file. This is useful for files that are auto-generated or intentionally deviate from standard linting rules. ```hcl # tflint-ignore-file: aws_instance_invalid_type resource "aws_instance" "foo" { instance_type = "t1.2xlarge" } ``` -------------------------------- ### Suppress Multiple Rules in HCL Source: https://github.com/terraform-linters/tflint/blob/master/docs/user-guide/annotations.md To suppress multiple rules on a single line in HCL, provide them as a comma-separated list after the `tflint-ignore` annotation. This helps in managing several known issues efficiently. ```hcl resource "aws_instance" "foo" { # tflint-ignore: aws_instance_invalid_type, other_rule instance_type = "t1.2xlarge" } ``` -------------------------------- ### Suppress Single Rule in HCL Source: https://github.com/terraform-linters/tflint/blob/master/docs/user-guide/annotations.md Use the `tflint-ignore` annotation to suppress a specific rule on a particular line in HCL files. This is useful when a rule flags an issue that is intentionally configured or not yet recognized by TFLint. ```hcl resource "aws_instance" "foo" { # tflint-ignore: aws_instance_invalid_type instance_type = "t1.2xlarge" } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.