Repository: GoogleCloudPlatform/terraform-validator
Pull request #260 (2021-07-20 23:02:26)

Run read tests as part of `make test`
Resolved https://github.com/GoogleCloudPlatform/terraform-validator/issues/258. I made it so that the read tests are considered unit tests, and get run as part of `make test`. There are a few separate types of fixes that I had to make to get things passing:

- Updated plan JSON that was out of date or incorrect in various ways, such as:
  - declaring fields which have since been marked incompatible in the terraform provider
  - not marking all the resources to be validated as changed
- Removed tests that don't work without online mode. (read tests are all run in offline mode.)
- Fixed marshalling/unmarshalling of timestamps. (Note: I'm not sure we actually _want_ the current behavior, but now it is at least consistent and tested.)


Patch:
diff --git a/converters/google/convert.go b/converters/google/convert.go
index d8c8a235..1abe1811 100644
--- a/converters/google/convert.go
+++ b/converters/google/convert.go
@@ -85,10 +85,10 @@ type Timestamp struct {
 }
 
 func (t Timestamp) MarshalJSON() ([]byte, error) {
-	return []byte(`"` + time.Unix(t.Seconds, t.Nanos).Format(time.RFC3339Nano) + `"`), nil
+	return []byte(`"` + time.Unix(0, t.Nanos).UTC().Format(time.RFC3339Nano) + `"`), nil
 }
 
-func (t Timestamp) UnmarshalJSON(b []byte) error {
+func (t *Timestamp) UnmarshalJSON(b []byte) error {
 	p, err := time.Parse(time.RFC3339Nano, strings.Trim(string(b), `"`))
 	if err != nil {
 		return fmt.Errorf("bad Timestamp: %v", err)


Test patch:
diff --git a/converters/google/convert_test.go b/converters/google/convert_test.go
index c67db287..f7877483 100644
--- a/converters/google/convert_test.go
+++ b/converters/google/convert_test.go
@@ -18,6 +18,7 @@ import (
 	"context"
 	"sort"
 	"testing"
+	"time"
 
 	"github.com/GoogleCloudPlatform/terraform-validator/ancestrymanager"
 	tfjson "github.com/hashicorp/terraform-json"
@@ -401,3 +402,32 @@ func TestAddStorageModuleAfterUnknown(t *testing.T) {
 	}
 
 }
+
+func TestTimestampMarshalJSON(t *testing.T) {
+	expectedJSON := []byte("\"2021-04-14T15:16:17Z\"")
+	date := time.Date(2021, time.April, 14, 15, 16, 17, 0, time.UTC)
+	ts := Timestamp{
+		Seconds: int64(date.Unix()),
+		Nanos: int64(date.UnixNano()),
+	}
+	json, err := ts.MarshalJSON()
+	if err != nil {
+		t.Fatalf("Unexpected error: %s", err)
+	}
+	assert.EqualValues(t, json, expectedJSON)
+}
+
+func TestTimestampUnmarshalJSON(t *testing.T) {
+	expectedDate := time.Date(2021, time.April, 14, 15, 16, 17, 0, time.UTC)
+	expected := Timestamp{
+		Seconds: int64(expectedDate.Unix()),
+		Nanos: int64(expectedDate.UnixNano()),
+	}
+	json := []byte("\"2021-04-14T15:16:17Z\"")
+	ts := Timestamp{}
+	err := ts.UnmarshalJSON(json)
+	if err != nil {
+		t.Fatalf("Unexpected error: %s", err)
+	}
+	assert.EqualValues(t, ts, expected)
+}
diff --git a/test/read_test.go b/test/read_test.go
index 43abbb9e..60fb90d2 100644
--- a/test/read_test.go
+++ b/test/read_test.go
@@ -16,11 +16,6 @@ import (
 )
 
 func TestReadPlannedAssetsCoverage(t *testing.T) {
-	if testing.Short() {
-		t.Skip("skipping integration test in short mode.")
-		return
-	}
-
 	cases := []struct {
 		name string
 	}{
@@ -28,10 +23,12 @@ func TestReadPlannedAssetsCoverage(t *testing.T) {
 		{name: "example_bigtable_instance"},
 		{name: "example_compute_disk"},
 		{name: "example_compute_firewall"},
-		{name: "example_compute_instance"},
+		// This test can't run in offline mode
+		// {name: "example_compute_instance"},
 		{name: "example_compute_network"},
 		{name: "example_compute_subnetwork"},
-		{name: "example_compute_forwarding_rule"},
+		// This test can't run in offline mode.
+		// {name: "example_compute_forwarding_rule"},
 		{name: "example_compute_global_forwarding_rule"},
 		{name: "example_container_cluster"},
 		{name: "example_filestore_instance"},
diff --git a/testdata/templates/example_compute_forwarding_rule.tfplan.json b/testdata/templates/example_compute_forwarding_rule.tfplan.json
deleted file mode 100644
index 104c1a5c..00000000
--- a/testdata/templates/example_compute_forwarding_rule.tfplan.json
+++ /dev/null
@@ -1,118 +0,0 @@
-{
-  "format_version": "0.1",
-  "terraform_version": "0.13.5",
-  "planned_values": {
-    "root_module": {
-      "resources": [
-        {
-          "address": "google_compute_forwarding_rule.default",
-          "mode": "managed",
-          "type": "google_compute_forwarding_rule",
-          "name": "default",
-          "provider_name": "registry.terraform.io/hashicorp/google",
-          "schema_version": 0,
-          "values": {
-            "all_ports": null,
-            "allow_global_access": null,
-            "backend_service": "test-backend-service-id",
-            "description": null,
-            "ip_protocol": "TCP",
-            "load_balancing_scheme": "INTERNAL_MANAGED",
-            "name": "test-forwarding-rule",
-            "port_range": "80",
-            "ports": null,
-            "region": "australia-southeast1",
-            "service_label": null,
-            "target": null,
-            "timeouts": null
-          }
-        }
-      ]
-    }
-  },
-  "resource_changes": [
-    {
-      "address": "google_compute_forwarding_rule.default",
-      "mode": "managed",
-      "type": "google_compute_forwarding_rule",
-      "name": "default",
-      "provider_name": "registry.terraform.io/hashicorp/google",
-      "change": {
-        "actions": [
-          "create"
-        ],
-        "before": null,
-        "after": {
-          "all_ports": null,
-          "allow_global_access": null,
-          "backend_service": "test-backend-service-id",
-          "description": null,
-          "ip_protocol": "TCP",
-          "load_balancing_scheme": "INTERNAL_MANAGED",
-          "name": "test-forwarding-rule",
-          "port_range": "80",
-          "ports": null,
-          "region": "australia-southeast1",
-          "service_label": null,
-          "target": null,
-          "timeouts": null
-        },
-        "after_unknown": {
-          "creation_timestamp": true,
-          "id": true,
-          "ip_address": true,
-          "network": true,
-          "network_tier": true,
-          "project": true,
-          "self_link": true,
-          "service_name": true,
-          "subnetwork": true
-        }
-      }
-    }
-  ],
-  "configuration": {
-    "provider_config": {
-      "google": {
-        "name": "google",
-        "expressions": {
-          "project": {
-            "constant_value": "{{.Provider.project}}"
-          }
-        }
-      }
-    },
-    "root_module": {
-      "resources": [
-        {
-          "address": "google_compute_forwarding_rule.default",
-          "mode": "managed",
-          "type": "google_compute_forwarding_rule",
-          "name": "default",
-          "provider_config_key": "google",
-          "expressions": {
-            "backend_service": {
-              "constant_value": "test-backend-service-id"
-            },
-            "ip_protocol": {
-              "constant_value": "TCP"
-            },
-            "load_balancing_scheme": {
-              "constant_value": "INTERNAL_MANAGED"
-            },
-            "name": {
-              "constant_value": "test-forwarding-rule"
-            },
-            "port_range": {
-              "constant_value": 80
-            },
-            "region": {
-              "constant_value": "australia-southeast1"
-            }
-          },
-          "schema_version": 0
-        }
-      ]
-    }
-  }
-}
\ No newline at end of file
diff --git a/testdata/templates/example_compute_instance.tfplan.json b/testdata/templates/example_compute_instance.tfplan.json
deleted file mode 100644
index bd00c58b..00000000
--- a/testdata/templates/example_compute_instance.tfplan.json
+++ /dev/null
@@ -1,354 +0,0 @@
-{
-  "format_version": "0.1",
-  "terraform_version": "0.14.2",
-  "planned_values": {
-    "root_module": {
-      "resources": [
-        {
-          "address": "google_compute_instance.default",
-          "mode": "managed",
-          "type": "google_compute_instance",
-          "name": "default",
-          "provider_name": "registry.terraform.io/hashicorp/google",
-          "schema_version": 6,
-          "values": {
-            "allow_stopping_for_update": null,
-            "attached_disk": [],
-            "boot_disk": [
-              {
-                "auto_delete": true,
-                "disk_encryption_key_raw": null,
-                "initialize_params": [
-                  {
-                    "image": "debian-cloud/debian-9"
-                  }
-                ],
-                "mode": "READ_WRITE"
-              }
-            ],
-            "can_ip_forward": false,
-            "deletion_protection": false,
-            "description": null,
-            "desired_status": null,
-            "enable_display": null,
-            "hostname": null,
-            "labels": null,
-            "machine_type": "n1-standard-1",
-            "metadata": {
-              "foo": "bar"
-            },
-            "metadata_startup_script": null,
-            "name": "test",
-            "network_interface": [
-              {
-                "access_config": [
-                  {
-                    "public_ptr_domain_name": null
-                  }
-                ],
-                "alias_ip_range": [],
-                "network": "default"
-              }
-            ],
-            "resource_policies": null,
-            "scratch_disk": [
-              {
-                "interface": "SCSI"
-              }
-            ],
-            "service_account": [
-              {
-                "scopes": [
-                  "https://www.googleapis.com/auth/cloud-platform"
-                ]
-              }
-            ],
-            "shielded_instance_config": [],
-            "tags": [
-              "bar",
-              "foo"
-            ],
-            "timeouts": null,
-            "zone": "us-central1-a"
-          }
-        },
-        {
-          "address": "google_service_account.default",
-          "mode": "managed",
-          "type": "google_service_account",
-          "name": "default",
-          "provider_name": "registry.terraform.io/hashicorp/google",
-          "schema_version": 0,
-          "values": {
-            "account_id": "service-account-id",
-            "description": null,
-            "display_name": "Service Account",
-            "timeouts": null
-          }
-        }
-      ]
-    }
-  },
-  "resource_changes": [
-    {
-      "address": "google_compute_instance.default",
-      "mode": "managed",
-      "type": "google_compute_instance",
-      "name": "default",
-      "provider_name": "registry.terraform.io/hashicorp/google",
-      "change": {
-        "actions": [
-          "create"
-        ],
-        "before": null,
-        "after": {
-          "allow_stopping_for_update": null,
-          "attached_disk": [],
-          "boot_disk": [
-            {
-              "auto_delete": true,
-              "disk_encryption_key_raw": null,
-              "initialize_params": [
-                {
-                  "image": "debian-cloud/debian-9"
-                }
-              ],
-              "mode": "READ_WRITE"
-            }
-          ],
-          "can_ip_forward": false,
-          "deletion_protection": false,
-          "description": null,
-          "desired_status": null,
-          "enable_display": null,
-          "hostname": null,
-          "labels": null,
-          "machine_type": "n1-standard-1",
-          "metadata": {
-            "foo": "bar"
-          },
-          "metadata_startup_script": null,
-          "name": "test",
-          "network_interface": [
-            {
-              "access_config": [
-                {
-                  "public_ptr_domain_name": null
-                }
-              ],
-              "alias_ip_range": [],
-              "network": "default"
-            }
-          ],
-          "resource_policies": null,
-          "scratch_disk": [
-            {
-              "interface": "SCSI"
-            }
-          ],
-          "service_account": [
-            {
-              "scopes": [
-                "https://www.googleapis.com/auth/cloud-platform"
-              ]
-            }
-          ],
-          "shielded_instance_config": [],
-          "tags": [
-            "bar",
-            "foo"
-          ],
-          "timeouts": null,
-          "zone": "us-central1-a"
-        },
-        "after_unknown": {
-          "attached_disk": [],
-          "boot_disk": [
-            {
-              "device_name": true,
-              "disk_encryption_key_sha256": true,
-              "initialize_params": [
-                {
-                  "labels": true,
-                  "size": true,
-                  "type": true
-                }
-              ],
-              "kms_key_self_link": true,
-              "source": true
-            }
-          ],
-          "cpu_platform": true,
-          "current_status": true,
-          "guest_accelerator": true,
-          "id": true,
-          "instance_id": true,
-          "label_fingerprint": true,
-          "metadata": {},
-          "metadata_fingerprint": true,
-          "min_cpu_platform": true,
-          "network_interface": [
-            {
-              "access_config": [
-                {
-                  "nat_ip": true,
-                  "network_tier": true
-                }
-              ],
-              "alias_ip_range": [],
-              "name": true,
-              "network_ip": true,
-              "subnetwork": true,
-              "subnetwork_project": true
-            }
-          ],
-          "project": true,
-          "scheduling": true,
-          "scratch_disk": [
-            {}
-          ],
-          "self_link": true,
-          "service_account": [
-            {
-              "email": true,
-              "scopes": [
-                false
-              ]
-            }
-          ],
-          "shielded_instance_config": [],
-          "tags": [
-            false,
-            false
-          ],
-          "tags_fingerprint": true
-        }
-      }
-    },
-    {
-      "address": "google_service_account.default",
-      "mode": "managed",
-      "type": "google_service_account",
-      "name": "default",
-      "provider_name": "registry.terraform.io/hashicorp/google",
-      "change": {
-        "actions": [
-          "create"
-        ],
-        "before": null,
-        "after": {
-          "account_id": "service-account-id",
-          "description": null,
-          "display_name": "Service Account",
-          "timeouts": null
-        },
-        "after_unknown": {
-          "email": true,
-          "id": true,
-          "name": true,
-          "project": true,
-          "unique_id": true
-        }
-      }
-    }
-  ],
-  "configuration": {
-    "provider_config": {
-      "google": {
-        "name": "google"
-      }
-    },
-    "root_module": {
-      "resources": [
-        {
-          "address": "google_compute_instance.default",
-          "mode": "managed",
-          "type": "google_compute_instance",
-          "name": "default",
-          "provider_config_key": "google",
-          "expressions": {
-            "boot_disk": [
-              {
-                "initialize_params": [
-                  {
-                    "image": {
-                      "constant_value": "debian-cloud/debian-9"
-                    }
-                  }
-                ]
-              }
-            ],
-            "machine_type": {
-              "constant_value": "n1-standard-1"
-            },
-            "metadata": {
-              "constant_value": {
-                "foo": "bar"
-              }
-            },
-            "name": {
-              "constant_value": "test"
-            },
-            "network_interface": [
-              {
-                "access_config": [
-                  {}
-                ],
-                "network": {
-                  "constant_value": "default"
-                }
-              }
-            ],
-            "scratch_disk": [
-              {
-                "interface": {
-                  "constant_value": "SCSI"
-                }
-              }
-            ],
-            "service_account": [
-              {
-                "email": {
-                  "references": [
-                    "google_service_account.default"
-                  ]
-                },
-                "scopes": {
-                  "constant_value": [
-                    "cloud-platform"
-                  ]
-                }
-              }
-            ],
-            "tags": {
-              "constant_value": [
-                "foo",
-                "bar"
-              ]
-            },
-            "zone": {
-              "constant_value": "us-central1-a"
-            }
-          },
-          "schema_version": 6
-        },
-        {
-          "address": "google_service_account.default",
-          "mode": "managed",
-          "type": "google_service_account",
-          "name": "default",
-          "provider_config_key": "google",
-          "expressions": {
-            "account_id": {
-              "constant_value": "service-account-id"
-            },
-            "display_name": {
-              "constant_value": "Service Account"
-            }
-          },
-          "schema_version": 0
-        }
-      ]
-    }
-  }
-}
diff --git a/testdata/templates/example_project_organization_policy.tfplan.json b/testdata/templates/example_project_organization_policy.tfplan.json
index 21c1b610..be9e8833 100644
--- a/testdata/templates/example_project_organization_policy.tfplan.json
+++ b/testdata/templates/example_project_organization_policy.tfplan.json
@@ -1,6 +1,6 @@
 {
   "format_version": "0.1",
-  "terraform_version": "0.12.29",
+  "terraform_version": "0.13.6",
   "planned_values": {
     "root_module": {
       "resources": [
@@ -9,7 +9,7 @@
           "mode": "managed",
           "type": "google_project_organization_policy",
           "name": "serial_port_policy",
-          "provider_name": "google",
+          "provider_name": "registry.terraform.io/hashicorp/google",
           "schema_version": 0,
           "values": {
             "boolean_policy": [
@@ -17,15 +17,11 @@
                 "enforced": true
               }
             ],
-            "constraint": "constraints/compute.disableSerialPortAccess",
-            "etag": "BwWzWX4t5oA=",
-            "id": "{{.Provider.project}}:compute.disableSerialPortAccess",
+            "constraint": "compute.disableSerialPortAccess",
             "list_policy": [],
             "project": "{{.Provider.project}}",
             "restore_policy": [],
-            "timeouts": null,
-            "update_time": "2020-11-05T10:23:53.808Z",
-            "version": 0
+            "timeouts": null
           }
         },
         {
@@ -33,7 +29,7 @@
           "mode": "managed",
           "type": "google_project_organization_policy",
           "name": "service_account_policy",
-          "provider_name": "google",
+          "provider_name": "registry.terraform.io/hashicorp/google",
           "schema_version": 0,
           "values": {
             "boolean_policy": [],
@@ -53,31 +49,26 @@
           "mode": "managed",
           "type": "google_project_organization_policy",
           "name": "services_policy",
-          "provider_name": "google",
+          "provider_name": "registry.terraform.io/hashicorp/google",
           "schema_version": 0,
           "values": {
             "boolean_policy": [],
-            "constraint": "constraints/serviceuser.services",
-            "etag": "BwWzdbWQlSo=",
-            "id": "{{.Provider.project}}:serviceuser.services",
+            "constraint": "serviceuser.services",
             "list_policy": [
               {
                 "allow": [
                   {
                     "all": true,
-                    "values": []
+                    "values": null
                   }
                 ],
                 "deny": [],
-                "inherit_from_parent": false,
-                "suggested_value": ""
+                "inherit_from_parent": null
               }
             ],
             "project": "{{.Provider.project}}",
             "restore_policy": [],
-            "timeouts": null,
-            "update_time": "2020-11-06T20:03:42.113Z",
-            "version": 0
+            "timeouts": null
           }
         }
       ]
@@ -89,44 +80,35 @@
       "mode": "managed",
       "type": "google_project_organization_policy",
       "name": "serial_port_policy",
-      "provider_name": "google",
+      "provider_name": "registry.terraform.io/hashicorp/google",
       "change": {
         "actions": [
-          "no-op"
+          "create"
         ],
-        "before": {
+        "before": null,
+        "after": {
           "boolean_policy": [
             {
               "enforced": true
             }
           ],
-          "constraint": "constraints/compute.disableSerialPortAccess",
-          "etag": "BwWzWX4t5oA=",
-          "id": "{{.Provider.project}}:compute.disableSerialPortAccess",
+          "constraint": "compute.disableSerialPortAccess",
           "list_policy": [],
           "project": "{{.Provider.project}}",
           "restore_policy": [],
-          "timeouts": null,
-          "update_time": "2020-11-05T10:23:53.808Z",
-          "version": 0
+          "timeouts": null
         },
-        "after": {
+        "after_unknown": {
           "boolean_policy": [
-            {
-              "enforced": true
-            }
+            {}
           ],
-          "constraint": "constraints/compute.disableSerialPortAccess",
-          "etag": "BwWzWX4t5oA=",
-          "id": "{{.Provider.project}}:compute.disableSerialPortAccess",
+          "etag": true,
+          "id": true,
           "list_policy": [],
-          "project": "{{.Provider.project}}",
           "restore_policy": [],
-          "timeouts": null,
-          "update_time": "2020-11-05T10:23:53.808Z",
-          "version": 0
-        },
-        "after_unknown": {}
+          "update_time": true,
+          "version": true
+        }
       }
     },
     {
@@ -134,7 +116,7 @@
       "mode": "managed",
       "type": "google_project_organization_policy",
       "name": "service_account_policy",
-      "provider_name": "google",
+      "provider_name": "registry.terraform.io/hashicorp/google",
       "change": {
         "actions": [
           "create"
@@ -170,129 +152,51 @@
       "mode": "managed",
       "type": "google_project_organization_policy",
       "name": "services_policy",
-      "provider_name": "google",
+      "provider_name": "registry.terraform.io/hashicorp/google",
       "change": {
         "actions": [
-          "no-op"
+          "create"
         ],
-        "before": {
+        "before": null,
+        "after": {
           "boolean_policy": [],
-          "constraint": "constraints/serviceuser.services",
-          "etag": "BwWzdbWQlSo=",
-          "id": "{{.Provider.project}}:serviceuser.services",
+          "constraint": "serviceuser.services",
           "list_policy": [
             {
               "allow": [
                 {
                   "all": true,
-                  "values": []
+                  "values": null
                 }
               ],
               "deny": [],
-              "inherit_from_parent": false,
-              "suggested_value": ""
+              "inherit_from_parent": null
             }
           ],
           "project": "{{.Provider.project}}",
           "restore_policy": [],
-          "timeouts": null,
-          "update_time": "2020-11-06T20:03:42.113Z",
-          "version": 0
+          "timeouts": null
         },
-        "after": {
+        "after_unknown": {
           "boolean_policy": [],
-          "constraint": "constraints/serviceuser.services",
-          "etag": "BwWzdbWQlSo=",
-          "id": "{{.Provider.project}}:serviceuser.services",
+          "etag": true,
+          "id": true,
           "list_policy": [
             {
               "allow": [
-                {
-                  "all": true,
-                  "values": []
-                }
+                {}
               ],
               "deny": [],
-              "inherit_from_parent": false,
-              "suggested_value": ""
+              "suggested_value": true
             }
           ],
-          "project": "{{.Provider.project}}",
           "restore_policy": [],
-          "timeouts": null,
-          "update_time": "2020-11-06T20:03:42.113Z",
-          "version": 0
-        },
-        "after_unknown": {}
+          "update_time": true,
+          "version": true
+        }
       }
     }
   ],
-  "prior_state": {
-    "format_version": "0.1",
-    "terraform_version": "0.12.29",
-    "values": {
-      "root_module": {
-        "resources": [
-          {
-            "address": "google_project_organization_policy.serial_port_policy",
-            "mode": "managed",
-            "type": "google_project_organization_policy",
-            "name": "serial_port_policy",
-            "provider_name": "google",
-            "schema_version": 0,
-            "values": {
-              "boolean_policy": [
-                {
-                  "enforced": true
-                }
-              ],
-              "constraint": "constraints/compute.disableSerialPortAccess",
-              "etag": "BwWzWX4t5oA=",
-              "id": "{{.Provider.project}}:compute.disableSerialPortAccess",
-              "list_policy": [],
-              "project": "{{.Provider.project}}",
-              "restore_policy": [],
-              "timeouts": null,
-              "update_time": "2020-11-05T10:23:53.808Z",
-              "version": 0
-            }
-          },
-          {
-            "address": "google_project_organization_policy.services_policy",
-            "mode": "managed",
-            "type": "google_project_organization_policy",
-            "name": "services_policy",
-            "provider_name": "google",
-            "schema_version": 0,
-            "values": {
-              "boolean_policy": [],
-              "constraint": "constraints/serviceuser.services",
-              "etag": "BwWzdbWQlSo=",
-              "id": "{{.Provider.project}}:serviceuser.services",
-              "list_policy": [
-                {
-                  "allow": [
-                    {
-                      "all": true,
-                      "values": []
-                    }
-                  ],
-                  "deny": [],
-                  "inherit_from_parent": false,
-                  "suggested_value": ""
-                }
-              ],
-              "project": "{{.Provider.project}}",
-              "restore_policy": [],
-              "timeouts": null,
-              "update_time": "2020-11-06T20:03:42.113Z",
-              "version": 0
-            }
-          }
-        ]
-      }
-    }
-  },
   "configuration": {
     "root_module": {
       "resources": [
diff --git a/testdata/templates/example_sql_database_instance.tfplan.json b/testdata/templates/example_sql_database_instance.tfplan.json
index e0054391..b10db75f 100644
--- a/testdata/templates/example_sql_database_instance.tfplan.json
+++ b/testdata/templates/example_sql_database_instance.tfplan.json
@@ -1,6 +1,6 @@
 {
   "format_version": "0.1",
-  "terraform_version": "0.12.10",
+  "terraform_version": "0.13.6",
   "planned_values": {
     "root_module": {
       "resources": [
@@ -9,22 +9,25 @@
           "mode": "managed",
           "type": "google_sql_database_instance",
           "name": "master",
-          "provider_name": "google",
+          "provider_name": "registry.terraform.io/hashicorp/google",
           "schema_version": 0,
           "values": {
+            "clone": [],
             "database_version": "POSTGRES_9_6",
+            "deletion_protection": true,
             "name": "master-instance",
             "region": "us-central1",
+            "restore_backup_context": [],
+            "root_password": null,
             "settings": [
               {
-                "authorized_gae_applications": null,
                 "database_flags": [],
                 "disk_autoresize": true,
+                "disk_autoresize_limit": 0,
+                "insights_config": [],
                 "maintenance_window": [],
                 "pricing_plan": "PER_USE",
-                "replication_type": "SYNCHRONOUS",
-                "tier": "db-f1-micro",
-                "user_labels": null
+                "tier": "db-f1-micro"
               }
             ],
             "timeouts": null
@@ -39,31 +42,35 @@
       "mode": "managed",
       "type": "google_sql_database_instance",
       "name": "master",
-      "provider_name": "google",
+      "provider_name": "registry.terraform.io/hashicorp/google",
       "change": {
         "actions": [
           "create"
         ],
         "before": null,
         "after": {
+          "clone": [],
           "database_version": "POSTGRES_9_6",
+          "deletion_protection": true,
           "name": "master-instance",
           "region": "us-central1",
+          "restore_backup_context": [],
+          "root_password": null,
           "settings": [
             {
-              "authorized_gae_applications": null,
               "database_flags": [],
               "disk_autoresize": true,
+              "disk_autoresize_limit": 0,
+              "insights_config": [],
               "maintenance_window": [],
               "pricing_plan": "PER_USE",
-              "replication_type": "SYNCHRONOUS",
-              "tier": "db-f1-micro",
-              "user_labels": null
+              "tier": "db-f1-micro"
             }
           ],
           "timeouts": null
         },
         "after_unknown": {
+          "clone": [],
           "connection_name": true,
           "first_ip_address": true,
           "id": true,
@@ -73,21 +80,26 @@
           "project": true,
           "public_ip_address": true,
           "replica_configuration": true,
+          "restore_backup_context": [],
           "self_link": true,
           "server_ca_cert": true,
           "service_account_email_address": true,
           "settings": [
             {
               "activation_policy": true,
+              "authorized_gae_applications": true,
               "availability_type": true,
               "backup_configuration": true,
               "crash_safe_replication": true,
               "database_flags": [],
               "disk_size": true,
               "disk_type": true,
+              "insights_config": [],
               "ip_configuration": true,
               "location_preference": true,
               "maintenance_window": [],
+              "replication_type": true,
+              "user_labels": true,
               "version": true
             }
           ]
@@ -96,16 +108,6 @@
     }
   ],
   "configuration": {
-    "provider_config": {
-      "google": {
-        "name": "google",
-        "expressions": {
-          "project": {
-            "constant_value": "{{.Provider.project}}"
-          }
-        }
-      }
-    },
     "root_module": {
       "resources": [
         {
diff --git a/testdata/templates/full_compute_instance.tfplan.json b/testdata/templates/full_compute_instance.tfplan.json
index c61bce9d..bf220f19 100644
--- a/testdata/templates/full_compute_instance.tfplan.json
+++ b/testdata/templates/full_compute_instance.tfplan.json
@@ -1,6 +1,6 @@
 {
   "format_version": "0.1",
-  "terraform_version": "0.12.20",
+  "terraform_version": "0.13.6",
   "planned_values": {
     "root_module": {
       "resources": [
@@ -9,9 +9,10 @@
           "mode": "managed",
           "type": "google_compute_instance",
           "name": "full_list_default_1",
-          "provider_name": "google",
+          "provider_name": "registry.terraform.io/hashicorp/google",
           "schema_version": 6,
           "values": {
+            "advanced_machine_features": [],
             "allow_stopping_for_update": true,
             "attached_disk": [
               {
@@ -46,6 +47,7 @@
             "can_ip_forward": true,
             "deletion_protection": true,
             "description": "test-description",
+            "desired_status": null,
             "enable_display": null,
             "guest_accelerator": [
               {
@@ -90,18 +92,22 @@
                   }
                 ],
                 "network": "default",
-                "network_ip": "test-network_ip"
+                "network_ip": "test-network_ip",
+                "nic_type": null
               },
               {
                 "access_config": [],
                 "alias_ip_range": [],
+                "nic_type": null,
                 "subnetwork": "test-subnetwork",
                 "subnetwork_project": "test-subnetwork_project"
               }
             ],
+            "resource_policies": null,
             "scheduling": [
               {
                 "automatic_restart": true,
+                "min_node_cpus": null,
                 "node_affinities": [
                   {
                     "key": "test-key",
@@ -152,9 +158,10 @@
           "mode": "managed",
           "type": "google_compute_instance",
           "name": "full_list_default_2",
-          "provider_name": "google",
+          "provider_name": "registry.terraform.io/hashicorp/google",
           "schema_version": 6,
           "values": {
+            "advanced_machine_features": [],
             "allow_stopping_for_update": null,
             "attached_disk": [],
             "boot_disk": [
@@ -168,6 +175,7 @@
             "can_ip_forward": false,
             "deletion_protection": false,
             "description": null,
+            "desired_status": null,
             "enable_display": null,
             "hostname": null,
             "labels": null,
@@ -179,9 +187,11 @@
               {
                 "access_config": [],
                 "alias_ip_range": [],
-                "network": "default"
+                "network": "default",
+                "nic_type": null
               }
             ],
+            "resource_policies": null,
             "scratch_disk": [],
             "service_account": [],
             "shielded_instance_config": [],
@@ -199,13 +209,14 @@
       "mode": "managed",
       "type": "google_compute_instance",
       "name": "full_list_default_1",
-      "provider_name": "google",
+      "provider_name": "registry.terraform.io/hashicorp/google",
       "change": {
         "actions": [
           "create"
         ],
         "before": null,
         "after": {
+          "advanced_machine_features": [],
           "allow_stopping_for_update": true,
           "attached_disk": [
             {
@@ -240,6 +251,7 @@
           "can_ip_forward": true,
           "deletion_protection": true,
           "description": "test-description",
+          "desired_status": null,
           "enable_display": null,
           "guest_accelerator": [
             {
@@ -284,18 +296,22 @@
                 }
               ],
               "network": "default",
-              "network_ip": "test-network_ip"
+              "network_ip": "test-network_ip",
+              "nic_type": null
             },
             {
               "access_config": [],
               "alias_ip_range": [],
+              "nic_type": null,
               "subnetwork": "test-subnetwork",
               "subnetwork_project": "test-subnetwork_project"
             }
           ],
+          "resource_policies": null,
           "scheduling": [
             {
               "automatic_restart": true,
+              "min_node_cpus": null,
               "node_affinities": [
                 {
                   "key": "test-key",
@@ -322,9 +338,7 @@
             {
               "email": "test-email",
               "scopes": [
-                "https://www.googleapis.com/auth/compute.readonly",
-                "https://www.googleapis.com/auth/devstorage.read_only",
-                "https://www.googleapis.com/auth/userinfo.email"
+                "https://www.googleapis.com/auth/cloud-platform"
               ]
             }
           ],
@@ -343,6 +357,7 @@
           "zone": "us-central1-a"
         },
         "after_unknown": {
+          "advanced_machine_features": [],
           "attached_disk": [
             {
               "disk_encryption_key_sha256": true
@@ -364,7 +379,9 @@
               "kms_key_self_link": true
             }
           ],
+          "confidential_instance_config": true,
           "cpu_platform": true,
+          "current_status": true,
           "guest_accelerator": [
             {},
             {}
@@ -405,6 +422,7 @@
             }
           ],
           "project": true,
+          "reservation_affinity": true,
           "scheduling": [
             {
               "node_affinities": [
@@ -425,8 +443,6 @@
           "service_account": [
             {
               "scopes": [
-                false,
-                false,
                 false
               ]
             }
@@ -447,13 +463,14 @@
       "mode": "managed",
       "type": "google_compute_instance",
       "name": "full_list_default_2",
-      "provider_name": "google",
+      "provider_name": "registry.terraform.io/hashicorp/google",
       "change": {
         "actions": [
           "create"
         ],
         "before": null,
         "after": {
+          "advanced_machine_features": [],
           "allow_stopping_for_update": null,
           "attached_disk": [],
           "boot_disk": [
@@ -467,6 +484,7 @@
           "can_ip_forward": false,
           "deletion_protection": false,
           "description": null,
+          "desired_status": null,
           "enable_display": null,
           "hostname": null,
           "labels": null,
@@ -478,9 +496,11 @@
             {
               "access_config": [],
               "alias_ip_range": [],
-              "network": "default"
+              "network": "default",
+              "nic_type": null
             }
           ],
+          "resource_policies": null,
           "scratch_disk": [],
           "service_account": [],
           "shielded_instance_config": [],
@@ -489,6 +509,7 @@
           "zone": "us-central1-a"
         },
         "after_unknown": {
+          "advanced_machine_features": [],
           "attached_disk": [],
           "boot_disk": [
             {
@@ -498,7 +519,9 @@
               "source": true
             }
           ],
+          "confidential_instance_config": true,
           "cpu_platform": true,
+          "current_status": true,
           "guest_accelerator": true,
           "id": true,
           "instance_id": true,
@@ -516,6 +539,7 @@
             }
           ],
           "project": true,
+          "reservation_affinity": true,
           "scheduling": true,
           "scratch_disk": [],
           "self_link": true,
@@ -527,16 +551,6 @@
     }
   ],
   "configuration": {
-    "provider_config": {
-      "google": {
-        "name": "google",
-        "expressions": {
-          "project": {
-            "constant_value": "{{.Provider.project}}"
-          }
-        }
-      }
-    },
     "root_module": {
       "resources": [
         {
@@ -723,9 +737,7 @@
                 },
                 "scopes": {
                   "constant_value": [
-                    "userinfo-email",
-                    "compute-ro",
-                    "storage-ro"
+                    "cloud-platform"
                   ]
                 }
               }
diff --git a/testdata/templates/full_container_cluster.tf b/testdata/templates/full_container_cluster.tf
index f6435943..af4d9a26 100644
--- a/testdata/templates/full_container_cluster.tf
+++ b/testdata/templates/full_container_cluster.tf
@@ -141,7 +141,6 @@ resource "google_container_cluster" "full_list_default_1" {
     enable_private_nodes    = true
     master_ipv4_cidr_block  = "127.0.0.0/28"
   }
-  remove_default_node_pool = true
   resource_labels = {
     test-resource_labels-key = "test-resource_labels-value"
   }
diff --git a/testdata/templates/full_container_cluster.tfplan.json b/testdata/templates/full_container_cluster.tfplan.json
index a645aaf8..f0fd4d9f 100644
--- a/testdata/templates/full_container_cluster.tfplan.json
+++ b/testdata/templates/full_container_cluster.tfplan.json
@@ -1,6 +1,6 @@
 {
   "format_version": "0.1",
-  "terraform_version": "0.12.20",
+  "terraform_version": "0.13.6",
   "planned_values": {
     "root_module": {
       "resources": [
@@ -9,7 +9,7 @@
           "mode": "managed",
           "type": "google_container_cluster",
           "name": "full_list_default_1",
-          "provider_name": "google",
+          "provider_name": "registry.terraform.io/hashicorp/google",
           "schema_version": 1,
           "values": {
             "addons_config": [
@@ -33,9 +33,11 @@
             ],
             "default_max_pods_per_node": 42,
             "description": "test-description",
+            "enable_autopilot": null,
             "enable_binary_authorization": false,
             "enable_kubernetes_alpha": true,
             "enable_legacy_abac": true,
+            "enable_tpu": null,
             "initial_node_count": 42,
             "ip_allocation_policy": [
               {
@@ -51,7 +53,9 @@
                   {
                     "start_time": "03:00"
                   }
-                ]
+                ],
+                "maintenance_exclusion": [],
+                "recurring_window": []
               }
             ],
             "master_auth": [
@@ -128,6 +132,7 @@
               "test-node_locations"
             ],
             "node_version": "test-node_version",
+            "pod_security_policy_config": [],
             "private_cluster_config": [
               {
                 "enable_private_endpoint": true,
@@ -135,15 +140,11 @@
                 "master_ipv4_cidr_block": "127.0.0.0/28"
               }
             ],
-            "workload_identity_config": [
-              {
-                "identity_namespace": "testproject.svc.id.goog"
-              }
-            ],
-            "remove_default_node_pool": true,
+            "remove_default_node_pool": null,
             "resource_labels": {
               "test-resource_labels-key": "test-resource_labels-value"
             },
+            "resource_usage_export_config": [],
             "subnetwork": "test-subnetwork",
             "timeouts": null,
             "vertical_pod_autoscaling": []
@@ -158,7 +159,7 @@
       "mode": "managed",
       "type": "google_container_cluster",
       "name": "full_list_default_1",
-      "provider_name": "google",
+      "provider_name": "registry.terraform.io/hashicorp/google",
       "change": {
         "actions": [
           "create"
@@ -186,9 +187,11 @@
           ],
           "default_max_pods_per_node": 42,
           "description": "test-description",
+          "enable_autopilot": null,
           "enable_binary_authorization": false,
           "enable_kubernetes_alpha": true,
           "enable_legacy_abac": true,
+          "enable_tpu": null,
           "initial_node_count": 42,
           "ip_allocation_policy": [
             {
@@ -204,7 +207,9 @@
                 {
                   "start_time": "03:00"
                 }
-              ]
+              ],
+              "maintenance_exclusion": [],
+              "recurring_window": []
             }
           ],
           "master_auth": [
@@ -281,6 +286,7 @@
             "test-node_locations"
           ],
           "node_version": "test-node_version",
+          "pod_security_policy_config": [],
           "private_cluster_config": [
             {
               "enable_private_endpoint": true,
@@ -288,30 +294,25 @@
               "master_ipv4_cidr_block": "127.0.0.0/28"
             }
           ],
-          "workload_identity_config": [
-            {
-              "identity_namespace": "testproject.svc.id.goog"
-            }
-          ],
-          "remove_default_node_pool": true,
+          "remove_default_node_pool": null,
           "resource_labels": {
             "test-resource_labels-key": "test-resource_labels-value"
           },
+          "resource_usage_export_config": [],
           "subnetwork": "test-subnetwork",
           "timeouts": null,
           "vertical_pod_autoscaling": []
         },
         "after_unknown": {
-          "additional_zones": true,
           "addons_config": [
             {
+              "cloudrun_config": true,
               "horizontal_pod_autoscaling": [
                 {}
               ],
               "http_load_balancing": [
                 {}
               ],
-              "kubernetes_dashboard": true,
               "network_policy_config": [
                 {}
               ]
@@ -320,17 +321,18 @@
           "authenticator_groups_config": true,
           "cluster_autoscaling": true,
           "cluster_ipv4_cidr": true,
+          "database_encryption": true,
+          "datapath_provider": true,
+          "default_snat_status": true,
           "enable_intranode_visibility": true,
-          "enable_tpu": true,
+          "enable_shielded_nodes": true,
           "endpoint": true,
           "id": true,
           "instance_group_urls": true,
           "ip_allocation_policy": [
             {
               "cluster_ipv4_cidr_block": true,
-              "node_ipv4_cidr_block": true,
-              "services_ipv4_cidr_block": true,
-              "subnetwork_name": true
+              "services_ipv4_cidr_block": true
             }
           ],
           "label_fingerprint": true,
@@ -340,7 +342,9 @@
                 {
                   "duration": true
                 }
-              ]
+              ],
+              "maintenance_exclusion": [],
+              "recurring_window": []
             }
           ],
           "master_auth": [
@@ -365,6 +369,7 @@
           "network_policy": [
             {}
           ],
+          "networking_mode": true,
           "node_config": [
             {
               "guest_accelerator": [
@@ -377,7 +382,6 @@
                 false,
                 false
               ],
-              "sandbox_config": true,
               "shielded_instance_config": true,
               "tags": [
                 false
@@ -391,20 +395,25 @@
           ],
           "node_pool": true,
           "operation": true,
-          "pod_security_policy_config": true,
+          "pod_security_policy_config": [],
           "private_cluster_config": [
             {
+              "master_global_access_config": true,
               "peering_name": true,
               "private_endpoint": true,
               "public_endpoint": true
             }
           ],
+          "private_ipv6_google_access": true,
           "project": true,
-          "region": true,
+          "release_channel": true,
           "resource_labels": {},
+          "resource_usage_export_config": [],
+          "self_link": true,
           "services_ipv4_cidr": true,
+          "tpu_ipv4_cidr_block": true,
           "vertical_pod_autoscaling": [],
-          "zone": true
+          "workload_identity_config": true
         }
       }
     }
@@ -617,16 +626,6 @@
                 }
               }
             ],
-            "workload_identity_config": [
-              {
-                "identity_namespace": {
-                  "constant_value": true
-                }
-              }
-            ],
-            "remove_default_node_pool": {
-              "constant_value": true
-            },
             "resource_labels": {
               "constant_value": {
                 "test-resource_labels-key": "test-resource_labels-value"
diff --git a/testdata/templates/full_spanner_instance.tfplan.json b/testdata/templates/full_spanner_instance.tfplan.json
index 129edc4e..ead499d7 100644
--- a/testdata/templates/full_spanner_instance.tfplan.json
+++ b/testdata/templates/full_spanner_instance.tfplan.json
@@ -1,64 +1,49 @@
 {
   "format_version": "0.1",
-  "terraform_version": "0.12.13",
+  "terraform_version": "0.13.6",
   "planned_values": {
     "root_module": {
       "resources": [
-            {
-              "address": "module.env.google_spanner_instance.spanner-instance",
-              "mode": "managed",
-              "type": "google_spanner_instance",
-              "name": "spanner-instance",
-              "provider_name": "google",
-              "schema_version": 0,
-              "values": {
-                "config": "projects/{{.Provider.project}}/instanceConfigs/regional-us-central1",
-                "display_name": "spanner-instance",
-                "id": "{{.Provider.project}}/spanner-instance",
-                "labels": {
-                  "label1": "value1",
-                  "label2": "value2",
-                  "label3": "value3"
-                },
-                "name": "spanner-instance",
-                "num_nodes": 1,
-                "state": "READY",
-                "timeouts": null
-              }
-            }
-          ]
+        {
+          "address": "google_spanner_instance.spanner-instance",
+          "mode": "managed",
+          "type": "google_spanner_instance",
+          "name": "spanner-instance",
+          "provider_name": "registry.terraform.io/hashicorp/google",
+          "schema_version": 0,
+          "values": {
+            "config": "regional-us-central1",
+            "display_name": "spanner-instance",
+            "force_destroy": false,
+            "labels": {
+              "label1": "value1",
+              "label2": "value2",
+              "label3": "value3"
+            },
+            "name": "spanner-instance",
+            "num_nodes": 1,
+            "timeouts": null
+          }
         }
-    },
+      ]
+    }
+  },
   "resource_changes": [
-     {
-      "address": "module.env.google_spanner_instance.spanner-instance",
-      "module_address": "module.env",
+    {
+      "address": "google_spanner_instance.spanner-instance",
       "mode": "managed",
       "type": "google_spanner_instance",
       "name": "spanner-instance",
-      "provider_name": "google",
+      "provider_name": "registry.terraform.io/hashicorp/google",
       "change": {
         "actions": [
-          "no-op"
+          "create"
         ],
-        "before": {
-          "config": "projects/abcloud-ref-dev/instanceConfigs/regional-us-central1",
-          "display_name": "spanner-instance",
-          "id": "{{.Provider.project}}/spanner-instance",
-          "labels": {
-            "label1": "value1",
-            "label2": "value2",
-            "label3": "value3"
-          },
-          "name": "spanner-instance",
-          "num_nodes": 1,
-          "state": "READY",
-          "timeouts": null
-        },
+        "before": null,
         "after": {
-          "config": "projects/{{.Provider.project}}/instanceConfigs/regional-us-central1",
+          "config": "regional-us-central1",
           "display_name": "spanner-instance",
-          "id": "{{.Provider.project}}/spanner-instance",
+          "force_destroy": false,
           "labels": {
             "label1": "value1",
             "label2": "value2",
@@ -66,11 +51,50 @@
           },
           "name": "spanner-instance",
           "num_nodes": 1,
-          "state": "READY",
           "timeouts": null
         },
-        "after_unknown": {}
+        "after_unknown": {
+          "id": true,
+          "labels": {},
+          "project": true,
+          "state": true
+        }
       }
     }
-  ]
+  ],
+  "configuration": {
+    "root_module": {
+      "resources": [
+        {
+          "address": "google_spanner_instance.spanner-instance",
+          "mode": "managed",
+          "type": "google_spanner_instance",
+          "name": "spanner-instance",
+          "provider_config_key": "google",
+          "expressions": {
+            "config": {
+              "constant_value": "regional-us-central1"
+            },
+            "display_name": {
+              "constant_value": "spanner-instance"
+            },
+            "labels": {
+              "constant_value": {
+                "label1": "value1",
+                "label2": "value2",
+                "label3": "value3"
+              }
+            },
+            "name": {
+              "constant_value": "spanner-instance"
+            },
+            "num_nodes": {
+              "constant_value": 1
+            }
+          },
+          "schema_version": 0
+        }
+      ]
+    }
+  }
 }