asp
asp

Reputation: 835

Issue in importing Azure resource into Terraform state

Objective: Trying to import module.resource which is already created azure resource via terraform into my statefile

What I tried:

terraform -chdir=Terraform import synapse_workspace_pe.azurerm_private_endpoint.syn_ws_pe_dev "/subscriptions/xxxx-xxxx-xxx--xx/resourceGroups/hub/providers/Microsoft.Network/privateEndpoints/pe-cb-ab-dev-we-dev"

Error that I get:

error: Invalid address
│ 
│   on <import-address> line 1:
│    1: synapse_workspace_pe.azurerm_private_endpoint.syn_ws_pe_dev
│ 
│ Resource instance key must be given in square brackets

I referred to some stackoverflow posts, syntax is same. can some one tell me how to fix this ?

Upvotes: 0

Views: 761

Answers (1)

Matthew Schuchard
Matthew Schuchard

Reputation: 28739

When importing resources from a declared module, then the namespace must be prefixed with the string literal module:

terraform -chdir=Terraform import module.synapse_workspace_pe.azurerm_private_endpoint.syn_ws_pe_dev "/subscriptions/xxxx-xxxx-xxx--xx/resourceGroups/hub/providers/Microsoft.Network/privateEndpoints/pe-cb-ab-dev-we-dev"

Upvotes: 4

Related Questions