Terraform Version
Terraform v0.13.0.
Terraform Configuration Files
terraform {
required_providers {
aws = {
version = “~> 4.65.0”
}
}
}
Debug Output
Initializing provider plugins…
-
Finding hashicorp/template versions matching “>= 2.1.0, >= 2.1.0, >= 2.1.0, >= 2.1.0, >= 2.1.0, >= 2.1.0, >= 2.1.0, >= 2.1.0, >= 2.1.0, >= 2.1.0, >= 2.1.0, >= 2.1.0, >= 2.1.0, >= 2.1.0, >= 2.1.0”…
-
Finding hashicorp/random versions matching “>= 2.2.1, >= 2.2.1, >= 2.2.1, >= 2.2.1, >= 2.2.1, >= 2.2.1, >= 2.2.1, >= 2.2.1, >= 2.2.1, >= 2.2.1, >= 2.2.1, >= 2.2.1, >= 2.2.1, >= 2.2.1, >= 2.2.1”…
-
Finding hashicorp/aws versions matching “~> 4.65.0, ~> 5.0, >= 2.47.0, >= 2.47.0, >= 2.47.0, ~> 5.0, >= 2.47.0, >= 2.47.0, >= 2.47.0, ~> 5.0, ~> 5.0, >= 2.47.0, >= 2.47.0, ~> 5.0, ~> 5.0, ~> 5.0, ~> 5.0, >= 2.47.0, >= 2.47.0, ~> 5.0, ~> 5.0, >= 2.47.0, ~> 5.0, >= 2.47.0, >= 2.47.0, ~> 5.0, ~> 5.0, >= 2.47.0, >= 2.47.0”…
-
Installing hashicorp/template v2.2.0…
-
Installed hashicorp/template v2.2.0 (self-signed, key ID 34365D9472D7468F)
-
Installing hashicorp/random v3.7.2…
-
Installed hashicorp/random v3.7.2 (self-signed, key ID 34365D9472D7468F)
Partner and community providers are signed by their developers.
If you’d like to know more about provider signing, you can read about it here:
https://www.terraform.io/docs/plugins/signing.html
Error: Failed to query available provider packages
Could not retrieve the list of available versions for provider hashicorp/aws:
no available releases match the given constraints ~> 4.65.0, ~> 5.0, >=
2.47.0, >= 2.47.0, >= 2.47.0, ~> 5.0, >= 2.47.0, >= 2.47.0, >= 2.47.0, ~> 5.0,
~> 5.0, >= 2.47.0, >= 2.47.0, ~> 5.0, ~> 5.0, ~> 5.0, ~> 5.0, >= 2.47.0, >=
2.47.0, ~> 5.0, ~> 5.0, >= 2.47.0, ~> 5.0, >= 2.47.0, >= 2.47.0, ~> 5.0, ~>
5.0, >= 2.47.0, >= 2.47.0
Cleaning up file based variables
00:01
ERROR: Job failed: exit status 1
Expected Behavior
Error: Invalid resource instance data in state
on .terraform/modules/vpc_vas/vpc/main.tf line 3:
3: resource “aws_vpc” “vpc_vc01” {
Instance module.vpc_vas.aws_vpc.vpc_vc01 data could not be decoded from the
state: unsupported attribute “enable_classiclink”.
Cleaning up file based variables
00:00
ERROR: Job failed: exit status 1
Actual Behavior
Error: Invalid resource instance data in state
on .terraform/modules/vpc_vas/vpc/main.tf line 3:
3: resource “aws_vpc” “vpc_vc01” {
Instance module.vpc_vas.aws_vpc.vpc_vc01 data could not be decoded from the
state: unsupported attribute “enable_classiclink”.
Cleaning up file based variables
00:00
ERROR: Job failed: exit status 1
Steps to Reproduce
Removed .terraform and .terraform.lock.hcl
Ran terraform init -upgrade
Removed resources from the state
Re-imported the resources
Additional Context
Hello Team,
I am using Terraform v0.13.0 for my project and encountered the following issue during initialization.
Error during terraform init:
Initializing provider plugins…
Terraform failed to retrieve the list of available versions for provider hashicorp/aws due to conflicting version constraints:
-
~> 4.65.0 -
~> 5.0 -
>= 2.47.0
As a result, Terraform could not find a single AWS provider version that satisfies all constraints, and the job failed.
Initially, my AWS provider configuration was:
terraform {
required_providers {
aws = {
version = "~> 4.65.0"
}
}
}
Later, I upgraded the AWS provider to:
terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = ">= 5.0"
}
}
}
After upgrading, I encountered the following error:
Error: Invalid resource instance data in state
unsupported attribute "enable_classiclink"
To resolve this, I performed the following workaround:
-
Removed
.terraformand.terraform.lock.hcl -
Ran
terraform init -upgrade -
Removed resources from the state
-
Re-imported the resources
After this workaround, terraform plan shows that Terraform wants to destroy and recreate almost all resources:
Plan: 330 to add, 29 to change, 329 to destroy
I do not understand why Terraform is attempting to recreate all resources after the provider upgrade.
Please help me understand the root cause and advise on the correct way to resolve this issue without recreating the entire infrastructure.