I am trying to import resources into the Terraform Enterprise remote
backend by running CLI commands from my local machine. Terraform version specified is 0.13.5 on the local system and the target Terraform Enterprise workspace. I’m making use of azurerm
provider version 2.60.0
The configuration looks like the following:
main.tf
terraform {
backend "remote" {
hostname = "my_host_name"
organization = "my_organization_name"
workspaces {
prefix = "my_workspace_prefix_"
}
}
}
provider "azurerm" {
version = ">=1.20.0"
subscription_id = var.my_subscription_id
tenant_id = var.my_tenant_id
client_id = var.my_client_id
client_secret = var.my_client_secret
features {}
}
module "my_module" {
source = "link to private registry"
version = "version_value"
subscription_id = var.my_subscription_id
tenant_id = var.my_tenant_id
client_id = var.my_client_id
client_secret = var.my_client_secret
}
# variable declarations and definitions
variables.auto.tfvars
my_subscription_id = "value"
my_tenant_id = "value"
my_client_id = "value"
my_client_secret = "value"
When I try to import a resource for my_module by running the command terraform import <module_path> <resource_address>
, I run into the following error:
Error: Invalid provider configuration
on main.tf line 8:
8: provider "azurerm" {
The configuration for provider["registry.terraform.io/hashicorp/azurerm"] depends
on values that cannot be determined until apply.
Another thing to note is that the provider input variables are also defined as Terraform Enterprise workspace variables.
I’m not sure why I would get this error when the values to the input variables are defined in an .auto.tfvars
file.
To try to resolve this, I have also tried passing in the provider variables explicitly via the command line arguments in the -var 'foo=bar'
format, but I still get the same error.
I also tried switching to the local backend with the exact same configuration, the import is successful when I do so. So the issue seems to be relevant just for the remote
backend.
When I specified the literal values to the provider arguments (instead of input variables), the import was successful for the remote
backend.
I need to use the input variables for provider arguments because these are sensitive in nature and can only be specified at runtime and cannot be specified as literal values. Does anyone has any feedback on how to resolve this issue?
Thank you!