Using Terraform to import existing resources on Azure

前端 未结 3 1231
死守一世寂寞
死守一世寂寞 2020-12-06 11:21

I have an existing resource group on Azure with a VM running on it and have been playing around with Terraform to try and import the resource to my state file.

I ha

3条回答
  •  囚心锁ツ
    2020-12-06 11:41

    It looks like you need to fix your script file first - azurerm isn't a valid resource name, did you mean:

    resource "azurerm_resource_group" "example" {
        # ...instance configuration...
        name = "MyResourceGroup"    
    }
    

    As seen in the output, import is expecting two parameters, ADDR and ID - you're only passing (what I assume is) the ID. You also need to tell terraform which resource in your script it maps to:

    terraform import azurerm_resource_group.example \
      /subscriptions/MySubscriptionNumber/resourceGroups/MyResourceGroup
    

提交回复
热议问题