Home > Enterprise >  How do I convert this ARM Concat string to Terraform Concat please
How do I convert this ARM Concat string to Terraform Concat please

Time:10-21

Ive been trying for a few hours now to work out how to convert this ARM Concat String to a Terraform Concat String.

"[Concat('DefaultEndpointsProtocol=https;AccountName=', parameters('accountName'), ';AccountKey=', parameters('accountKey'), ';EndpointSuffix=core.windows.net')]"

Terraform what I have so far

value = Concat(['DefaultEndpointsProtocol=https;AccountName=', parameters('azurerm_storage_account.website_storage_account')], [';AccountKey=', parameters('zurerm_storage_account.website_storage_account.primary_access_key'),] ';EndpointSuffix=core.windows.net')]"

Also tried

format("DefaultEndpointsProtocol=https"";"""AccountName="%s{azurerm_storage_account.website_storage_account}";""""AccountKey="%s{azurerm_storage_account.website_storage_account.primary_access_key}";"EndpointSuffix=core.windows.net")

What I am trying to achieve is to put these two values: azurerm_storage_account.website_storage_account & azurerm_storage_account.website_storage_account.primary_access_key in their right places within this string:

DefaultEndpointsProtocol=https;AccountName={acountName};AccountKey={accountKey};EndpointSuffix=core.windows.net

CodePudding user response:

Apologies if I missing something but I think this is simpler than it first appears.


value = "DefaultEndpointsProtocol=https;AccountName=${azurerm_storage_account.website_storage_account.name};AccountKey=${azurerm_storage_account.website_storage_account.primary_access_key};EndpointSuffix=core.windows.net"

Within a string contained within "", Terraform resource attributes can be interpolated within ${}.

I have also modified azurerm_storage_account.website_storage_account to azurerm_storage_account.website_storage_account.name as you have to specify an attribute of the resource, rather than just the resource. I took a guess that name is what you required here, but you can look at the alternative attributes here

  • Related