Seeing "The filename or extension is too long" when "terragrunt plan" is executed in Windows

Viewed 2033

Executing "terragrunt plan" from Visual Studio code gives the below error in Windows 10:

Running command: terraform init -backend-config=region=eu-west-2 -backend-config=bucket=bucket-name" -backend-config=dynamodb_table=lock-table -backend-config=encrypt=true -backend-config=key=ec2/terraform.tfstate

Initializing the backend...

Successfully configured the backend "s3"! Terraform will automatically use this backend unless the backend configuration changes.

Initializing provider plugins...

  • Finding hashicorp/aws versions matching "~> 3.36.0"...
  • Installing hashicorp/aws v3.36.0...

Error: Failed to install provider

Error while installing hashicorp/aws v3.36.0: mkdir .terraform/plugins/registry.terraform.io/hashicorp/aws/3.36.0/windows_amd64: The filename or extension is too long.

[terragrunt] 2021/05/19 15:39:20 Hit multiple errors: exit status 1

3 Answers

Thanks Rubens for suggesting using TERRAGRUNT_DOWNLOAD environment variable. I'm able to work around this problem. Here are the complete steps in terragrunt:

  1. from cmd, set TERRAGRUNT_DOWNLOAD and call init:

set TERRAGRUNT_DOWNLOAD=C:\.terragrunt-cache

terragrunt init

  1. Then copy or move C:\.terragrunt-cache content to the .terragrunt-cache in my project (better clean up the folder first)

  2. from cmd, unset TERRAGRUNT_DOWNLOAD and call apply

set TERRAGRUNT_DOWNLOAD=

terragrunt apply

I had faced similar issue on terraform init. I installed latest version of terraform and it got resolved.

Related