diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 5ce0f4898..a7ec0148c 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -42,9 +42,9 @@ jobs: strategy: matrix: terraform: - - '1.0.2' - - '1.3.8' - - '1.4.0' + - '1.7.5' + - '1.8.5' + - '1.9.7' steps: - uses: actions/setup-go@v5 with: diff --git a/configstack/module_test.go b/configstack/module_test.go index 847484c6a..51e33f8d1 100644 --- a/configstack/module_test.go +++ b/configstack/module_test.go @@ -46,7 +46,7 @@ func TestResolveTerraformModulesOneModuleWithIncludesNoDependencies(t *testing.T Path: canonical(t, "../test/fixture-modules/module-b/module-b-child"), Dependencies: []*TerraformModule{}, Config: config.TerragruntConfig{ - RemoteState: state(t, "bucket", "module-b-child/terraform.tfstate"), + RemoteState: state("bucket", "module-b-child/terraform.tfstate"), Terraform: &config.TerraformConfig{Source: "..."}, }, TerragruntOptions: mockOptions.Clone(canonical(t, "../test/fixture-modules/module-b/module-b-child/"+config.DefaultConfigName)), @@ -104,7 +104,7 @@ func TestResolveTerraformModulesMultipleModulesWithDependencies(t *testing.T) { Path: canonical(t, "../test/fixture-modules/module-b/module-b-child"), Dependencies: []*TerraformModule{}, Config: config.TerragruntConfig{ - RemoteState: state(t, "bucket", "module-b-child/terraform.tfstate"), + RemoteState: state("bucket", "module-b-child/terraform.tfstate"), Terraform: &config.TerraformConfig{Source: "..."}, }, TerragruntOptions: mockOptions.Clone(canonical(t, "../test/fixture-modules/module-b/module-b-child/"+config.DefaultConfigName)), @@ -152,7 +152,7 @@ func TestResolveTerraformModulesMultipleModulesWithDependenciesWithIncludes(t *t Path: canonical(t, "../test/fixture-modules/module-b/module-b-child"), Dependencies: []*TerraformModule{}, Config: config.TerragruntConfig{ - RemoteState: state(t, "bucket", "module-b-child/terraform.tfstate"), + RemoteState: state("bucket", "module-b-child/terraform.tfstate"), Terraform: &config.TerraformConfig{Source: "..."}, }, TerragruntOptions: mockOptions.Clone(canonical(t, "../test/fixture-modules/module-b/module-b-child/"+config.DefaultConfigName)), @@ -162,7 +162,7 @@ func TestResolveTerraformModulesMultipleModulesWithDependenciesWithIncludes(t *t Path: canonical(t, "../test/fixture-modules/module-e/module-e-child"), Dependencies: []*TerraformModule{moduleA, moduleB}, Config: config.TerragruntConfig{ - RemoteState: state(t, "bucket", "module-e-child/terraform.tfstate"), + RemoteState: state("bucket", "module-e-child/terraform.tfstate"), Dependencies: &config.ModuleDependencies{Paths: []string{Abs("../test/fixture-modules/module-a"), Abs("../test/fixture-modules/module-b/module-b-child")}}, Terraform: &config.TerraformConfig{Source: "test"}, }, diff --git a/configstack/stack_test.go b/configstack/stack_test.go index 9aeea3fcb..c78943064 100644 --- a/configstack/stack_test.go +++ b/configstack/stack_test.go @@ -17,14 +17,14 @@ func TestFindStackInSubfolders(t *testing.T) { t.Parallel() filePaths := []string{ - "/stage/data-stores/redis/" + config.DefaultConfigName, - "/stage/data-stores/postgres/" + config.DefaultConfigName, - "/stage/ecs-cluster/" + config.DefaultConfigName, - "/stage/kms-master-key/" + config.DefaultConfigName, - "/stage/vpc/" + config.DefaultConfigName, + "stage/data-stores/redis/" + config.DefaultConfigName, + "stage/data-stores/postgres/" + config.DefaultConfigName, + "stage/ecs-cluster/" + config.DefaultConfigName, + "stage/kms-master-key/" + config.DefaultConfigName, + "stage/vpc/" + config.DefaultConfigName, } - tempFolder := createTempFolder(t) + tempFolder := createTempFolder() writeDummyTerragruntConfigs(t, tempFolder, filePaths) envFolder := filepath.ToSlash(util.JoinPath(tempFolder + "/stage")) @@ -51,13 +51,8 @@ func TestFindStackInSubfolders(t *testing.T) { } } -func createTempFolder(t *testing.T) string { - tmpFolder, err := ioutil.TempDir("", "") - if err != nil { - t.Fatalf("Failed to create temp directory: %s\n", err.Error()) - } - - return filepath.ToSlash(tmpFolder) +func createTempFolder() string { + return filepath.ToSlash(os.TempDir()) } // Create a dummy Terragrunt config file at each of the given paths diff --git a/configstack/test_helpers.go b/configstack/test_helpers.go index 47b1c38da..c0bbae41d 100644 --- a/configstack/test_helpers.go +++ b/configstack/test_helpers.go @@ -111,7 +111,7 @@ func assertRunningModulesEqual(t *testing.T, expected *runningModule, actual *ru } // We can't do a simple IsError comparison for UnrecognizedDependency because that error is a struct that -// contains an array, and in Go, trying to compare arrays gives a "comparing noncomparable type +// contains an array, and in Go, trying to compare arrays gives a "comparing non comparable type // configstack.UnrecognizedDependency" panic. Therefore, we have to compare that error more manually. func assertErrorsEqual(t *testing.T, expected error, actual error, messageAndArgs ...interface{}) { actual = tgerrors.Unwrap(actual) @@ -165,7 +165,7 @@ func canonical(t *testing.T, path string) string { } // Create a State struct -func state(t *testing.T, bucket string, key string) *remote.State { +func state(bucket string, key string) *remote.State { return &remote.State{ Backend: "s3", Config: map[string]interface{}{ diff --git a/test/fixture-download/hello-world-with-backend/main.tf b/test/fixture-download/hello-world-with-backend/main.tf index bc394d74e..caeb2a4cb 100644 --- a/test/fixture-download/hello-world-with-backend/main.tf +++ b/test/fixture-download/hello-world-with-backend/main.tf @@ -1,13 +1,9 @@ -data "template_file" "test" { - template = "hello, ${var.name}" -} - variable "name" { description = "Specify a name" } -output "test" { - value = data.template_file.test.rendered +output "example" { + value = "hello, ${var.name}" } terraform { diff --git a/test/fixture-download/hello-world/main.tf b/test/fixture-download/hello-world/main.tf index bd2e95e7e..41f2d21a4 100644 --- a/test/fixture-download/hello-world/main.tf +++ b/test/fixture-download/hello-world/main.tf @@ -1,13 +1,9 @@ -data "template_file" "test" { - template = "${module.hello.hello}, ${var.name}" -} - variable "name" { description = "Specify a name" } output "test" { - value = data.template_file.test.rendered + value = "${module.hello.hello}, ${var.name}" } module "hello" { diff --git a/test/fixture-download/local-relative-extra-args-windows/JZwoL6Viko8bzuRvTOQFx3Jh8vs/3mU4huxMLOXOW5ZgJOFXGUFDKc8/main.tf b/test/fixture-download/local-relative-extra-args-windows/JZwoL6Viko8bzuRvTOQFx3Jh8vs/3mU4huxMLOXOW5ZgJOFXGUFDKc8/main.tf index bd2e95e7e..41f2d21a4 100644 --- a/test/fixture-download/local-relative-extra-args-windows/JZwoL6Viko8bzuRvTOQFx3Jh8vs/3mU4huxMLOXOW5ZgJOFXGUFDKc8/main.tf +++ b/test/fixture-download/local-relative-extra-args-windows/JZwoL6Viko8bzuRvTOQFx3Jh8vs/3mU4huxMLOXOW5ZgJOFXGUFDKc8/main.tf @@ -1,13 +1,9 @@ -data "template_file" "test" { - template = "${module.hello.hello}, ${var.name}" -} - variable "name" { description = "Specify a name" } output "test" { - value = data.template_file.test.rendered + value = "${module.hello.hello}, ${var.name}" } module "hello" { diff --git a/test/fixture-gotemplate/main.tf b/test/fixture-gotemplate/main.tf index 55529fb9b..3e8d641f3 100644 --- a/test/fixture-gotemplate/main.tf +++ b/test/fixture-gotemplate/main.tf @@ -1,9 +1,5 @@ -data "template_file" "@String(`This is an example`).Fields().Join(`_`)" { - template = "ok" -} - -output "result" { - value = data.template_file.This_is_an_example.rendered +output "@String(`This is an output`).Fields().Join(`_`)" { + value = "ok" } variable "test1" { diff --git a/test/fixture-hooks/after-only/main.tf b/test/fixture-hooks/after-only/main.tf index 15d67cca8..d024551a2 100644 --- a/test/fixture-hooks/after-only/main.tf +++ b/test/fixture-hooks/after-only/main.tf @@ -1,7 +1,3 @@ -data "template_file" "example" { - template = "hello, world" -} - output "example" { - value = data.template_file.example.rendered + value = "hello, world" } diff --git a/test/fixture-hooks/before-and-after-merge/qa/my-app/main.tf b/test/fixture-hooks/before-and-after-merge/qa/my-app/main.tf index 7cc7209a9..6cc719cf1 100644 --- a/test/fixture-hooks/before-and-after-merge/qa/my-app/main.tf +++ b/test/fixture-hooks/before-and-after-merge/qa/my-app/main.tf @@ -2,10 +2,6 @@ terraform { backend "s3" {} } -data "template_file" "example" { - template = "hello, world" -} - output "example" { - value = data.template_file.example.rendered + value = "hello, world" } diff --git a/test/fixture-hooks/before-and-after/main.tf b/test/fixture-hooks/before-and-after/main.tf index 15d67cca8..d024551a2 100644 --- a/test/fixture-hooks/before-and-after/main.tf +++ b/test/fixture-hooks/before-and-after/main.tf @@ -1,7 +1,3 @@ -data "template_file" "example" { - template = "hello, world" -} - output "example" { - value = data.template_file.example.rendered + value = "hello, world" } diff --git a/test/fixture-hooks/before-only/main.tf b/test/fixture-hooks/before-only/main.tf index 15d67cca8..d024551a2 100644 --- a/test/fixture-hooks/before-only/main.tf +++ b/test/fixture-hooks/before-only/main.tf @@ -1,7 +1,3 @@ -data "template_file" "example" { - template = "hello, world" -} - output "example" { - value = data.template_file.example.rendered + value = "hello, world" } diff --git a/test/fixture-hooks/before-only/terragrunt.hcl b/test/fixture-hooks/before-only/terragrunt.hcl index f883891f0..9050fc38b 100644 --- a/test/fixture-hooks/before-only/terragrunt.hcl +++ b/test/fixture-hooks/before-only/terragrunt.hcl @@ -1,4 +1,4 @@ pre_hook "pre_hook_1" { on_commands = ["apply", "plan"] command = "touch file.out" -} \ No newline at end of file +} diff --git a/test/fixture-hooks/exitcode-1-run-on-errors/main.tf b/test/fixture-hooks/exitcode-1-run-on-errors/main.tf index 15d67cca8..d024551a2 100644 --- a/test/fixture-hooks/exitcode-1-run-on-errors/main.tf +++ b/test/fixture-hooks/exitcode-1-run-on-errors/main.tf @@ -1,7 +1,3 @@ -data "template_file" "example" { - template = "hello, world" -} - output "example" { - value = data.template_file.example.rendered + value = "hello, world" } diff --git a/test/fixture-hooks/exitcode-1/main.tf b/test/fixture-hooks/exitcode-1/main.tf index 15d67cca8..d024551a2 100644 --- a/test/fixture-hooks/exitcode-1/main.tf +++ b/test/fixture-hooks/exitcode-1/main.tf @@ -1,7 +1,3 @@ -data "template_file" "example" { - template = "hello, world" -} - output "example" { - value = data.template_file.example.rendered + value = "hello, world" } diff --git a/test/fixture-hooks/exitcode-1/terragrunt.hcl b/test/fixture-hooks/exitcode-1/terragrunt.hcl index cb6622bc7..48cf67281 100644 --- a/test/fixture-hooks/exitcode-1/terragrunt.hcl +++ b/test/fixture-hooks/exitcode-1/terragrunt.hcl @@ -6,4 +6,4 @@ post_hook "post_hook_1" { post_hook "post_hook_2" { on_commands = ["apply", "plan"] command = "touch test.out" -} \ No newline at end of file +} diff --git a/test/fixture-hooks/exitcode-2-pre/main.tf b/test/fixture-hooks/exitcode-2-pre/main.tf index 15d67cca8..d024551a2 100644 --- a/test/fixture-hooks/exitcode-2-pre/main.tf +++ b/test/fixture-hooks/exitcode-2-pre/main.tf @@ -1,7 +1,3 @@ -data "template_file" "example" { - template = "hello, world" -} - output "example" { - value = data.template_file.example.rendered + value = "hello, world" } diff --git a/test/fixture-hooks/exitcode-2/main.tf b/test/fixture-hooks/exitcode-2/main.tf index 15d67cca8..d024551a2 100644 --- a/test/fixture-hooks/exitcode-2/main.tf +++ b/test/fixture-hooks/exitcode-2/main.tf @@ -1,7 +1,3 @@ -data "template_file" "example" { - template = "hello, world" -} - output "example" { - value = data.template_file.example.rendered + value = "hello, world" } diff --git a/test/fixture-hooks/ignore-error/main.tf b/test/fixture-hooks/ignore-error/main.tf index 15d67cca8..d024551a2 100644 --- a/test/fixture-hooks/ignore-error/main.tf +++ b/test/fixture-hooks/ignore-error/main.tf @@ -1,7 +1,3 @@ -data "template_file" "example" { - template = "hello, world" -} - output "example" { - value = data.template_file.example.rendered + value = "hello, world" } diff --git a/test/fixture-hooks/interpolations/main.tf b/test/fixture-hooks/interpolations/main.tf index 15d67cca8..d024551a2 100644 --- a/test/fixture-hooks/interpolations/main.tf +++ b/test/fixture-hooks/interpolations/main.tf @@ -1,7 +1,3 @@ -data "template_file" "example" { - template = "hello, world" -} - output "example" { - value = data.template_file.example.rendered + value = "hello, world" } diff --git a/test/fixture-import-files/bad-source/main.tf b/test/fixture-import-files/bad-source/main.tf index f756b484c..f537b5b64 100644 --- a/test/fixture-import-files/bad-source/main.tf +++ b/test/fixture-import-files/bad-source/main.tf @@ -1,7 +1,7 @@ -data "template_file" "example" { - template = var.var +output "example" { + value = var.var } -output "example" { - value = data.template_file.example.rendered +variable "var" { + default = "123" } diff --git a/test/fixture-import-files/bad-source/vars.tf b/test/fixture-import-files/bad-source/vars.tf deleted file mode 100644 index 8ca5aa0ef..000000000 --- a/test/fixture-import-files/bad-source/vars.tf +++ /dev/null @@ -1,3 +0,0 @@ -variable "var" { - default = "123" -} diff --git a/test/fixture-import-files/basic/main.tf b/test/fixture-import-files/basic/main.tf index f756b484c..1f3b61fa8 100644 --- a/test/fixture-import-files/basic/main.tf +++ b/test/fixture-import-files/basic/main.tf @@ -1,7 +1,3 @@ -data "template_file" "example" { - template = var.var -} - output "example" { - value = data.template_file.example.rendered + value = var.var } diff --git a/test/fixture-import-files/overwrite/main.tf b/test/fixture-import-files/overwrite/main.tf index f756b484c..1f3b61fa8 100644 --- a/test/fixture-import-files/overwrite/main.tf +++ b/test/fixture-import-files/overwrite/main.tf @@ -1,7 +1,3 @@ -data "template_file" "example" { - template = var.var -} - output "example" { - value = data.template_file.example.rendered + value = var.var } diff --git a/test/fixture-include/qa/my-app/main.tf b/test/fixture-include/qa/my-app/main.tf index dabe32d12..2b89c7c92 100644 --- a/test/fixture-include/qa/my-app/main.tf +++ b/test/fixture-include/qa/my-app/main.tf @@ -2,7 +2,6 @@ terraform { backend "s3" {} } -# Create an arbitrary local resource -data "template_file" "test" { - template = "Hello, I am a template." -} \ No newline at end of file +output "text" { + value = "Hello, I am an output" +} diff --git a/test/fixture-parent-folders/terragrunt-in-root/child/sub-child/sub-sub-child/main.tf b/test/fixture-parent-folders/terragrunt-in-root/child/sub-child/sub-sub-child/main.tf index dabe32d12..aa7ebf5af 100644 --- a/test/fixture-parent-folders/terragrunt-in-root/child/sub-child/sub-sub-child/main.tf +++ b/test/fixture-parent-folders/terragrunt-in-root/child/sub-child/sub-sub-child/main.tf @@ -2,7 +2,6 @@ terraform { backend "s3" {} } -# Create an arbitrary local resource -data "template_file" "test" { - template = "Hello, I am a template." -} \ No newline at end of file +output "test" { + value = "Hello, I am a output" +} diff --git a/test/fixture-provider/provider.tf b/test/fixture-provider/provider.tf deleted file mode 100644 index 91460b1b6..000000000 --- a/test/fixture-provider/provider.tf +++ /dev/null @@ -1,13 +0,0 @@ -provider "template" { - alias = "test" -} - -# Create an arbitrary local resource -data "template_file" "test" { - provider = "template.@(`test`)" - template = "Everything is fine" -} - -output "ok" { - value = data.template_file.test.rendered -} diff --git a/test/fixture-provider/terragrunt.hcl b/test/fixture-provider/terragrunt.hcl deleted file mode 100644 index c99c29955..000000000 --- a/test/fixture-provider/terragrunt.hcl +++ /dev/null @@ -1,3 +0,0 @@ -terraform { - source = "." -} diff --git a/test/fixture-stack/mgmt/bastion-host/main.tf b/test/fixture-stack/mgmt/bastion-host/main.tf index b83465aa4..87f38533d 100644 --- a/test/fixture-stack/mgmt/bastion-host/main.tf +++ b/test/fixture-stack/mgmt/bastion-host/main.tf @@ -2,13 +2,8 @@ terraform { backend "s3" {} } -# Create an arbitrary local resource -data "template_file" "text" { - template = "[I am a bastion-host template. Data from my dependencies: vpc = ${data.terraform_remote_state.vpc.outputs.text}]" -} - output "text" { - value = data.template_file.text.rendered + value = "[I am a bastion-host template. Data from my dependencies: vpc = ${data.terraform_remote_state.vpc.outputs.text}]" } variable "terraform_remote_state_s3_bucket" { diff --git a/test/fixture-stack/mgmt/vpc/main.tf b/test/fixture-stack/mgmt/vpc/main.tf index 5f95fe801..a6da068ec 100644 --- a/test/fixture-stack/mgmt/vpc/main.tf +++ b/test/fixture-stack/mgmt/vpc/main.tf @@ -6,11 +6,6 @@ terraform { backend "s3" {} } -# Create an arbitrary local resource -data "template_file" "text" { - template = "[I am a mgmt vpc template. I have no dependencies.]" -} - output "text" { - value = data.template_file.text.rendered + value = "[I am a mgmt vpc template. I have no dependencies.]" } diff --git a/test/fixture-stack/stage/backend-app/main.tf b/test/fixture-stack/stage/backend-app/main.tf index 6792d0833..1beed50de 100644 --- a/test/fixture-stack/stage/backend-app/main.tf +++ b/test/fixture-stack/stage/backend-app/main.tf @@ -2,13 +2,8 @@ terraform { backend "s3" {} } -# Create an arbitrary local resource -data "template_file" "text" { - template = "[I am a backend-app template. Data from my dependencies: vpc = ${data.terraform_remote_state.vpc.outputs.text}, bastion-host = ${data.terraform_remote_state.bastion_host.outputs.text}, mysql = ${data.terraform_remote_state.mysql.outputs.text}, search-app = ${data.terraform_remote_state.search_app.outputs.text}]" -} - output "text" { - value = data.template_file.text.rendered + value = "[I am a backend-app template. Data from my dependencies: vpc = ${data.terraform_remote_state.vpc.outputs.text}, bastion-host = ${data.terraform_remote_state.bastion_host.outputs.text}, mysql = ${data.terraform_remote_state.mysql.outputs.text}, search-app = ${data.terraform_remote_state.search_app.outputs.text}]" } variable "terraform_remote_state_s3_bucket" { diff --git a/test/fixture-stack/stage/frontend-app/main.tf b/test/fixture-stack/stage/frontend-app/main.tf index 1a9ce74f9..3e199ca05 100644 --- a/test/fixture-stack/stage/frontend-app/main.tf +++ b/test/fixture-stack/stage/frontend-app/main.tf @@ -2,13 +2,8 @@ terraform { backend "s3" {} } -# Create an arbitrary local resource -data "template_file" "text" { - template = "[I am a frontend-app template. Data from my dependencies: vpc = ${data.terraform_remote_state.vpc.outputs.text}, bastion-host = ${data.terraform_remote_state.bastion_host.outputs.text}, backend-app = ${data.terraform_remote_state.backend_app.outputs.text}]" -} - output "text" { - value = data.template_file.text.rendered + value = "[I am a frontend-app template. Data from my dependencies: vpc = ${data.terraform_remote_state.vpc.outputs.text}, bastion-host = ${data.terraform_remote_state.bastion_host.outputs.text}, backend-app = ${data.terraform_remote_state.backend_app.outputs.text}]" } variable "terraform_remote_state_s3_bucket" { diff --git a/test/fixture-stack/stage/mysql/main.tf b/test/fixture-stack/stage/mysql/main.tf index 6c1d78d01..8a3df19c3 100644 --- a/test/fixture-stack/stage/mysql/main.tf +++ b/test/fixture-stack/stage/mysql/main.tf @@ -2,13 +2,8 @@ terraform { backend "s3" {} } -# Create an arbitrary local resource -data "template_file" "text" { - template = "[I am a mysql template. Data from my dependencies: vpc = ${data.terraform_remote_state.vpc.outputs.text}]" -} - output "text" { - value = data.template_file.text.rendered + value = "[I am a mysql template. Data from my dependencies: vpc = ${data.terraform_remote_state.vpc.outputs.text}]" } variable "terraform_remote_state_s3_bucket" { diff --git a/test/fixture-stack/stage/redis/main.tf b/test/fixture-stack/stage/redis/main.tf index 3307441cc..6fa0d7c47 100644 --- a/test/fixture-stack/stage/redis/main.tf +++ b/test/fixture-stack/stage/redis/main.tf @@ -2,13 +2,8 @@ terraform { backend "s3" {} } -# Create an arbitrary local resource -data "template_file" "text" { - template = "[I am a redis template. Data from my dependencies: vpc = ${data.terraform_remote_state.vpc.outputs.text}]" -} - output "text" { - value = data.template_file.text.rendered + value = "[I am a redis template. Data from my dependencies: vpc = ${data.terraform_remote_state.vpc.outputs.text}]" } variable "terraform_remote_state_s3_bucket" { diff --git a/test/fixture-stack/stage/search-app/example-module/main.tf b/test/fixture-stack/stage/search-app/example-module/main.tf index 2368e3baf..ee084f844 100644 --- a/test/fixture-stack/stage/search-app/example-module/main.tf +++ b/test/fixture-stack/stage/search-app/example-module/main.tf @@ -1,8 +1,3 @@ -# Create an arbitrary local resource -data "template_file" "text" { - template = "Example text from a module" -} - output "text" { - value = data.template_file.text.rendered + value = "Example text from a module" } diff --git a/test/fixture-stack/stage/search-app/main.tf b/test/fixture-stack/stage/search-app/main.tf index 45db4328f..8d1a9d4aa 100644 --- a/test/fixture-stack/stage/search-app/main.tf +++ b/test/fixture-stack/stage/search-app/main.tf @@ -2,17 +2,12 @@ terraform { backend "s3" {} } -# Create an arbitrary local resource -data "template_file" "text" { - template = "[I am a search-app template. Data from my dependencies: vpc = ${data.terraform_remote_state.vpc.outputs.text}, redis = ${data.terraform_remote_state.redis.outputs.text}, example_module = ${module.example_module.text}]" -} - module "example_module" { source = "./example-module" } output "text" { - value = data.template_file.text.rendered + value = "[I am a search-app template. Data from my dependencies: vpc = ${data.terraform_remote_state.vpc.outputs.text}, redis = ${data.terraform_remote_state.redis.outputs.text}, example_module = ${module.example_module.text}]" } variable "terraform_remote_state_s3_bucket" { diff --git a/test/fixture-stack/stage/vpc/main.tf b/test/fixture-stack/stage/vpc/main.tf index c15ddccd2..059363eb7 100644 --- a/test/fixture-stack/stage/vpc/main.tf +++ b/test/fixture-stack/stage/vpc/main.tf @@ -2,13 +2,8 @@ terraform { backend "s3" {} } -# Create an arbitrary local resource -data "template_file" "text" { - template = "[I am a stage vpc template. Data from my dependencies: vpc = ${data.terraform_remote_state.mgmt_vpc.outputs.text}]" -} - output "text" { - value = data.template_file.text.rendered + value = "[I am a stage vpc template. Data from my dependencies: vpc = ${data.terraform_remote_state.mgmt_vpc.outputs.text}]" } variable "terraform_remote_state_s3_bucket" { diff --git a/test/fixture-variables/basic-file/main.tf b/test/fixture-variables/basic-file/main.tf index f3bdd731a..dea2742fa 100644 --- a/test/fixture-variables/basic-file/main.tf +++ b/test/fixture-variables/basic-file/main.tf @@ -1,7 +1,3 @@ -data "template_file" "example" { - template = var.hello -} - output "example" { - value = data.template_file.example.rendered + value = var.hello } diff --git a/test/fixture-variables/basic-file/vars.json b/test/fixture-variables/basic-file/vars.json index 076b39e6d..a09a9f53a 100644 --- a/test/fixture-variables/basic-file/vars.json +++ b/test/fixture-variables/basic-file/vars.json @@ -1,3 +1,3 @@ { - "hello": 123 + "hello": "123" } \ No newline at end of file diff --git a/test/fixture-variables/basic/main.tf b/test/fixture-variables/basic/main.tf index f3bdd731a..dea2742fa 100644 --- a/test/fixture-variables/basic/main.tf +++ b/test/fixture-variables/basic/main.tf @@ -1,7 +1,3 @@ -data "template_file" "example" { - template = var.hello -} - output "example" { - value = data.template_file.example.rendered + value = var.hello } diff --git a/test/fixture-variables/different-types/main.tf b/test/fixture-variables/different-types/main.tf index a6aad10fb..8ea9ad04d 100644 --- a/test/fixture-variables/different-types/main.tf +++ b/test/fixture-variables/different-types/main.tf @@ -1,7 +1,3 @@ -data "template_file" "example" { - template = "${var.bool ? var.list[1] : var.list[0]}-${var.int > 2 ? var.string : ""}" -} - output "example" { - value = data.template_file.example.rendered + value = "${var.bool ? var.list[1] : var.list[0]}-${var.int > 2 ? var.string : ""}" } diff --git a/test/fixture-variables/export-config/main.tf b/test/fixture-variables/export-config/main.tf index ce90582e4..6e37d08b8 100644 --- a/test/fixture-variables/export-config/main.tf +++ b/test/fixture-variables/export-config/main.tf @@ -1,7 +1,3 @@ -data "template_file" "example" { - template = var.ImportVariables[0].Vars[0] -} - output "example" { - value = data.template_file.example.rendered + value = var.ImportVariables[0].Vars[0] } diff --git a/test/fixture-variables/glob-file/main.tf b/test/fixture-variables/glob-file/main.tf index 134ef3f53..9c72409d8 100644 --- a/test/fixture-variables/glob-file/main.tf +++ b/test/fixture-variables/glob-file/main.tf @@ -1,7 +1,3 @@ -data "template_file" "example" { - template = "${var.var1}-${var.var2}-${var.var3}-${var.var4}" -} - output "example" { - value = data.template_file.example.rendered + value = "${var.var1}-${var.var2}-${var.var3}-${var.var4}" } diff --git a/test/fixture-variables/list_from_inputs/main.tf b/test/fixture-variables/list_from_inputs/main.tf index ffa372385..5fcdc9885 100644 --- a/test/fixture-variables/list_from_inputs/main.tf +++ b/test/fixture-variables/list_from_inputs/main.tf @@ -1,5 +1,4 @@ variable "my_list" { - type = list(object({ var1 = string var2 = string diff --git a/test/fixture-variables/list_from_tfvars/main.tf b/test/fixture-variables/list_from_tfvars/main.tf index ffa372385..5fcdc9885 100644 --- a/test/fixture-variables/list_from_tfvars/main.tf +++ b/test/fixture-variables/list_from_tfvars/main.tf @@ -1,5 +1,4 @@ variable "my_list" { - type = list(object({ var1 = string var2 = string diff --git a/test/fixture-variables/load-tf-variables/main.tf b/test/fixture-variables/load-tf-variables/main.tf index 43c2b1f58..4bb62f95d 100644 --- a/test/fixture-variables/load-tf-variables/main.tf +++ b/test/fixture-variables/load-tf-variables/main.tf @@ -1,7 +1,3 @@ -data "template_file" "example" { - template = "${var.var1}-${var.var2}-${var.loaded.var1}-${var.loaded.var2}" -} - output "example" { - value = data.template_file.example.rendered + value = "${var.var1}-${var.var2}-${var.loaded.var1}-${var.loaded.var2}" } diff --git a/test/fixture-variables/load-tf-variables/terragrunt.hcl b/test/fixture-variables/load-tf-variables/terragrunt.hcl index f11c2a394..6f3e36365 100644 --- a/test/fixture-variables/load-tf-variables/terragrunt.hcl +++ b/test/fixture-variables/load-tf-variables/terragrunt.hcl @@ -1,6 +1,6 @@ import_variables "test" { required_var_files = [ - "vars.tf", + "vars.tfvars", ] nested_under = ["loaded"] diff --git a/test/fixture-variables/load-tf-variables/vars.tfvars b/test/fixture-variables/load-tf-variables/vars.tfvars new file mode 100644 index 000000000..1f4c52669 --- /dev/null +++ b/test/fixture-variables/load-tf-variables/vars.tfvars @@ -0,0 +1,2 @@ +var1 = "hello1" +var2 = "hello2" diff --git a/test/fixture-variables/map/main.tf b/test/fixture-variables/map/main.tf index 9b0a489cd..5337508e1 100644 --- a/test/fixture-variables/map/main.tf +++ b/test/fixture-variables/map/main.tf @@ -1,7 +1,3 @@ -data "template_file" "example" { - template = "${var.testmap.test1}-${var.testmap.test2}-${var.nested.testmap2.test1}-${var.nested.testmap2.test2}-@(nested.testmap2.test1)-@(nested.testmap2.test2)" -} - output "example" { - value = data.template_file.example.rendered + value = "${var.testmap.test1}-${var.testmap.test2}-${var.nested.testmap2.test1}-${var.nested.testmap2.test2}-@(nested.testmap2.test1)-@(nested.testmap2.test2)" } diff --git a/test/fixture-variables/module-inline/my-module/main.tf b/test/fixture-variables/module-inline/my-module/main.tf index f3bdd731a..dea2742fa 100644 --- a/test/fixture-variables/module-inline/my-module/main.tf +++ b/test/fixture-variables/module-inline/my-module/main.tf @@ -1,7 +1,3 @@ -data "template_file" "example" { - template = var.hello -} - output "example" { - value = data.template_file.example.rendered + value = var.hello } diff --git a/test/fixture-variables/multiple-nested/main.tf b/test/fixture-variables/multiple-nested/main.tf index f58e699ce..8ab4c30ea 100644 --- a/test/fixture-variables/multiple-nested/main.tf +++ b/test/fixture-variables/multiple-nested/main.tf @@ -1,8 +1,3 @@ -data "template_file" "nested" { - template = "${var.testmap.test1}${var.main.testmap.test2}${var.local.testmap.test3}" -} - output "nested" { - value = data.template_file.nested.rendered + value = "${var.testmap.test1}${var.main.testmap.test2}${var.local.testmap.test3}" } - diff --git a/test/fixture-variables/nested/main.tf b/test/fixture-variables/nested/main.tf index 4d6c511f6..b930f3b8f 100644 --- a/test/fixture-variables/nested/main.tf +++ b/test/fixture-variables/nested/main.tf @@ -1,7 +1,3 @@ -data "template_file" "example" { - template = "${var.nested1["var"]}-${var.nested2["var"]}" -} - output "example" { - value = data.template_file.example.rendered + value = "${var.nested1["var"]}-${var.nested2["var"]}" } diff --git a/test/fixture-variables/no-templating-in-file/main.tf b/test/fixture-variables/no-templating-in-file/main.tf index f3bdd731a..dea2742fa 100644 --- a/test/fixture-variables/no-templating-in-file/main.tf +++ b/test/fixture-variables/no-templating-in-file/main.tf @@ -1,7 +1,3 @@ -data "template_file" "example" { - template = var.hello -} - output "example" { - value = data.template_file.example.rendered + value = var.hello } diff --git a/test/fixture-variables/no-tf-variables/main.tf b/test/fixture-variables/no-tf-variables/main.tf index 3783306e1..0b6eb82cf 100644 --- a/test/fixture-variables/no-tf-variables/main.tf +++ b/test/fixture-variables/no-tf-variables/main.tf @@ -1,7 +1,3 @@ -data "template_file" "example" { - template = "@(hello1)@(hello2)@(hello3)" -} - output "example" { - value = data.template_file.example.rendered + value = "@(hello1)@(hello2)@(hello3)" } diff --git a/test/fixture-variables/overwrite/main.tf b/test/fixture-variables/overwrite/main.tf index f3bdd731a..dea2742fa 100644 --- a/test/fixture-variables/overwrite/main.tf +++ b/test/fixture-variables/overwrite/main.tf @@ -1,7 +1,3 @@ -data "template_file" "example" { - template = var.hello -} - output "example" { - value = data.template_file.example.rendered + value = var.hello } diff --git a/test/fixture-variables/source/main.tf b/test/fixture-variables/source/main.tf index 2e0e6a920..b845b27c9 100644 --- a/test/fixture-variables/source/main.tf +++ b/test/fixture-variables/source/main.tf @@ -1,7 +1,3 @@ -data "template_file" "example" { - template = "${var.hello1}${var.hello2}" -} - output "example" { - value = data.template_file.example.rendered + value = "${var.hello1}${var.hello2}" } diff --git a/test/fixture-variables/templating-in-file/main.tf b/test/fixture-variables/templating-in-file/main.tf index f3bdd731a..dea2742fa 100644 --- a/test/fixture-variables/templating-in-file/main.tf +++ b/test/fixture-variables/templating-in-file/main.tf @@ -1,7 +1,3 @@ -data "template_file" "example" { - template = var.hello -} - output "example" { - value = data.template_file.example.rendered + value = var.hello } diff --git a/test/fixture/main.tf b/test/fixture/main.tf index a337394c1..24982bda7 100644 --- a/test/fixture/main.tf +++ b/test/fixture/main.tf @@ -3,10 +3,16 @@ terraform { } # Create an arbitrary local resource -data "template_file" "test" { - template = "Hello, I am a template. My sample_var value = $${sample_var}" +locals { + test = "Hello, I am a template. My sample_var value = $${sample_var}" +} + +output "rendered_template" { + value = templatestring(local.test, {sample_var = var.sample_var}) +} - vars = { - sample_var = var.sample_var - } +# Configure these variables +variable "sample_var" { + description = "A sample_var to pass to the template." + default = "hello" } diff --git a/test/fixture/outputs.tf b/test/fixture/outputs.tf deleted file mode 100644 index af9fb11e4..000000000 --- a/test/fixture/outputs.tf +++ /dev/null @@ -1,3 +0,0 @@ -output "rendered_template" { - value = data.template_file.test.rendered -} diff --git a/test/fixture/vars.tf b/test/fixture/vars.tf deleted file mode 100644 index 8c0b97eed..000000000 --- a/test/fixture/vars.tf +++ /dev/null @@ -1,5 +0,0 @@ -# Configure these variables -variable "sample_var" { - description = "A sample_var to pass to the template." - default = "hello" -} diff --git a/test/integration_gotemplate_test.go b/test/integration_gotemplate_test.go index 1bf550a84..70d0a0de0 100644 --- a/test/integration_gotemplate_test.go +++ b/test/integration_gotemplate_test.go @@ -16,32 +16,19 @@ func TestTerragruntGoTemplate(t *testing.T) { project string args string expectedOutput []string - additionalTest func(*testing.T, string, string, string) } tests := []test{ - // Test that the provider substitution is working properly - { - project: "fixture-provider", - args: "--terragrunt-apply-template", - expectedOutput: []string{`^ok = "Everything is fine"$`}, - additionalTest: func(t *testing.T, folder, stdout, stderr string) { - assert.NotContains(t, stdout, "Warning") - }, - }, - // Test that loading default variablesthe works even if the terraform original source is not compliant + // Test that loading default variables works even if the terraform original source is not compliant { project: "fixture-gotemplate", args: "--terragrunt-apply-template --terragrunt-logging-level DEBUG", expectedOutput: []string{ - `^result = "ok"$`, + `^This_is_an_output = "ok"$`, `^test1 = "I am test 1"$`, `^test2 = "I am test 2 \(overridden\)"$`, `^json1 = "I am json 1"$`, `^json2 = "I am json 2 \(overridden\)"$`, }, - additionalTest: func(t *testing.T, folder, stdout, stderr string) { - assert.Contains(t, stderr, "caught errors while trying to load default variable values from") - }, }, } for _, test := range tests { @@ -57,9 +44,6 @@ func TestTerragruntGoTemplate(t *testing.T) { for _, expectedOutput := range tt.expectedOutput { assert.Regexp(t, fmt.Sprintf(`(?m).*%s.*`, expectedOutput), stdout.String()) } - if tt.additionalTest != nil { - tt.additionalTest(t, rootPath, stdout.String(), stderr.String()) - } }) } }