Post

How to fix 'Error parsing Resource ID […]: ID contained more segments than required' in Terraform

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:

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 to lower and uppercase but nothing changes.

But wait…

Why the heck contains the of the error message our local file system?! Something like:

C:/git/subscriptions/xxxx

Powershell to the rescue

It would appear that the 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, hopefully I can save you a little bit of headache.

Have a nice day!

This post is licensed under CC BY 4.0 by the author.