Search code examples
azurevariablesterraformstring-concatenationterraform-provider-azure

Azure VM shutdown using variables in Terraform


I have a requirement to use variables to set notification emails to a list of people in Terraform to shut down a resource. However, the emails to be sent are required to combine three declared variables, so the module will look something like the below:

  notification_settings {
    enabled         = true
    time_in_minutes = "180"
    email           = format("%s", "${var.config.person1};${var.config.person2};${var.config.person3}")
  }

Any ideas or suggestions would be helpful on how to do this.


Solution

  • This should be changed from:

    email = format("%s", "${var.config.person1};${var.config.person2};${var.config.person3}")
    

    to:

    email = format("%s;%s;%s", var.config.person1, var.config.person2, var.config.person3)
    

    More information on format function can be found in [1].


    [1] https://www.terraform.io/language/functions/format