2

I have an ID of a resource and the ID states that the value is known as "/Subscriptions/xxxxxxx-xxxxxx-xxxxxx-xxxxx/" and when leveraging the data resource, "azurerm_subscription "current" ", to get the current subscription data, I get the output of "/subscriptions/xxxxxxx-xxxxxx-xxxxxx-xxxxx/".

You will notice that the only difference between the two values is the Upper case S in the word "Subscriptions". When making terraform changes to use "azurerm_subscription.current.id", instead of hardcoding the Subscription ID value in other resources, it fails to acknowledge the syntax is the same and is telling me that I need to replace the resource I am working with (in this situation I am working with a data disk on a vm). I do not want to destroy the disk and recreate it using just a different casing of the word subscription.

Is this task possible? Am I able to place anything into the main.tf file I am working with to change this casing? I have tried "title(data.azurerm_subscription.current.id)" and it does work in changing the s to an upper case S, however, it also makes all other "first words" that start with an alphabet letter upper case as well (not desired result). I just want to upper case the very first word.

Kind of a loaded question, but any thoughts on this?

aseb
  • 274
  • 2
  • 11
  • Trying to use regex() commands as well to just focus a change on the 1st character of the ID (in this case S) so if anyone has thoughts on that, please let me know! – aseb Dec 02 '20 at 17:35
  • I'm not sure about this resource type in particular, but typically if a remote system considers two different strings to be functionally equivalent like this then the provider will include a rule to normalize it so that it doesn't show up as a change to be applied. If that's not happening here, the provider dev team might be willing to add a new rule for that so that what you tried would work without any special adjustments. – Martin Atkins Dec 03 '20 at 00:41
  • That would be nice! The provider is not handling this situation well. The Resource ID has the word as "Subscriptions" instead of "subscriptions" which tells me that the resource has to be deleted and replaced if I run terraform apply. Even though the words are the same, the uppercase S throws the configuration off. – aseb Dec 03 '20 at 15:33
  • TBH this is very annoying and should be fixed. – Rafael Colucci Jun 16 '21 at 12:10
  • Agreed! But we can only use what exists sadly – aseb Jun 16 '21 at 16:51

0 Answers0