Terraform - Define hash using locals

Hashes (key value pairs) can be defined in a locals block. For example, let's say your .usr/local/terraform/locals.tf file has the following.

locals {
  hash = {
    foo = "Hello"
    bar = "World"
  }
}

 

And let's say your /usr/local/terraform/outputs.tf file has the following.

output "my-hash" {
  value = local.hash
}

 

The terraform output command should return the following.

my-hash = {
  "foo" = "Hello"
  "bar" = "World"
}

 




Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee

Add a Comment




We will never share your name or email with anyone. Enter your email if you would like to be notified when we respond to your comment.





Please enter 60b35 in the box below so that we can be sure you are a human.




Comments

Web design by yours truely - me, myself, and I   |   jeremy.canfield@freekb.net   |