How to change map method to tomap method?
Let's say you have multiple tags in your code which was written quite back and that time it was working fine on old Terraform version before v0.12 but if the same code you execute on updated/latest Terrafrom you get subjected error while try to run Terrafrom plan command. Then this article will help you to fix your issue.
What is simple solution to fix this issue?
Just replace "map" method to "tomap" and just to little bit formatting for the same.
map({"Name", "My_Name"), map("AppName", "My_App")})
tomap({"Name" = "My_Name", "App_Name" = "My_App"})
or
tomap({
"Name" = "My_Name",
"App_Name" = "My_App"
})
#Code with "map" method
resource "aws_instance" "My_instance"
ami = my_ami
instance_type = my_type
tags = merge(var.tags, map({"Name", "My_instance_Name"), map("AppName", "My_App"), map("Project", "My_Project"), map("Team_contact", "my_team@example.com"}))
#Code with "tomap" method
resource "aws_instance" "My_instance"
ami = my_ami
instance_type = my_type
tags = merge(var.tags, tomap({"Name" = "My_instance_Name", "AppName" = "My_App", "Project" = "My_Project", "Team_contact" = "my_team@example.com"}))
In latest version of Terrafrom "map" method has been deprecated(not available). So you have to use "tomap" methoed instead of map.
your valuable information and time. Please keep updating.
ReplyDeleteDevops Online Training Hyderabad
Best Devops Online Course