diff --git a/terraform/context_input_test.go b/terraform/context_input_test.go index 49a2ead7f..b1bb9c0d6 100644 --- a/terraform/context_input_test.go +++ b/terraform/context_input_test.go @@ -24,16 +24,11 @@ func TestContext2Input(t *testing.T) { }, ), Variables: InputValues{ - "foo": &InputValue{ - Value: cty.StringVal("us-west-2"), - SourceType: ValueFromCaller, - }, "amis": &InputValue{ - Value: cty.ListVal([]cty.Value{ - cty.MapVal(map[string]cty.Value{ - "us-east-1": cty.StringVal("override"), - }), + Value: cty.MapVal(map[string]cty.Value{ + "us-east-1": cty.StringVal("override"), }), + SourceType: ValueFromCaller, }, }, UIInput: input, @@ -43,17 +38,17 @@ func TestContext2Input(t *testing.T) { "var.foo": "us-east-1", } - if err := ctx.Input(InputModeStd); err != nil { - t.Fatalf("err: %s", err) + if diags := ctx.Input(InputModeStd | InputModeVarUnset); diags.HasErrors() { + t.Fatalf("input errors: %s", diags.Err()) } - if _, err := ctx.Plan(); err != nil { - t.Fatalf("err: %s", err) + if _, diags := ctx.Plan(); diags.HasErrors() { + t.Fatalf("plan errors: %s", diags.Err()) } - state, err := ctx.Apply() - if err != nil { - t.Fatalf("err: %s", err) + state, diags := ctx.Apply() + if diags.HasErrors() { + t.Fatalf("apply errors: %s", diags.Err()) } actual := strings.TrimSpace(state.String()) diff --git a/terraform/test-fixtures/input-vars/main.tf b/terraform/test-fixtures/input-vars/main.tf index 9c2d0b67d..905f5d75c 100644 --- a/terraform/test-fixtures/input-vars/main.tf +++ b/terraform/test-fixtures/input-vars/main.tf @@ -1,22 +1,21 @@ variable "amis" { - default = { - us-east-1 = "foo" - us-west-2 = "bar" - } + default = { + us-west-2 = "bar" + } } variable "bar" { - default = "baz" + default = "baz" } variable "foo" {} resource "aws_instance" "foo" { - num = "2" - bar = "${var.bar}" + num = "2" + bar = var.bar } resource "aws_instance" "bar" { - foo = "${var.foo}" - bar = "${lookup(var.amis, var.foo)}" + foo = var.foo + bar = var.amis[var.foo] }