Skip to content

Commit

Permalink
fix update failure (#7101) (#13460)
Browse files Browse the repository at this point in the history
Co-authored-by: Edward Sun <sunedward@google.com>
Signed-off-by: Modular Magician <magic-modules@google.com>

Signed-off-by: Modular Magician <magic-modules@google.com>
Co-authored-by: Edward Sun <sunedward@google.com>
  • Loading branch information
modular-magician and Edward Sun authored Jan 11, 2023
1 parent 8aa4a99 commit fc29c88
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .changelog/7101.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
bigqueryconnection: fixed `aws.access_role.iam_role_id` cannot be updated on `google_bigquery_connection`
```
2 changes: 1 addition & 1 deletion google/resource_bigquery_connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -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") {
Expand Down
70 changes: 70 additions & 0 deletions google/resource_bigquery_connection_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

0 comments on commit fc29c88

Please sign in to comment.