Closed unkinected closed 6 months ago
@unkinected Sorry for running into this.. From the error message:
Specified workspace "name" conflicts with TF_WORKSPACE environment variable.
Looks like there is an existing env var TF_WORKSPACE
in your current session, would you please check if it exists by echo $TF_WORKSPACE
. if yes, then evaluate whether you shall unset it by unset TF_WORKSPACE
?
Hi @magodo , yea, that was the first thing I checked. I do not have any environment variables named TF_WORKSPACE
, and even when I do set it manually, there is no change in the output. This problem occurred on a colleague's computer too who retrieved our terraform repo fresh.
We use powershell as our cli and echo $TF_WORKSPACE
and echo $env:TF_WORKSPACE
both return nothing. This command doesn't work when inside the terraform console. I don't see any such variables set in the Windows env variables control panel either.
Note that I am able to add, remove, and alter my resources otherwise just fine. It's the aztfexport map command that is causing problems.
Unfortunately, the environment variable TF_WORKSPACE
somehow is forcely reset by the terraform-exec
library: https://github.com/hashicorp/terraform-exec/pull/75. There are also several upstream issues asking for that feature:
I think you misunderstood. I don’t want to use the TF_WORKSPACE environment variable. I have never set that. I have the workspace specified in my terraform.tf file but yet aztfexport map seems to be ignoring it. Or misinterpreting it or something, thinking that there’s a conflict when there isn’t. This used to work fine and somehow stopped recently, even though my terraform.tf hasn’t changed.
I'm not quite sure when this started, but all of a sudden I'm receiving an error when trying to import resources into Terraform.
I've essentially followed the Azure guide: https://learn.microsoft.com/en-us/azure/developer/terraform/azure-export-for-terraform/export-advanced-scenarios. To reproduce
This has worked fine up til now, though I'll admit it has been a little while since I've needed to do this. My terraform file hasn't changed:
I've tried setting a TF_WORKSPACE environment variable but that doesn't do anything. If I remove the workspaces block from terraform.tf I get a new error:
I was on an older version of aztfexport and just upgraded to 0.14.0, no change. I was on terraform 1.6.6 and upgraded to 1.7.4, no change.
Any ideas? Generating the resource files works, but importing them into terraform state does not.