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 enthusiasticly open our shell and smash something like
terraform import azurerm_resource_group.xxxxx <resourceID>
Code language: HTML, XML (xml)
and straight in our face comes this
Error: Error parsing Resource ID <resourceID> ID contained more segments than required: <resourceID>
Code language: JavaScript (javascript)
Now, hell breaks loose, we check our commands triple times, change the <resourceID> to lower and uppercase but nothing changes.
But wait…
Why the heck contains the <resourceID> of the error message our local file system?!
Something like:
C:/git/subscriptions/xxxx
Code language: JavaScript (javascript)
Powershell to the rescue
It would appear that the <resourceID> is not correctly transmitted to the Azure Provider Plugin and therefore not correctly parsed.
Just using Powershell resolved the issue for me.
The end
Thats all for today folks, i hope i can save someone a little bit of headache.
Have a nice day!
Armin