diff --git a/helper/diff/resource_builder.go b/helper/diff/resource_builder.go index 7fe565ac6..69a0e93ee 100644 --- a/helper/diff/resource_builder.go +++ b/helper/diff/resource_builder.go @@ -108,6 +108,13 @@ func (b *ResourceBuilder) Diff( Type: terraform.DiffAttrOutput, } } + + // The ID will change + attrs["id"] = &terraform.ResourceAttrDiff{ + Old: s.ID, + NewComputed: true, + Type: terraform.DiffAttrOutput, + } } // Build our resulting diff if we had attributes change diff --git a/helper/diff/resource_builder_test.go b/helper/diff/resource_builder_test.go index d62f674a3..1ac408b51 100644 --- a/helper/diff/resource_builder_test.go +++ b/helper/diff/resource_builder_test.go @@ -202,18 +202,22 @@ const testRBComplexDiff = `UPDATE const testRBNewDiff = `UPDATE IN foo: "" => "bar" + OUT id: "" => "" OUT private_ip: "" => "" ` const testRBRequiresNewDiff = `CREATE IN ami: "foo" => "bar" (forces new resource) + OUT id: "1" => "" OUT private_ip: "127.0.0.1" => "" ` const testRBUnknownDiff = `UPDATE IN foo: "" => "${var.unknown}" + OUT id: "" => "" ` const testRBVarsDiff = `UPDATE IN foo: "" => "bar" + OUT id: "" => "" ` diff --git a/terraform/terraform_test.go b/terraform/terraform_test.go index 91f1e1990..0ba3b6b83 100644 --- a/terraform/terraform_test.go +++ b/terraform/terraform_test.go @@ -222,7 +222,23 @@ UPDATE: aws_instance.bar foo: "" => "" type: "" => "aws_instance" UPDATE: aws_instance.foo - id: "" => "" + foo: "" => "" + num: "" => "2" + type: "" => "aws_instance" + +STATE: + + +` + +const testTerraformPlanComputedIdStr = ` +DIFF: + +UPDATE: aws_instance.bar + foo: "" => "" + type: "" => "aws_instance" +UPDATE: aws_instance.foo + foo: "" => "" num: "" => "2" type: "" => "aws_instance" diff --git a/terraform/test-fixtures/plan-computed/main.tf b/terraform/test-fixtures/plan-computed/main.tf index 6f886cb62..a9dfe01ee 100644 --- a/terraform/test-fixtures/plan-computed/main.tf +++ b/terraform/test-fixtures/plan-computed/main.tf @@ -1,8 +1,8 @@ resource "aws_instance" "foo" { num = "2" - compute = "id" + compute = "foo" } resource "aws_instance" "bar" { - foo = "${aws_instance.foo.id}" + foo = "${aws_instance.foo.foo}" }