From f76c1ec9211a7a517d6fdbd1167814baa6ff2bbf Mon Sep 17 00:00:00 2001 From: James Nugent Date: Mon, 1 Aug 2016 18:54:17 -0500 Subject: [PATCH] provider/aws: Fix aws_route53_record 0-2 migration (#7907) When migrating the state of an `aws_route53_record`, a v0 state was never upgraded to v2, and a typo in a unit test masked this. This commit fixes the migration by chaining the invocation of the migration function, and corrects the test. --- .../providers/aws/resource_aws_route53_record_migrate.go | 8 ++++++-- .../aws/resource_aws_route53_record_migrate_test.go | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/builtin/providers/aws/resource_aws_route53_record_migrate.go b/builtin/providers/aws/resource_aws_route53_record_migrate.go index 5e81b5933..ad6cda9d3 100644 --- a/builtin/providers/aws/resource_aws_route53_record_migrate.go +++ b/builtin/providers/aws/resource_aws_route53_record_migrate.go @@ -12,8 +12,12 @@ func resourceAwsRoute53RecordMigrateState( v int, is *terraform.InstanceState, meta interface{}) (*terraform.InstanceState, error) { switch v { case 0: - log.Println("[INFO] Found AWS Route53 Record State v0; migrating to v1") - return migrateRoute53RecordStateV0toV1(is) + log.Println("[INFO] Found AWS Route53 Record State v0; migrating to v1 then v2") + v1InstanceState, err := migrateRoute53RecordStateV0toV1(is) + if err != nil { + return v1InstanceState, err + } + return migrateRoute53RecordStateV1toV2(v1InstanceState) case 1: log.Println("[INFO] Found AWS Route53 Record State v1; migrating to v2") return migrateRoute53RecordStateV1toV2(is) diff --git a/builtin/providers/aws/resource_aws_route53_record_migrate_test.go b/builtin/providers/aws/resource_aws_route53_record_migrate_test.go index 672b51761..6efe0a4fa 100644 --- a/builtin/providers/aws/resource_aws_route53_record_migrate_test.go +++ b/builtin/providers/aws/resource_aws_route53_record_migrate_test.go @@ -79,7 +79,7 @@ func TestAWSRoute53RecordMigrateStateV1toV2(t *testing.T) { }, }, "v0_2": { - StateVersion: 1, + StateVersion: 0, Attributes: map[string]string{ "weight": "-1", },