Reputation: 153
I have issue with tags, this pattern worked on AWS but for Azure i got error which is strange, can someone review and help? Thanks.
$ terraform plan
Error: azurerm_virtual_network.vnet: 1 error(s) occurred:
azurerm_virtual_network.vnet: At column 5, line 2: merge: argument 1 should be type map, got type string in:
${ merge(map("Name", var.env_name), var.global_tags, var.vnet_tags)}
main.tf
resource "azurerm_resource_group" "vnet" {
name = "${var.resource_group_name}"
location = "${var.location}"
}
resource "azurerm_virtual_network" "vnet" {
name = "${var.vnet_name}"
location = "${var.location}"
address_space = ["${var.address_space}"]
resource_group_name = "${azurerm_resource_group.vnet.name}"
dns_servers = "${var.dns_servers}"
tags = "${
merge(map("Name", format("%s %s", var.env_name, "Vnet")),
var.global_tags,
var.vnet_tags)}"
variables.tf
variable "env_name" {
default = "Company DTAP"
}
variable "global_tags" {
default = "Company Ltd"
}
variable "vnet_tags" {
default = "Production"
}
Upvotes: 1
Views: 505
Reputation: 72151
I dont really know what you are trying to achieve, but merge
works with maps, where as in your case global_tags
and vnet_tags
are strings. and the error says just that
so you cast your first input to the merge
function to MAP, but dont cast the other ones. you should cast them to MAP as well.
Upvotes: 1