Skip to content
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

[bug] Does not work when working with terragrunt & dynamic backend config #167

Open
SunsetYe66 opened this issue Jan 24, 2024 · 0 comments

Comments

@SunsetYe66
Copy link

Hi folks,

I tested tfmigrate under our IaC code and found this error:

failed to switch backend to local: failed to run command (exited 1): terragrunt init -input=false -no-color -reconfigure
stdout:

Initializing the backend...
Initializing modules...

stderr:

Error: Invalid backend configuration argument

The backend configuration argument "key" given on the command line is not
expected for the selected backend type.


Error: Invalid backend configuration argument

The backend configuration argument "bucket" given on the command line is not
expected for the selected backend type.


Error: Invalid backend configuration argument

The backend configuration argument "region" given on the command line is not
expected for the selected backend type.

I use TFMIGRATE_EXEC_PATH=terragrunt as mentioned in #34 . And our terragrunt code defines how the backend is set.

terraform {
  extra_arguments "common_vars" {
    commands = get_terraform_commands_that_need_vars()

    arguments = [
      "-input=false",
    ] 
  }
  extra_arguments "init_args" {
    commands = [
      "init",
    ]

    arguments = [
      "-backend-config=key=${path_relative_to_include()}/terraform.tfstate",        
      "-backend-config=bucket=${get_env("ACCOUNT_ID")}-infra",
      "-backend-config=region=${get_env("REGION")}",
    ]
  }
}

Don't know if there're possible solutions or workarounds towards this. Many thanks if you guys can shed some light on this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant