Terraform 1.7.1 AWS Init Regression

Ever since we upgraded to terraform 1.7.1, we started seeing this error:

Initializing the backend...
╷
│ Error: failed to get shared config profile, ***********
│ 
│ 
╵

╷
│ Error: Backend initialization required, please run "terraform init"
│ 
│ Reason: Initial configuration of the requested backend "s3"
│ 
│ The "backend" is the interface that Terraform uses to store state,
│ perform operations, etc. If this message is showing up, it means that the
│ Terraform configuration you're using is using a custom configuration for
│ the Terraform backend.
│ 
│ Changes to backend configurations require reinitialization. This allows
│ Terraform to set up the new configuration, copy existing state, etc. Please
│ run
│ "terraform init" with either the "-reconfigure" or "-migrate-state" flags
│ to
│ use the current configuration.
│ 
│ If the change reason above is incorrect, please verify your configuration
│ hasn't changed and try again. At this point, no changes to your existing
│ configuration or state have been made.

This does not happen in terraform 1.6.5. We use the AWS provider 5.35.0+, and our backend is S3:

terraform {
  backend "s3" {
    encrypt = true
  }
  required_version = "= 1.6.5"
  required_providers {
    aws = {
      source  = "hashicorp/aws"
      version = "~> 5.35.0"
    }
  }
}

This looks like a regression in 1.7.1 and 1.7.2.

I got same error with terraform 1.7.3.

I got this error when I

  • declare profile option in s3 backend configuration
  • configure AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY and AWS_SESSION_TOKEN
  • don’t declare profile in config file
 Error: Backend configuration changed
│ 
│ A change in the backend configuration has been detected, which may require migrating existing state.
│ 
│ If you wish to attempt automatic migration of the state, use "terraform init -migrate-state".
│ If you wish to store the current configuration with no changes to the state, use "terraform init -reconfigure".

So we have to provide profile or get rid of profile option in s3 backend statement.

use_legacy_workflow option default value has changed to false in 1.7.0. So set this value true and you can avoid error.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.