From fc29c8880b445fbdbd61c53be8c47b183d6326c4 Mon Sep 17 00:00:00 2001 From: The Magician Date: Wed, 11 Jan 2023 12:25:56 -0800 Subject: [PATCH] fix update failure (#7101) (#13460) Co-authored-by: Edward Sun Signed-off-by: Modular Magician Signed-off-by: Modular Magician Co-authored-by: Edward Sun --- .changelog/7101.txt | 3 + google/resource_bigquery_connection.go | 2 +- google/resource_bigquery_connection_test.go | 70 +++++++++++++++++++++ 3 files changed, 74 insertions(+), 1 deletion(-) create mode 100644 .changelog/7101.txt diff --git a/.changelog/7101.txt b/.changelog/7101.txt new file mode 100644 index 00000000000..6d87e085cf6 --- /dev/null +++ b/.changelog/7101.txt @@ -0,0 +1,3 @@ +```release-note:bug +bigqueryconnection: fixed `aws.access_role.iam_role_id` cannot be updated on `google_bigquery_connection` +``` diff --git a/google/resource_bigquery_connection.go b/google/resource_bigquery_connection.go index 59f2ec450b9..96978bfadf2 100644 --- a/google/resource_bigquery_connection.go +++ b/google/resource_bigquery_connection.go @@ -514,7 +514,7 @@ func resourceBigqueryConnectionConnectionUpdate(d *schema.ResourceData, meta int } if d.HasChange("aws") { - updateMask = append(updateMask, "aws") + updateMask = append(updateMask, "aws.access_role.iam_role_id") } if d.HasChange("azure") { diff --git a/google/resource_bigquery_connection_test.go b/google/resource_bigquery_connection_test.go index df13f7672b4..ddecf9d8dd8 100644 --- a/google/resource_bigquery_connection_test.go +++ b/google/resource_bigquery_connection_test.go @@ -138,3 +138,73 @@ resource "google_bigquery_connection" "connection" { } `, context) } + +func TestAccBigqueryConnectionConnection_bigqueryConnectionAwsUpdate(t *testing.T) { + t.Parallel() + + context := map[string]interface{}{ + "random_suffix": randString(t, 10), + } + + vcrTest(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + ExternalProviders: map[string]resource.ExternalProvider{ + "random": {}, + "time": {}, + }, + CheckDestroy: testAccCheckBigqueryConnectionConnectionDestroyProducer(t), + Steps: []resource.TestStep{ + { + Config: testAccBigqueryConnectionConnection_bigqueryConnectionAws(context), + }, + { + ResourceName: "google_bigquery_connection.connection", + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{"location"}, + }, + { + Config: testAccBigqueryConnectionConnection_bigqueryConnectionAwsUpdate(context), + }, + { + ResourceName: "google_bigquery_connection.connection", + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{"location"}, + }, + }, + }) +} + +func testAccBigqueryConnectionConnection_bigqueryConnectionAws(context map[string]interface{}) string { + return Nprintf(` +resource "google_bigquery_connection" "connection" { + connection_id = "tf-test-my-connection%{random_suffix}" + location = "aws-us-east-1" + friendly_name = "👋" + description = "a riveting description" + aws { + access_role { + iam_role_id = "arn:aws:iam::999999999999:role/omnirole%{random_suffix}" + } + } +} +`, context) +} + +func testAccBigqueryConnectionConnection_bigqueryConnectionAwsUpdate(context map[string]interface{}) string { + return Nprintf(` +resource "google_bigquery_connection" "connection" { + connection_id = "tf-test-my-connection%{random_suffix}" + location = "aws-us-east-1" + friendly_name = "👋" + description = "a riveting description" + aws { + access_role { + iam_role_id = "arn:aws:iam::999999999999:role/omnirole%{random_suffix}update" + } + } +} +`, context) +}