Reputation: 949
We have a requirement to create an Azure storage account in Terraform. However, the naming convention required is to combine three declared variables, meaning the module will look something like the below:
resource "azurerm_storage_account" "example" {
name = "(var.first)(var.second)(var.third)"
resource_group_name = "rg01"
location = "uksouth"
account_tier = "Standard"
account_replication_type = "GRS"
It's become a bit of a struggle trying to achieve this and having pored over the Terraform guides, there doesn't appear to be any function that can enable us achieve this. Any ideas or suggestions?
Upvotes: 0
Views: 635
Reputation: 2798
You can use format():
resource "azurerm_storage_account" "example" {
name = format("%s%s%s", var.first, var.second, var.third)
resource_group_name = "rg01"
location = "uksouth"
account_tier = "Standard"
account_replication_type = "GRS"
Upvotes: 0
Reputation: 238309
Assuming that your variables are strings and you don't have any incorrect characters, then it should be:
name = "${var.first}${var.second}${var.third}"
Upvotes: 2