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] terraform output query for "initializing the backend" hidden since v0.68.0 #3840

Open
msiebeneicher opened this issue Feb 5, 2025 · 2 comments
Labels
bug Something isn't working

Comments

@msiebeneicher
Copy link

Describe the bug

In our setup, we first create an S3 state bucket for the Terraform remote states without a remote state configuration. We then import the state file later using Terraform's autodetection with a valid remote state configuration:

15:57:01.091 STDOUT terraform: Initializing the backend...
15:57:02.874 STDOUT terraform: Do you want to copy existing state to the new backend?
15:57:02.874 STDOUT terraform: Pre-existing state was found while migrating the previous "local" backend to the
15:57:02.874 STDOUT terraform: newly configured "s3" backend. No existing state was found in the newly
15:57:02.874 STDOUT terraform: configured "s3" backend. Do you want to copy this state to the new "s3"
15:57:02.874 STDOUT terraform: backend? Enter "yes" to copy and "no" to start with an empty state.
15:57:02.874 STDOUT terraform: Enter a value:

This way works totally fine with all terragrunt versions <= v0.67.16.

With v0.68.0 (inclusive the latest version) we have the problem that we don't get the output during the apply process.
The output will be displayed after you abort the process (cmd+c on cli):

6:03:16.342 INFO Caching terraform providers for ./.terragrunt-cache/kVCRK66[...]
16:03:24.691 INFO Interrupt signal received. Gracefully shutting down...
16:03:24.691 INFO Shutting down Terragrunt Cache server...
16:03:24.691 INFO Terragrunt Cache server stopped
16:03:16.388 INFO terraform: Initializing the backend...
16:03:18.121 INFO terraform: Do you want to copy existing state to the new backend?
16:03:18.121 INFO terraform: Pre-existing state was found while migrating the previous "local" backend to the
16:03:18.121 INFO terraform: newly configured "s3" backend. No existing state was found in the newly
16:03:18.121 INFO terraform: configured "s3" backend. Do you want to copy this state to the new "s3"
16:03:18.121 INFO terraform: backend? Enter "yes" to copy and "no" to start with an empty state.
16:03:18.121 INFO terraform: Enter a value:
16:03:24.882 INFO terraform: Initializing modules...
16:03:24.903 ERROR terraform: Module installation was canceled by an interrupt signal.

This breaks our current account spin up process and forces us to create the remote state first with v0.67.16 before we are able to update and use the final version in our project.

Steps To Reproduce

generate "provider" {
  path      = "provider.tf"
  if_exists = "overwrite_terragrunt"
  contents  = <<EOF
provider "aws" {
  region = "${local.aws_region}"
  # Only these AWS Account IDs may be operated on by this template
  allowed_account_ids = ["${local.account_id}"]
}
EOF
}

remote_state {
  backend = "s3"
  config = {
    disable_bucket_update = true
    encrypt               = true
    bucket                = "terraform-state"
    key                   = "${path_relative_to_include()}/terraform.tfstate"
    region                = local.aws_backend_region
    # [...]
  }
  generate = {
    path      = "backend.tf"
    if_exists = "overwrite_terragrunt"
  }
}

Expected behavior

Getting the output of the backendMigrateEmptyConfirm tf function in the same way like the apply confirm message.

Versions

  • Terragrunt version: v0.72.6
  • OpenTofu/Terraform version: v1.5.7
  • Environment details: mac OS 14.7.3
@msiebeneicher msiebeneicher added the bug Something isn't working label Feb 5, 2025
@yhakbar
Copy link
Collaborator

yhakbar commented Feb 7, 2025

Let me know if I've failed to reproduce your issue wrong:

Image

It seems to work for me.

@msiebeneicher
Copy link
Author

msiebeneicher commented Feb 10, 2025

Hi @yhakbar,

thx for taking care of the issue and for the try here!

I don't see something wrong during your steps. 🤔 Can you maybe try the same with terraform v1.5.7 - just to check the combination here. How described in the issue: With terragrunt <= v0.67.16 it also works fine on our environment.

I see in your try that opentofu also send the question to stdout like "15:57:02.874 STDOUT terraform: Do you want to copy existing state to the new backend?". In our issue case terraform send the output to "info" with version >= v0.68.0like "16:03:18.121 INFO terraform: Do you want to copy existing state to the new backend?"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants