skip to Main Content

azurerm_public_ip.TestGeraldVm: Importing from ID "C:/Program Files/Git/subscriptions/3476gjkfe7-73ed-3444-2124-n8e6ad00jr1z/resourceGroups/henry/providers/Microsoft.Network/publicIPAddresses/TestVm-ip"…

Error: parsing "C:/Program Files/Git/subscriptions/3476gjkfe7-73ed-3444-2124-n8e6ad00jr1z/resourceGroups/henry/providers/Microsoft.Network/publicIPAddresses/TestVm-ip": parsing segment "subscriptions": parsing the PublicIPAddress ID: the segment at position 0 didn’t match

Expected a PublicIPAddress ID that matched:

/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/publicIPAddresses/publicIPAddressesValue

However this value was provided:

C:/Program Files/Git/subscriptions/3476gjkfe7-73ed-3444-2124-n8e6ad00jr1z/resourceGroups/henry/providers/Microsoft.Network/publicIPAddresses/TestVm-ip

The parsed Resource ID was missing a value for the segment at position 0
(which should be the literal value "subscriptions").

Tried to import the resources to delete the IP

2

Answers


  1. The Azure Public IP resource ID you’re trying to import is incorrect format. the resource ID start with /subscriptions/..., but you provided local path in import command, because of this ID Terraform is throwing an error as incorrect ID.

    Make sure to pass the correct resource ID in terraform import command.

    You can find the azure public IP resource ID by navigating to Azure Public IP address > Select your IP > Overview > JSON View

    enter image description here

      terraform import azurerm_public_ip.example /subscriptions/xxxxxxxxxxx/resourceGroups/Venkat/providers/Microsoft.Network/publicIPAddresses/venkatIP
    

    terraform import azurerm_public_ip.example Public IP resource ID

    enter image description here

    Login or Signup to reply.
  2. If you’re on Windows machine and using Git Bash, this is due to POSIX to Windows conversion ruining the resource ID. The solution is to run the command before executing import:

    export MSYS_NO_PATHCONV=1
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search