gruntwork-io / terragrunt

Terragrunt is a flexible orchestration tool that allows Infrastructure as Code written in OpenTofu/Terraform to scale.
https://terragrunt.gruntwork.io/
MIT License
8.07k stars 981 forks source link

tflint-ruleset-azurerm: Failed to initialize plugins #2440

Closed samba2 closed 1 year ago

samba2 commented 1 year ago

When running the tflint hook with terragrunt, I receive the following error:

Failed to initialize plugins; Unrecognized remote plugin message: Incorrect Usage. flag provided but not defined: -act-as-bundled-plugin
This usually means
  the plugin was not compiled for this architecture,
  the plugin is missing dynamic-link libraries necessary to run,
  the plugin is not executable by this process due to file permissions, or
  the plugin failed to negotiate the initial go-plugin protocol handshake

Additional notes about plugin:
  Path: /home/linuxbrew/.linuxbrew/Cellar/terragrunt/0.43.2/bin/terragrunt
  Mode: -r-xr-xr-x
  Owner: 1000 [samba] (current: 1000 [samba])
  Group: 1000 [samba] (current: 1000 [samba])
  ELF architecture: EM_X86_64 (current architecture: amd64)
...
        * Error while running tflint with args: [tflint --init --config /home/***/azure/.tflint.hcl /home/***/.terragrunt-cache/GUnzcwgY_Z12Iod7V0cXm90Mr3Q/V9u4X1WhUCaqO6kHtHpod5iHxOc/rg]

I am aware of the troubleshooting notice in the docs, but I believe I've set things up correctly.

Here is my .tflint.hcl:

plugin "azurerm" {
  enabled = true
  version = "0.20.0"
  source  = "github.com/terraform-linters/tflint-ruleset-azurerm"
}

When I run tflint --init --config /home/***/azure/.tflint.hcl /home/***/.terragrunt cache/GUnzcwgY_Z12Iod7V0cXm90Mr3Q/V9u4X1WhUCaqO6kHtHpod5iHxOc/rg directly, things work.

Versions:

denis256 commented 1 year ago

Hi, tried to define the terraform plugin in .tflint.hcl?

plugin "terraform" {
  enabled = true
  preset  = "recommended"

  version = "0.1.0"
  source  = "github.com/terraform-linters/tflint-ruleset-terraform"
}

Reference: https://github.com/gruntwork-io/terragrunt/pull/2362#issuecomment-1319753875

samba2 commented 1 year ago

@denis256 Good that you mention that. Yes, I also tried this and it worked. So the issue seems to be related with terragrunt + tflint + the azure rules plugin.

samba2 commented 1 year ago

I had some time looking into that issue. I admit that I was confused by which plugins are actually needed although it was always mentioned, but as a terragrunt/ tflint beginner I did not bring together the puzzle pieces.

This made terragrunt v0.45.0 working with the tflint hook:

# explicit "terraform" plugin with version + source
plugin "terraform" {
    enabled = true
    version = "0.2.2"
    source  = "github.com/terraform-linters/tflint-ruleset-terraform"
}

# ...and the "azurerm" plugin
plugin "azurerm" {
    enabled = true
    version = "0.22.0"
    source  = "github.com/terraform-linters/tflint-ruleset-azurerm"
}

# rules follow here
...

Sorry for the confusion caused. I'll close the issue.