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

terraform import is broken after upgrading to 1.10.2, but terraform apply works fine #36225

Open
KieranP opened this issue Dec 17, 2024 · 3 comments
Labels
backend/remote bug cloud Related to Terraform Cloud's integration with Terraform new new issue not yet triaged

Comments

@KieranP
Copy link

KieranP commented Dec 17, 2024

Terraform Version

Terraform v1.10.2
on darwin_arm64
+ provider registry.terraform.io/cloudflare/cloudflare v4.48.0
+ provider registry.terraform.io/datadog/datadog v3.49.0
+ provider registry.terraform.io/hashicorp/aws v5.81.0
+ provider registry.terraform.io/hashicorp/http v3.4.5
+ provider registry.terraform.io/integrations/github v6.4.0
+ provider registry.terraform.io/mongodb/mongodbatlas v1.22.0

Terraform Configuration Files

I have 100s of files and 1000s of resources, but the issue isn't with one in particular. Running terraform apply works fine. Something is broken in the terraform import command.

Debug Output

2024-12-17T17:28:19.774+1300 [INFO]  Terraform version: 1.10.2
2024-12-17T17:28:19.774+1300 [DEBUG] using github.com/hashicorp/go-tfe v1.70.0
2024-12-17T17:28:19.774+1300 [DEBUG] using github.com/hashicorp/hcl/v2 v2.23.0
2024-12-17T17:28:19.774+1300 [DEBUG] using github.com/hashicorp/terraform-svchost v0.1.1
2024-12-17T17:28:19.774+1300 [DEBUG] using github.com/zclconf/go-cty v1.15.1-0.20241111215639-63279be090d7
2024-12-17T17:28:19.774+1300 [INFO]  Go runtime version: go1.23.3
2024-12-17T17:28:19.774+1300 [INFO]  CLI args: []string{"terraform", "import", "module.devops.aws_s3_bucket.REDACTED", "REDACTED"}
2024-12-17T17:28:19.774+1300 [TRACE] Stdout is a terminal of width 235
2024-12-17T17:28:19.774+1300 [TRACE] Stderr is a terminal of width 235
2024-12-17T17:28:19.774+1300 [TRACE] Stdin is a terminal
2024-12-17T17:28:19.774+1300 [DEBUG] Attempting to open CLI config file: /Users/kieran/.terraformrc
2024-12-17T17:28:19.775+1300 [DEBUG] File doesn't exist, but doesn't need to. Ignoring.
2024-12-17T17:28:19.775+1300 [INFO]  Loading CLI configuration from /Users/kieran/.terraform.d/credentials.tfrc.json
2024-12-17T17:28:19.775+1300 [DEBUG] ignoring non-existing provider search directory terraform.d/plugins
2024-12-17T17:28:19.775+1300 [DEBUG] ignoring non-existing provider search directory /Users/kieran/.terraform.d/plugins
2024-12-17T17:28:19.775+1300 [DEBUG] ignoring non-existing provider search directory /Users/kieran/Library/Application Support/io.terraform/plugins
2024-12-17T17:28:19.775+1300 [DEBUG] ignoring non-existing provider search directory /Library/Application Support/io.terraform/plugins
2024-12-17T17:28:19.775+1300 [INFO]  CLI command args: []string{"import", "module.devops.aws_s3_bucket.REDACTED", "REDACTED"}
2024-12-17T17:28:19.820+1300 [TRACE] Meta.Backend: built configuration for "remote" backend with hash value 2832275289
2024-12-17T17:28:19.820+1300 [TRACE] Meta.Backend: working directory was previously initialized for "remote" backend
2024-12-17T17:28:19.820+1300 [TRACE] Meta.Backend: using already-initialized, unchanged "remote" backend configuration
2024-12-17T17:28:19.820+1300 [DEBUG] Service discovery for app.terraform.io at https://app.terraform.io/.well-known/terraform.json
2024-12-17T17:28:19.820+1300 [TRACE] HTTP client GET request to https://app.terraform.io/.well-known/terraform.json
2024-12-17T17:28:20.906+1300 [DEBUG] Retrieve version constraints for service tfe.v2.1 and product terraform
2024-12-17T17:28:20.907+1300 [TRACE] HTTP client GET request to https://checkpoint-api.hashicorp.com/v1/versions/tfe.v2.1?product=terraform
2024-12-17T17:28:22.747+1300 [TRACE] Meta.BackendForPlan: backend *remote.Remote supports operations
2024-12-17T17:28:22.747+1300 [DEBUG] Service discovery for app.terraform.io aliased as localterraform.com
2024-12-17T17:28:22.747+1300 [TRACE] Meta.Backend: instantiated backend of type *remote.Remote
2024-12-17T17:28:22.753+1300 [TRACE] providercache.fillMetaCache: scanning directory .terraform/providers
2024-12-17T17:28:22.754+1300 [TRACE] getproviders.SearchLocalDirectory: found registry.terraform.io/cloudflare/cloudflare v4.39.0 for darwin_arm64 at .terraform/providers/registry.terraform.io/cloudflare/cloudflare/4.39.0/darwin_arm64
2024-12-17T17:28:22.754+1300 [TRACE] getproviders.SearchLocalDirectory: found registry.terraform.io/cloudflare/cloudflare v4.45.0 for darwin_arm64 at .terraform/providers/registry.terraform.io/cloudflare/cloudflare/4.45.0/darwin_arm64
2024-12-17T17:28:22.755+1300 [TRACE] getproviders.SearchLocalDirectory: found registry.terraform.io/cloudflare/cloudflare v4.46.0 for darwin_arm64 at .terraform/providers/registry.terraform.io/cloudflare/cloudflare/4.46.0/darwin_arm64
2024-12-17T17:28:22.755+1300 [TRACE] getproviders.SearchLocalDirectory: found registry.terraform.io/cloudflare/cloudflare v4.48.0 for darwin_arm64 at .terraform/providers/registry.terraform.io/cloudflare/cloudflare/4.48.0/darwin_arm64
2024-12-17T17:28:22.756+1300 [TRACE] getproviders.SearchLocalDirectory: found registry.terraform.io/datadog/datadog v3.43.0 for darwin_arm64 at .terraform/providers/registry.terraform.io/datadog/datadog/3.43.0/darwin_arm64
2024-12-17T17:28:22.756+1300 [TRACE] getproviders.SearchLocalDirectory: found registry.terraform.io/datadog/datadog v3.47.0 for darwin_arm64 at .terraform/providers/registry.terraform.io/datadog/datadog/3.47.0/darwin_arm64
2024-12-17T17:28:22.757+1300 [TRACE] getproviders.SearchLocalDirectory: found registry.terraform.io/datadog/datadog v3.48.1 for darwin_arm64 at .terraform/providers/registry.terraform.io/datadog/datadog/3.48.1/darwin_arm64
2024-12-17T17:28:22.757+1300 [TRACE] getproviders.SearchLocalDirectory: found registry.terraform.io/datadog/datadog v3.49.0 for darwin_arm64 at .terraform/providers/registry.terraform.io/datadog/datadog/3.49.0/darwin_arm64
2024-12-17T17:28:22.757+1300 [TRACE] getproviders.SearchLocalDirectory: found registry.terraform.io/hashicorp/aws v5.63.0 for darwin_arm64 at .terraform/providers/registry.terraform.io/hashicorp/aws/5.63.0/darwin_arm64
2024-12-17T17:28:22.758+1300 [TRACE] getproviders.SearchLocalDirectory: found registry.terraform.io/hashicorp/aws v5.75.1 for darwin_arm64 at .terraform/providers/registry.terraform.io/hashicorp/aws/5.75.1/darwin_arm64
2024-12-17T17:28:22.758+1300 [TRACE] getproviders.SearchLocalDirectory: found registry.terraform.io/hashicorp/aws v5.76.0 for darwin_arm64 at .terraform/providers/registry.terraform.io/hashicorp/aws/5.76.0/darwin_arm64
2024-12-17T17:28:22.758+1300 [TRACE] getproviders.SearchLocalDirectory: found registry.terraform.io/hashicorp/aws v5.81.0 for darwin_arm64 at .terraform/providers/registry.terraform.io/hashicorp/aws/5.81.0/darwin_arm64
2024-12-17T17:28:22.759+1300 [TRACE] getproviders.SearchLocalDirectory: found registry.terraform.io/hashicorp/http v3.4.5 for darwin_arm64 at .terraform/providers/registry.terraform.io/hashicorp/http/3.4.5/darwin_arm64
2024-12-17T17:28:22.759+1300 [TRACE] getproviders.SearchLocalDirectory: found registry.terraform.io/integrations/github v6.2.3 for darwin_arm64 at .terraform/providers/registry.terraform.io/integrations/github/6.2.3/darwin_arm64
2024-12-17T17:28:22.759+1300 [TRACE] getproviders.SearchLocalDirectory: found registry.terraform.io/integrations/github v6.3.1 for darwin_arm64 at .terraform/providers/registry.terraform.io/integrations/github/6.3.1/darwin_arm64
2024-12-17T17:28:22.760+1300 [TRACE] getproviders.SearchLocalDirectory: found registry.terraform.io/integrations/github v6.4.0 for darwin_arm64 at .terraform/providers/registry.terraform.io/integrations/github/6.4.0/darwin_arm64
2024-12-17T17:28:22.760+1300 [TRACE] getproviders.SearchLocalDirectory: found registry.terraform.io/mongodb/mongodbatlas v1.18.0 for darwin_arm64 at .terraform/providers/registry.terraform.io/mongodb/mongodbatlas/1.18.0/darwin_arm64
2024-12-17T17:28:22.761+1300 [TRACE] getproviders.SearchLocalDirectory: found registry.terraform.io/mongodb/mongodbatlas v1.21.4 for darwin_arm64 at .terraform/providers/registry.terraform.io/mongodb/mongodbatlas/1.21.4/darwin_arm64
2024-12-17T17:28:22.761+1300 [TRACE] getproviders.SearchLocalDirectory: found registry.terraform.io/mongodb/mongodbatlas v1.22.0 for darwin_arm64 at .terraform/providers/registry.terraform.io/mongodb/mongodbatlas/1.22.0/darwin_arm64
2024-12-17T17:28:22.761+1300 [TRACE] providercache.fillMetaCache: including .terraform/providers/registry.terraform.io/hashicorp/http/3.4.5/darwin_arm64 as a candidate package for registry.terraform.io/hashicorp/http 3.4.5
2024-12-17T17:28:22.761+1300 [TRACE] providercache.fillMetaCache: including .terraform/providers/registry.terraform.io/integrations/github/6.2.3/darwin_arm64 as a candidate package for registry.terraform.io/integrations/github 6.2.3
2024-12-17T17:28:22.761+1300 [TRACE] providercache.fillMetaCache: including .terraform/providers/registry.terraform.io/integrations/github/6.3.1/darwin_arm64 as a candidate package for registry.terraform.io/integrations/github 6.3.1
2024-12-17T17:28:22.761+1300 [TRACE] providercache.fillMetaCache: including .terraform/providers/registry.terraform.io/integrations/github/6.4.0/darwin_arm64 as a candidate package for registry.terraform.io/integrations/github 6.4.0
2024-12-17T17:28:22.761+1300 [TRACE] providercache.fillMetaCache: including .terraform/providers/registry.terraform.io/mongodb/mongodbatlas/1.18.0/darwin_arm64 as a candidate package for registry.terraform.io/mongodb/mongodbatlas 1.18.0
2024-12-17T17:28:22.761+1300 [TRACE] providercache.fillMetaCache: including .terraform/providers/registry.terraform.io/mongodb/mongodbatlas/1.21.4/darwin_arm64 as a candidate package for registry.terraform.io/mongodb/mongodbatlas 1.21.4
2024-12-17T17:28:22.761+1300 [TRACE] providercache.fillMetaCache: including .terraform/providers/registry.terraform.io/mongodb/mongodbatlas/1.22.0/darwin_arm64 as a candidate package for registry.terraform.io/mongodb/mongodbatlas 1.22.0
2024-12-17T17:28:22.761+1300 [TRACE] providercache.fillMetaCache: including .terraform/providers/registry.terraform.io/cloudflare/cloudflare/4.39.0/darwin_arm64 as a candidate package for registry.terraform.io/cloudflare/cloudflare 4.39.0
2024-12-17T17:28:22.761+1300 [TRACE] providercache.fillMetaCache: including .terraform/providers/registry.terraform.io/cloudflare/cloudflare/4.45.0/darwin_arm64 as a candidate package for registry.terraform.io/cloudflare/cloudflare 4.45.0
2024-12-17T17:28:22.761+1300 [TRACE] providercache.fillMetaCache: including .terraform/providers/registry.terraform.io/cloudflare/cloudflare/4.46.0/darwin_arm64 as a candidate package for registry.terraform.io/cloudflare/cloudflare 4.46.0
2024-12-17T17:28:22.761+1300 [TRACE] providercache.fillMetaCache: including .terraform/providers/registry.terraform.io/cloudflare/cloudflare/4.48.0/darwin_arm64 as a candidate package for registry.terraform.io/cloudflare/cloudflare 4.48.0
2024-12-17T17:28:22.761+1300 [TRACE] providercache.fillMetaCache: including .terraform/providers/registry.terraform.io/datadog/datadog/3.43.0/darwin_arm64 as a candidate package for registry.terraform.io/datadog/datadog 3.43.0
2024-12-17T17:28:22.761+1300 [TRACE] providercache.fillMetaCache: including .terraform/providers/registry.terraform.io/datadog/datadog/3.47.0/darwin_arm64 as a candidate package for registry.terraform.io/datadog/datadog 3.47.0
2024-12-17T17:28:22.761+1300 [TRACE] providercache.fillMetaCache: including .terraform/providers/registry.terraform.io/datadog/datadog/3.48.1/darwin_arm64 as a candidate package for registry.terraform.io/datadog/datadog 3.48.1
2024-12-17T17:28:22.761+1300 [TRACE] providercache.fillMetaCache: including .terraform/providers/registry.terraform.io/datadog/datadog/3.49.0/darwin_arm64 as a candidate package for registry.terraform.io/datadog/datadog 3.49.0
2024-12-17T17:28:22.761+1300 [TRACE] providercache.fillMetaCache: including .terraform/providers/registry.terraform.io/hashicorp/aws/5.63.0/darwin_arm64 as a candidate package for registry.terraform.io/hashicorp/aws 5.63.0
2024-12-17T17:28:22.761+1300 [TRACE] providercache.fillMetaCache: including .terraform/providers/registry.terraform.io/hashicorp/aws/5.75.1/darwin_arm64 as a candidate package for registry.terraform.io/hashicorp/aws 5.75.1
2024-12-17T17:28:22.761+1300 [TRACE] providercache.fillMetaCache: including .terraform/providers/registry.terraform.io/hashicorp/aws/5.76.0/darwin_arm64 as a candidate package for registry.terraform.io/hashicorp/aws 5.76.0
2024-12-17T17:28:22.761+1300 [TRACE] providercache.fillMetaCache: including .terraform/providers/registry.terraform.io/hashicorp/aws/5.81.0/darwin_arm64 as a candidate package for registry.terraform.io/hashicorp/aws 5.81.0
2024-12-17T17:28:22.790+1300 [TRACE] providercache.fillMetaCache: using cached result from previous scan of .terraform/providers
2024-12-17T17:28:22.808+1300 [TRACE] providercache.fillMetaCache: using cached result from previous scan of .terraform/providers
2024-12-17T17:28:23.062+1300 [TRACE] providercache.fillMetaCache: using cached result from previous scan of .terraform/providers
2024-12-17T17:28:23.069+1300 [TRACE] providercache.fillMetaCache: using cached result from previous scan of .terraform/providers
2024-12-17T17:28:23.077+1300 [TRACE] providercache.fillMetaCache: using cached result from previous scan of .terraform/providers
2024-12-17T17:28:23.103+1300 [DEBUG] checking for provisioner in "."
2024-12-17T17:28:23.104+1300 [DEBUG] checking for provisioner in "/opt/homebrew/bin"
2024-12-17T17:28:23.104+1300 [TRACE] Meta.Backend: backend *remote.Remote supports operations
2024-12-17T17:28:23.105+1300 [TRACE] backend/remote: looking up workspace for xpand/infra
╷
│ Error: Error looking up workspace
│ 
│ Invalid Terraform version: Malformed version: ~>1.10.0

Expected Behavior

I upgraded my local Terraform CLI to 1.10.2 and the Terraform Cloud version to ~>1.10.0. Running terraform apply works fine. I should be able to import a resource by creating the resource and using terraform import module.devops.aws_s3_bucket.REDACTED REDACTED. I've done this 100s of times before on version 1.9.x.

Actual Behavior

The import fails with this error:

│ Error: Error looking up workspace
│ 
│ Invalid Terraform version: Malformed version: ~>1.10.0

Steps to Reproduce

  1. terraform import module.devops.aws_s3_bucket.REDACTED REDACTED

Additional Context

No response

References

No response

Generative AI / LLM assisted development?

No response

@KieranP KieranP added bug new new issue not yet triaged labels Dec 17, 2024
@jbardin jbardin added backend/remote cloud Related to Terraform Cloud's integration with Terraform labels Dec 17, 2024
@jbardin
Copy link
Member

jbardin commented Dec 17, 2024

Hi @KieranP,

The Error looking up workspace happens before Terraform starts any of the actual planning process, so I don't think this is a change in import behavior, because the logs show that Terraform hasn't begun executing any of the import process yet.

This is more likely something to do with the old remote backend. I've tagged this to see if someone from the cloud team can determine what may have changed to cause the ~>1.10.0 to be returned as the workspace version. Does it work if you use the newer cloud backend? Can you plan an import using import blocks?

Thanks!

@KieranP
Copy link
Author

KieranP commented Dec 17, 2024

@jbardin Thank you. You are correct. Simply changing backend "remote" { to cloud { in my terraform { config fixed the issue. So seems like 1.10.x has a bug with remote backend.

@crw
Copy link
Contributor

crw commented Dec 17, 2024

May be related to (thought not the same as) #36155.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend/remote bug cloud Related to Terraform Cloud's integration with Terraform new new issue not yet triaged
Projects
None yet
Development

No branches or pull requests

3 participants