From c6787d02664d238782d95cade4f0cdb4a306db4a Mon Sep 17 00:00:00 2001 From: James Bardin Date: Wed, 23 May 2018 13:39:36 -0400 Subject: [PATCH] update test fixtures Update test fixtures to work in our new world. This is mostly changing out attribute names for those in the schema, adding Providers to states, and updating the test-fixture configurations. --- terraform/context_apply_test.go | 187 +++++++++--------- terraform/context_test.go | 20 +- terraform/graph_builder.go | 2 +- terraform/node_resource_abstract.go | 2 + terraform/terraform_test.go | 9 +- .../apply-destroy-cross-providers/main.tf | 5 +- .../apply-destroy-targeted-count/main.tf | 2 +- terraform/test-fixtures/apply-good/main.tf | 2 +- .../apply-interpolated-count/main.tf | 2 +- .../amodule/main.tf | 2 +- .../main.tf | 2 +- .../main.tf | 5 +- .../child/main.tf | 5 +- .../apply-module-var-resource-count/main.tf | 5 +- .../main.tf | 2 +- .../child/child.tf | 5 +- .../apply-multi-var-comprehensive/root.tf | 9 +- .../apply-multi-var-count-dec/main.tf | 4 +- .../apply-multi-var-order-interp/main.tf | 6 +- .../apply-multi-var-order/main.tf | 4 +- .../test-fixtures/apply-multi-var/main.tf | 4 +- .../apply-provisioner-conninfo/main.tf | 9 +- .../provisioner-interp-count.tf | 4 +- .../test-fixtures/issue-5254/step-1/main.tf | 4 +- 24 files changed, 161 insertions(+), 140 deletions(-) diff --git a/terraform/context_apply_test.go b/terraform/context_apply_test.go index f3680ba559..46600156ba 100644 --- a/terraform/context_apply_test.go +++ b/terraform/context_apply_test.go @@ -86,6 +86,7 @@ func TestContext2Apply_unstable(t *testing.T) { md := plan.Diff.RootModule() rd := md.Resources["test_resource.foo"] + randomVal := rd.Attributes["random"].New t.Logf("plan-time value is %q", randomVal) @@ -214,55 +215,54 @@ func TestContext2Apply_resourceDependsOnModule(t *testing.T) { p := testProvider("aws") p.DiffFn = testDiffFn - { - // Wait for the dependency, sleep, and verify the graph never - // called a child. - var called int32 - var checked bool - p.ApplyFn = func( - info *InstanceInfo, - is *InstanceState, - id *InstanceDiff) (*InstanceState, error) { - if info.HumanId() == "module.child.aws_instance.child" { - checked = true + // verify the apply happens in the correct order + var mu sync.Mutex + var order []string - // Sleep to allow parallel execution - time.Sleep(50 * time.Millisecond) + p.ApplyFn = func( + info *InstanceInfo, + is *InstanceState, + id *InstanceDiff) (*InstanceState, error) { + if info.HumanId() == "module.child.aws_instance.child" { - // Verify that called is 0 (dep not called) - if atomic.LoadInt32(&called) != 0 { - return nil, fmt.Errorf("aws_instance.a should not be called") - } - } + // make the child slower than the parent + time.Sleep(50 * time.Millisecond) - atomic.AddInt32(&called, 1) - return testApplyFn(info, is, id) + mu.Lock() + order = append(order, "child") + mu.Unlock() + } else { + mu.Lock() + order = append(order, "parent") + mu.Unlock() } - ctx := testContext2(t, &ContextOpts{ - Config: m, - ProviderResolver: ResourceProviderResolverFixed( - map[string]ResourceProviderFactory{ - "aws": testProviderFuncFixed(p), - }, - ), - }) - - if _, diags := ctx.Plan(); diags.HasErrors() { - t.Fatalf("diags: %s", diags.Err()) - } - - state, diags := ctx.Apply() - if diags.HasErrors() { - t.Fatalf("diags: %s", diags.Err()) - } - - if !checked { - t.Fatal("should check") - } - - checkStateString(t, state, testTerraformApplyResourceDependsOnModuleStr) + return testApplyFn(info, is, id) } + + ctx := testContext2(t, &ContextOpts{ + Config: m, + ProviderResolver: ResourceProviderResolverFixed( + map[string]ResourceProviderFactory{ + "aws": testProviderFuncFixed(p), + }, + ), + }) + + if _, diags := ctx.Plan(); diags.HasErrors() { + t.Fatalf("diags: %s", diags.Err()) + } + + state, diags := ctx.Apply() + if diags.HasErrors() { + t.Fatalf("diags: %s", diags.Err()) + } + + if !reflect.DeepEqual(order, []string{"child", "parent"}) { + t.Fatal("resources applied out of order") + } + + checkStateString(t, state, testTerraformApplyResourceDependsOnModuleStr) } // Test that without a config, the Dependencies in the state are enough @@ -301,27 +301,28 @@ func TestContext2Apply_resourceDependsOnModuleStateOnly(t *testing.T) { } { - // Wait for the dependency, sleep, and verify the graph never - // called a child. - var called int32 - var checked bool + // verify the apply happens in the correct order + var mu sync.Mutex + var order []string + p.ApplyFn = func( info *InstanceInfo, is *InstanceState, id *InstanceDiff) (*InstanceState, error) { if info.HumanId() == "aws_instance.a" { - checked = true - // Sleep to allow parallel execution + // make the dep slower than the parent time.Sleep(50 * time.Millisecond) - // Verify that called is 0 (dep not called) - if atomic.LoadInt32(&called) != 0 { - return nil, fmt.Errorf("module child should not be called") - } + mu.Lock() + order = append(order, "child") + mu.Unlock() + } else { + mu.Lock() + order = append(order, "parent") + mu.Unlock() } - atomic.AddInt32(&called, 1) return testApplyFn(info, is, id) } @@ -344,8 +345,8 @@ func TestContext2Apply_resourceDependsOnModuleStateOnly(t *testing.T) { t.Fatalf("diags: %s", diags.Err()) } - if !checked { - t.Fatal("should check") + if !reflect.DeepEqual(order, []string{"child", "parent"}) { + t.Fatal("resources applied out of order") } checkStateString(t, state, "") @@ -1069,6 +1070,7 @@ func TestContext2Apply_createBeforeDestroy_hook(t *testing.T) { "require_new": "abc", }, }, + Provider: "provider.aws", }, }, }, @@ -1213,6 +1215,7 @@ func TestContext2Apply_createBeforeDestroy_deposedOnly(t *testing.T) { ID: "foo", }, }, + Provider: "provider.aws", }, }, }, @@ -1725,25 +1728,20 @@ func TestContext2Apply_destroyCrossProviders(t *testing.T) { p_aws.ApplyFn = testApplyFn p_aws.DiffFn = testDiffFn - p_tf := testProvider("terraform") - p_tf.ApplyFn = testApplyFn - p_tf.DiffFn = testDiffFn - providers := map[string]ResourceProviderFactory{ - "aws": testProviderFuncFixed(p_aws), - "terraform": testProviderFuncFixed(p_tf), + "aws": testProviderFuncFixed(p_aws), } // Bug only appears from time to time, // so we run this test multiple times // to check for the race-condition - for i := 0; i <= 10; i++ { + + // FIXME: this test flaps now, so run it more times + for i := 0; i <= 100; i++ { ctx := getContextForApply_destroyCrossProviders(t, m, providers) - if p, diags := ctx.Plan(); diags.HasErrors() { + if _, diags := ctx.Plan(); diags.HasErrors() { t.Fatalf("diags: %s", diags.Err()) - } else { - t.Logf(p.String()) } if _, diags := ctx.Apply(); diags.HasErrors() { @@ -1758,14 +1756,15 @@ func getContextForApply_destroyCrossProviders(t *testing.T, m *configs.Config, p &ModuleState{ Path: rootModulePath, Resources: map[string]*ResourceState{ - "terraform_remote_state.shared": &ResourceState{ - Type: "terraform_remote_state", + "aws_instance.shared": &ResourceState{ + Type: "aws_instance", Primary: &InstanceState{ ID: "remote-2652591293", Attributes: map[string]string{ - "output.env_name": "test", + "id": "test", }, }, + Provider: "provider.aws", }, }, }, @@ -1780,6 +1779,7 @@ func getContextForApply_destroyCrossProviders(t *testing.T, m *configs.Config, p "value": "test", }, }, + Provider: "provider.aws", }, }, }, @@ -1826,9 +1826,6 @@ func TestContext2Apply_minimal(t *testing.T) { } func TestContext2Apply_badDiff(t *testing.T) { - // FIXME - return - m := testModule(t, "apply-good") p := testProvider("aws") p.ApplyFn = testApplyFn @@ -1849,7 +1846,11 @@ func TestContext2Apply_badDiff(t *testing.T) { p.DiffFn = func(*InstanceInfo, *InstanceState, *ResourceConfig) (*InstanceDiff, error) { return &InstanceDiff{ Attributes: map[string]*ResourceAttrDiff{ - "newp": nil, + "newp": &ResourceAttrDiff{ + Old: "", + New: "", + NewComputed: true, + }, }, }, nil } @@ -3076,6 +3077,7 @@ func TestContext2Apply_moduleVarRefExisting(t *testing.T) { "foo": "bar", }, }, + Provider: "provider.aws", }, }, }, @@ -3391,7 +3393,7 @@ func TestContext2Apply_multiProviderDestroyChild(t *testing.T) { p.ApplyFn = testApplyFn p.DiffFn = testDiffFn - p2 := testProvider("do") + p2 := testProvider("vault") p2.ApplyFn = testApplyFn p2.DiffFn = testDiffFn @@ -4427,9 +4429,6 @@ func TestContext2Apply_provisionerCreateFailNoId(t *testing.T) { } func TestContext2Apply_provisionerFail(t *testing.T) { - // FIXME - return - m := testModule(t, "apply-provisioner-fail") p := testProvider("aws") pr := testProvisioner() @@ -4475,9 +4474,6 @@ func TestContext2Apply_provisionerFail(t *testing.T) { } func TestContext2Apply_provisionerFail_createBeforeDestroy(t *testing.T) { - // FIXME - return - m := testModule(t, "apply-provisioner-fail-create-before") p := testProvider("aws") pr := testProvisioner() @@ -4782,9 +4778,6 @@ aws_instance.web: // Verify that a normal provisioner with on_failure "continue" set won't // taint the resource and continues executing. func TestContext2Apply_provisionerFailContinue(t *testing.T) { - // FIXME - return - m := testModule(t, "apply-provisioner-fail-continue") p := testProvider("aws") pr := testProvisioner() @@ -4833,9 +4826,6 @@ aws_instance.foo: // Verify that a normal provisioner with on_failure "continue" records // the error with the hook. func TestContext2Apply_provisionerFailContinueHook(t *testing.T) { - // FIXME - return - h := new(MockHook) m := testModule(t, "apply-provisioner-fail-continue") p := testProvider("aws") @@ -5778,9 +5768,6 @@ func TestContext2Apply_provisionerExplicitSelfRef(t *testing.T) { // Provisioner should NOT run on a diff, only create func TestContext2Apply_Provisioner_Diff(t *testing.T) { - //FIXME - return - m := testModule(t, "apply-provisioner-diff") p := testProvider("aws") pr := testProvisioner() @@ -5955,7 +5942,7 @@ func TestContext2Apply_Provisioner_ConnInfo(t *testing.T) { if conn["user"] != "superuser" { t.Fatalf("Bad: %#v", conn) } - if conn["pass"] != "test" { + if conn["password"] != "test" { t.Fatalf("Bad: %#v", conn) } @@ -6901,7 +6888,7 @@ func TestContext2Apply_error(t *testing.T) { actual := strings.TrimSpace(state.String()) expected := strings.TrimSpace(testTerraformApplyErrorStr) if actual != expected { - t.Fatalf("bad: \n%s", actual) + t.Fatalf("expected:\n%s\n\ngot:\n%s", expected, actual) } } @@ -6975,7 +6962,7 @@ func TestContext2Apply_errorPartial(t *testing.T) { actual := strings.TrimSpace(state.String()) expected := strings.TrimSpace(testTerraformApplyErrorPartialStr) if actual != expected { - t.Fatalf("bad: \n%s", actual) + t.Fatalf("expected:\n%s\n\ngot:\n%s", expected, actual) } } @@ -7702,6 +7689,7 @@ func TestContext2Apply_targetedDestroy(t *testing.T) { checkStateString(t, state, ` aws_instance.bar: ID = i-abc123 + provider = provider.aws `) } @@ -8016,7 +8004,7 @@ func TestContext2Apply_targetedDestroyModule(t *testing.T) { }, }, Targets: []addrs.Targetable{ - addrs.RootModuleInstance.Resource( + addrs.RootModuleInstance.Child("child", addrs.NoKey).Resource( addrs.ManagedResourceMode, "aws_instance", "foo", ), }, @@ -8035,12 +8023,15 @@ func TestContext2Apply_targetedDestroyModule(t *testing.T) { checkStateString(t, state, ` aws_instance.bar: ID = i-abc123 + provider = provider.aws aws_instance.foo: ID = i-bcd345 + provider = provider.aws module.child: aws_instance.bar: ID = i-abc123 + provider = provider.aws `) } @@ -8094,12 +8085,16 @@ func TestContext2Apply_targetedDestroyCountIndex(t *testing.T) { checkStateString(t, state, ` aws_instance.bar.0: ID = i-abc123 + provider = provider.aws aws_instance.bar.2: ID = i-abc123 + provider = provider.aws aws_instance.foo.0: ID = i-bcd345 + provider = provider.aws aws_instance.foo.1: ID = i-bcd345 + provider = provider.aws `) } @@ -8346,7 +8341,7 @@ func TestContext2Apply_unknownAttribute(t *testing.T) { state, diags := ctx.Apply() if diags.HasErrors() { - t.Fatal("should error") + t.Fatal("should error with UnknownVariableValue") } actual := strings.TrimSpace(state.String()) @@ -9170,9 +9165,6 @@ module.middle.bottom: // If a data source explicitly depends on another resource, it's because we need // that resource to be applied first. func TestContext2Apply_dataDependsOn(t *testing.T) { - //FIXME - return - p := testProvider("null") m := testModule(t, "apply-data-depends-on") @@ -9225,6 +9217,7 @@ func TestContext2Apply_dataDependsOn(t *testing.T) { t.Fatalf("diags: %s", diags.Err()) } + t.Fatal("nil pointer below") root := state.ModuleByPath(addrs.RootModuleInstance) actual := root.Resources["data.null_data_source.read"].Primary.Attributes["foo"] diff --git a/terraform/context_test.go b/terraform/context_test.go index 390fad2e10..39c08f6db9 100644 --- a/terraform/context_test.go +++ b/terraform/context_test.go @@ -401,6 +401,10 @@ func testProvisioner() *MockResourceProvisioner { Type: cty.String, Optional: true, }, + "when": { + Type: cty.String, + Optional: true, + }, }, } return p @@ -464,6 +468,14 @@ func testProviderSchema(name string) *ProviderSchema { Type: cty.String, Optional: true, }, + "value": { + Type: cty.String, + Optional: true, + }, + "root": { + Type: cty.Number, + Optional: true, + }, }, }, ResourceTypes: map[string]*configschema.Block{ @@ -584,8 +596,8 @@ func testProviderSchema(name string) *ProviderSchema { Optional: true, }, "output": { - Type: cty.String, - Optional: true, + Type: cty.Map(cty.String), + Computed: true, }, }, }, @@ -629,6 +641,10 @@ func testProviderSchema(name string) *ProviderSchema { Type: cty.String, Optional: true, }, + "output": { + Type: cty.Map(cty.String), + Optional: true, + }, }, }, name + "_file": { diff --git a/terraform/graph_builder.go b/terraform/graph_builder.go index 76ae5be6e7..ccdbd3419f 100644 --- a/terraform/graph_builder.go +++ b/terraform/graph_builder.go @@ -67,7 +67,7 @@ func (b *BasicGraphBuilder) Build(path addrs.ModuleInstance) (*Graph, tfdiags.Di log.Printf("[TRACE] Completed graph transform %T with new graph:\n%s------", step, thisStepStr) lastStepStr = thisStepStr } else { - log.Printf("[TRACE] Completed graph transform %T (no changes)", step) + log.Printf("[TRACE] Completed graph transform %T (no changes)\n------", step) } if err != nil { diff --git a/terraform/node_resource_abstract.go b/terraform/node_resource_abstract.go index 2f3592bcc9..5d01101a08 100644 --- a/terraform/node_resource_abstract.go +++ b/terraform/node_resource_abstract.go @@ -364,6 +364,8 @@ func (n *NodeAbstractResource) ProvisionedBy() []string { // GraphNodeProvisionerConsumer func (n *NodeAbstractResource) AttachProvisionerSchema(name string, schema *configschema.Block) { + // FIXME: this isn't called anywehere + panic("unused") n.ProvisionerSchemas[name] = schema } diff --git a/terraform/terraform_test.go b/terraform/terraform_test.go index d9424a4f07..92fcb5807a 100644 --- a/terraform/terraform_test.go +++ b/terraform/terraform_test.go @@ -512,7 +512,7 @@ const testTerraformApplyModuleBoolStr = ` aws_instance.bar: ID = foo provider = provider.aws - foo = 1 + foo = true type = aws_instance Dependencies: @@ -522,7 +522,7 @@ module.child: Outputs: - leader = 1 + leader = true ` const testTerraformApplyModuleDestroyOrderStr = ` @@ -566,6 +566,7 @@ module.child: const testTerraformApplyModuleVarRefExistingStr = ` aws_instance.foo: ID = foo + provider = provider.aws foo = bar module.child: @@ -724,7 +725,7 @@ aws_instance.bar: aws_instance.foo: ID = foo provider = provider.aws - num = 2 + value = 2 ` const testTerraformApplyErrorCreateBeforeDestroyStr = ` @@ -751,7 +752,7 @@ aws_instance.bar: aws_instance.foo: ID = foo provider = provider.aws - num = 2 + value = 2 ` const testTerraformApplyResourceDependsOnModuleStr = ` diff --git a/terraform/test-fixtures/apply-destroy-cross-providers/main.tf b/terraform/test-fixtures/apply-destroy-cross-providers/main.tf index b0595b9e81..1ff123a73b 100644 --- a/terraform/test-fixtures/apply-destroy-cross-providers/main.tf +++ b/terraform/test-fixtures/apply-destroy-cross-providers/main.tf @@ -1,6 +1,7 @@ -resource "terraform_remote_state" "shared" {} +resource "aws_instance" "shared" { +} module "child" { source = "./child" - value = "${terraform_remote_state.shared.output.env_name}" + value = "${aws_instance.shared.id}" } diff --git a/terraform/test-fixtures/apply-destroy-targeted-count/main.tf b/terraform/test-fixtures/apply-destroy-targeted-count/main.tf index f4fba3c059..680d30ffaa 100644 --- a/terraform/test-fixtures/apply-destroy-targeted-count/main.tf +++ b/terraform/test-fixtures/apply-destroy-targeted-count/main.tf @@ -3,5 +3,5 @@ resource "aws_instance" "foo" { } resource "aws_instance" "bar" { - instances = ["${aws_instance.foo.*.id}"] + foo = ["${aws_instance.foo.*.id}"] } diff --git a/terraform/test-fixtures/apply-good/main.tf b/terraform/test-fixtures/apply-good/main.tf index b07fc97f4d..5c22c19d10 100644 --- a/terraform/test-fixtures/apply-good/main.tf +++ b/terraform/test-fixtures/apply-good/main.tf @@ -1,5 +1,5 @@ resource "aws_instance" "foo" { - num = "2" + num = 2 } resource "aws_instance" "bar" { diff --git a/terraform/test-fixtures/apply-interpolated-count/main.tf b/terraform/test-fixtures/apply-interpolated-count/main.tf index c4ed06dc70..527a0b8420 100644 --- a/terraform/test-fixtures/apply-interpolated-count/main.tf +++ b/terraform/test-fixtures/apply-interpolated-count/main.tf @@ -7,5 +7,5 @@ resource "aws_instance" "test" { } resource "aws_instance" "dependent" { - count = "${aws_instance.test.count}" + count = "${length(aws_instance.test)}" } diff --git a/terraform/test-fixtures/apply-map-var-through-module/amodule/main.tf b/terraform/test-fixtures/apply-map-var-through-module/amodule/main.tf index 133ac62fcf..ce2cc8c782 100644 --- a/terraform/test-fixtures/apply-map-var-through-module/amodule/main.tf +++ b/terraform/test-fixtures/apply-map-var-through-module/amodule/main.tf @@ -5,5 +5,5 @@ variable "amis" { resource "null_resource" "noop" {} output "amis_out" { - value = "${var.amis}" + value = "${var.amis}" } diff --git a/terraform/test-fixtures/apply-module-provider-inherit-alias-orphan/main.tf b/terraform/test-fixtures/apply-module-provider-inherit-alias-orphan/main.tf index b0b563c93c..d41436803d 100644 --- a/terraform/test-fixtures/apply-module-provider-inherit-alias-orphan/main.tf +++ b/terraform/test-fixtures/apply-module-provider-inherit-alias-orphan/main.tf @@ -1,5 +1,5 @@ provider "aws" { - root = "1" + root = 1 } provider "aws" { diff --git a/terraform/test-fixtures/apply-module-provider-inherit-alias/main.tf b/terraform/test-fixtures/apply-module-provider-inherit-alias/main.tf index 82837cd6d5..0db8243472 100644 --- a/terraform/test-fixtures/apply-module-provider-inherit-alias/main.tf +++ b/terraform/test-fixtures/apply-module-provider-inherit-alias/main.tf @@ -1,5 +1,5 @@ provider "aws" { - root = "1" + root = 1 } provider "aws" { @@ -9,4 +9,7 @@ provider "aws" { module "child" { source = "./child" + providers = { + "aws.eu" = "aws.eu" + } } diff --git a/terraform/test-fixtures/apply-module-var-resource-count/child/main.tf b/terraform/test-fixtures/apply-module-var-resource-count/child/main.tf index e624b53a66..1a19910e8f 100644 --- a/terraform/test-fixtures/apply-module-var-resource-count/child/main.tf +++ b/terraform/test-fixtures/apply-module-var-resource-count/child/main.tf @@ -1,5 +1,6 @@ -variable "count" {} +variable "num" { +} resource "aws_instance" "foo" { - count = "${var.count}" + count = "${var.num}" } diff --git a/terraform/test-fixtures/apply-module-var-resource-count/main.tf b/terraform/test-fixtures/apply-module-var-resource-count/main.tf index 1afaeb7582..6f7d20c48b 100644 --- a/terraform/test-fixtures/apply-module-var-resource-count/main.tf +++ b/terraform/test-fixtures/apply-module-var-resource-count/main.tf @@ -1,6 +1,7 @@ -variable "count" {} +variable "num" { +} module "child" { source = "./child" - count = "${var.count}" + num = "${var.num}" } diff --git a/terraform/test-fixtures/apply-multi-provider-destroy-child/main.tf b/terraform/test-fixtures/apply-multi-provider-destroy-child/main.tf index 61e69e8169..9b799979b1 100644 --- a/terraform/test-fixtures/apply-multi-provider-destroy-child/main.tf +++ b/terraform/test-fixtures/apply-multi-provider-destroy-child/main.tf @@ -1,7 +1,7 @@ resource "vault_instance" "foo" {} provider "aws" { - addr = "${vault_instance.foo.id}" + value = "${vault_instance.foo.id}" } module "child" { diff --git a/terraform/test-fixtures/apply-multi-var-comprehensive/child/child.tf b/terraform/test-fixtures/apply-multi-var-comprehensive/child/child.tf index e208ea6f5e..5355c79941 100644 --- a/terraform/test-fixtures/apply-multi-var-comprehensive/child/child.tf +++ b/terraform/test-fixtures/apply-multi-var-comprehensive/child/child.tf @@ -1,5 +1,4 @@ - -variable "count" { +variable "num" { } variable "source_ids" { @@ -11,7 +10,7 @@ variable "source_names" { } resource "test_thing" "multi_count_var" { - count = "${var.count}" + count = "${var.num}" # Can pluck a single item out of a multi-var source_id = "${var.source_ids[count.index]}" diff --git a/terraform/test-fixtures/apply-multi-var-comprehensive/root.tf b/terraform/test-fixtures/apply-multi-var-comprehensive/root.tf index b0da725352..495d53b01a 100644 --- a/terraform/test-fixtures/apply-multi-var-comprehensive/root.tf +++ b/terraform/test-fixtures/apply-multi-var-comprehensive/root.tf @@ -1,16 +1,15 @@ - -variable "count" { +variable "num" { } resource "test_thing" "source" { - count = "${var.count}" + count = "${var.num}" # The diffFunc in the test exports "name" here too, which we can use # to test values that are known during plan. } resource "test_thing" "multi_count_var" { - count = "${var.count}" + count = "${var.num}" # Can pluck a single item out of a multi-var source_id = "${test_thing.source.*.id[count.index]}" @@ -53,7 +52,7 @@ resource "test_thing" "whole_splat" { module "child" { source = "./child" - count = "${var.count}" + count = "${var.num}" source_ids = "${test_thing.source.*.id}" source_names = "${test_thing.source.*.name}" } diff --git a/terraform/test-fixtures/apply-multi-var-count-dec/main.tf b/terraform/test-fixtures/apply-multi-var-count-dec/main.tf index ab820b5cf2..c69ec500bd 100644 --- a/terraform/test-fixtures/apply-multi-var-count-dec/main.tf +++ b/terraform/test-fixtures/apply-multi-var-count-dec/main.tf @@ -1,7 +1,7 @@ -variable "count" {} +variable "num" {} resource "aws_instance" "foo" { - count = "${var.count}" + count = "${var.num}" value = "foo" } diff --git a/terraform/test-fixtures/apply-multi-var-order-interp/main.tf b/terraform/test-fixtures/apply-multi-var-order-interp/main.tf index d4abcefdbd..6cc2e29d9a 100644 --- a/terraform/test-fixtures/apply-multi-var-order-interp/main.tf +++ b/terraform/test-fixtures/apply-multi-var-order-interp/main.tf @@ -1,14 +1,14 @@ -variable "count" { +variable "num" { default = 15 } resource "aws_instance" "bar" { - count = "${var.count}" + count = "${var.num}" foo = "index-${count.index}" } resource "aws_instance" "baz" { - count = "${var.count}" + count = "${var.num}" foo = "baz-${element(aws_instance.bar.*.foo, count.index)}" } diff --git a/terraform/test-fixtures/apply-multi-var-order/main.tf b/terraform/test-fixtures/apply-multi-var-order/main.tf index a5c9698e2a..7ffefb6f34 100644 --- a/terraform/test-fixtures/apply-multi-var-order/main.tf +++ b/terraform/test-fixtures/apply-multi-var-order/main.tf @@ -1,9 +1,9 @@ -variable "count" { +variable "num" { default = 15 } resource "aws_instance" "bar" { - count = "${var.count}" + count = "${var.num}" foo = "index-${count.index}" } diff --git a/terraform/test-fixtures/apply-multi-var/main.tf b/terraform/test-fixtures/apply-multi-var/main.tf index 22eb1988ea..6d44b96f16 100644 --- a/terraform/test-fixtures/apply-multi-var/main.tf +++ b/terraform/test-fixtures/apply-multi-var/main.tf @@ -1,8 +1,8 @@ -variable "count" {} +variable "num" {} resource "aws_instance" "bar" { foo = "bar${count.index}" - count = "${var.count}" + count = "${var.num}" } output "output" { diff --git a/terraform/test-fixtures/apply-provisioner-conninfo/main.tf b/terraform/test-fixtures/apply-provisioner-conninfo/main.tf index 029895fa19..b1fb5d70b0 100644 --- a/terraform/test-fixtures/apply-provisioner-conninfo/main.tf +++ b/terraform/test-fixtures/apply-provisioner-conninfo/main.tf @@ -1,5 +1,8 @@ -variable "pass" {} -variable "value" {} +variable "pass" { +} + +variable "value" { +} resource "aws_instance" "foo" { num = "2" @@ -17,7 +20,7 @@ resource "aws_instance" "bar" { connection { user = "superuser" port = 2222 - pass = "${var.pass}" + password = "${var.pass}" } } } diff --git a/terraform/test-fixtures/apply-provisioner-interp-count/provisioner-interp-count.tf b/terraform/test-fixtures/apply-provisioner-interp-count/provisioner-interp-count.tf index f6457a3dd3..236325d59c 100644 --- a/terraform/test-fixtures/apply-provisioner-interp-count/provisioner-interp-count.tf +++ b/terraform/test-fixtures/apply-provisioner-interp-count/provisioner-interp-count.tf @@ -1,9 +1,9 @@ -variable "count" { +variable "num" { default = 3 } resource "aws_instance" "a" { - count = "${var.count}" + count = "${var.num}" } resource "aws_instance" "b" { diff --git a/terraform/test-fixtures/issue-5254/step-1/main.tf b/terraform/test-fixtures/issue-5254/step-1/main.tf index e1d3bbac9a..c30446c5aa 100644 --- a/terraform/test-fixtures/issue-5254/step-1/main.tf +++ b/terraform/test-fixtures/issue-5254/step-1/main.tf @@ -1,4 +1,6 @@ -variable "c" { default = 1 } +variable "c" { + default = 1 +} resource "template_file" "parent" { count = "${var.c}"