├── .gitignore ├── README.md └── test.tf /.gitignore: -------------------------------------------------------------------------------- 1 | # terraform 2 | .terraform/ 3 | *.tfstate* 4 | *.tfvars 5 | *.log 6 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # terraform-local-test 2 | 3 | This repo is used as part of a blog post on [how to test Terraform built-in functions locally](http://artemstar.com/2018/03/03/terraform-test-functions/) 4 | -------------------------------------------------------------------------------- /test.tf: -------------------------------------------------------------------------------- 1 | variable "my_list" { 2 | default = ["hello", "world"] 3 | } 4 | 5 | variable "my_map" { 6 | default = { 7 | id = "1" 8 | message = "hello world" 9 | } 10 | } 11 | 12 | ## functions to test 13 | output "my_list_test1" { 14 | value = "${length(var.my_list)}" 15 | } 16 | 17 | output "my_map_test1" { 18 | value = "${lookup(var.my_map, "id")}" 19 | } 20 | 21 | output "my_map_test2" { 22 | value = "${lookup(var.my_map, "message")}" 23 | } 24 | 25 | output "my_map_test3" { 26 | value = "${lookup(var.my_map, "author", "None")}" 27 | } 28 | --------------------------------------------------------------------------------