diff --git a/.changelog/5362.txt b/.changelog/5362.txt new file mode 100644 index 00000000000..2d71057ec4b --- /dev/null +++ b/.changelog/5362.txt @@ -0,0 +1,3 @@ +```release-note:bug +bigquery: fixed a bug of cannot add required fields to an existing schema on `google_bigquery_table` +``` diff --git a/google/resource_bigquery_table.go b/google/resource_bigquery_table.go index 4a8bd4e6625..1b7acd7f8cd 100644 --- a/google/resource_bigquery_table.go +++ b/google/resource_bigquery_table.go @@ -225,6 +225,17 @@ func resourceBigQueryTableSchemaIsChangeable(old, new interface{}) (bool, error) return false, err } mapNew := bigQueryArrayToMapIndexedByName(arrayNew) + for key := range mapNew { + // making unchangeable if an newly added column is with REQUIRED mode + if _, ok := mapOld[key]; !ok { + items := mapNew[key].(map[string]interface{}) + for k := range items { + if k == "mode" && fmt.Sprintf("%v", items[k]) == "REQUIRED" { + return false, nil + } + } + } + } for key := range mapOld { // all old keys should be represented in the new config if _, ok := mapNew[key]; !ok { diff --git a/google/resource_container_node_pool.go b/google/resource_container_node_pool.go index 6cf6977b68e..6811a4099f3 100644 --- a/google/resource_container_node_pool.go +++ b/google/resource_container_node_pool.go @@ -1,13 +1,13 @@ package google import ( - "context" "fmt" "log" "regexp" "strings" "time" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/customdiff" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"