How to fix 'Error parsing Resource ID […]: ID contained more segments than required' in Terraform
Hey folks,
today I would like to give you a quick hint in the hope of saving you an hour’s worth of pondering.
Our starting position:
- We want to import an existing Azure resource into Terraform.
- We use the actual Terraform version 0.12.28
- We use the actual Terraform Azure Provider v2.18.0
- We use Git for Windows
- We use the provided Git Bash
To long to read
Update: 24.01.23:
Thanks to Sven for pointing out an even better solution, as described here:
https://github.com/hashicorp/terraform-provider-azurerm/issues/2208
Original:
Use Powershell.
The whole story
So, we enthusiastically open our shell and smash something like
terraform import azurerm_resource_group.xxxxx <resourceID>
and straight in our face comes this
Error: Error parsing Resource ID <resourceID> ID contained more segments than required: <resourceID>
Now, hell breaks loose, we check our commands triple times, change the
But wait…
Why the heck contains the
C:/git/subscriptions/xxxx
Powershell to the rescue
It would appear that the
Just using Powershell resolved the issue for me.
The end
Thats all for today folks, hopefully I can save you a little bit of headache.
Have a nice day!