Skip to content

Commit

Permalink
remove allow_resource_tags_on_deletion from google_bigquery_table
Browse files Browse the repository at this point in the history
  • Loading branch information
wj-chen committed Aug 8, 2024
1 parent a31848e commit 96c360b
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 38 deletions.
10 changes: 0 additions & 10 deletions mmv1/products/bigquery/Table.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,6 @@ examples:
vars:
dataset_id: 'dataset_id'
table_id: 'table_id'
virtual_fields:
- !ruby/object:Api::Type::Boolean
name: 'allow_resource_tags_on_deletion'
description: |
If set to true, it allows table deletion when there are still resource tags attached.
deprecation_message: |
`allow_resource_tags_on_deletion` is deprecated and will be removed in a future major
release. The default behavior will be allowing the presence of resource tags on
deletion after the next major release.
default_value: false
parameters:
# TODO(alexstephen): Remove once we have support for placing
# nested object fields in URL
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1250,14 +1250,6 @@ func ResourceBigQueryTable() *schema.Resource {
Description: `Whether Terraform will be prevented from destroying the instance. When the field is set to true or unset in Terraform state, a terraform apply or terraform destroy that would delete the table will fail. When the field is set to false, deleting the table is allowed.`,
},

"allow_resource_tags_on_deletion": {
Type: schema.TypeBool,
Optional: true,
Default: false,
Description: `**Deprecated** Whether or not to allow table deletion when there are still resource tags attached.`,
Deprecated: `This field is deprecated and will be removed in a future major release. The default behavior will be allowing the presence of resource tags on deletion after the next major release.`,
},

// TableConstraints: [Optional] Defines the primary key and foreign keys.
"table_constraints": {
Type: schema.TypeList,
Expand Down Expand Up @@ -1930,17 +1922,6 @@ func resourceBigQueryTableDelete(d *schema.ResourceData, meta interface{}) error
if d.Get("deletion_protection").(bool) {
return fmt.Errorf("cannot destroy table %v without setting deletion_protection=false and running `terraform apply`", d.Id())
}
if v, ok := d.GetOk("resource_tags"); ok {
if !d.Get("allow_resource_tags_on_deletion").(bool) {
var resourceTags []string

for k, v := range v.(map[string]interface{}) {
resourceTags = append(resourceTags, fmt.Sprintf("%s:%s", k, v.(string)))
}

return fmt.Errorf("cannot destroy table %v without unsetting the following resource tags or setting allow_resource_tags_on_deletion=true: %v", d.Id(), resourceTags)
}
}

config := meta.(*transport_tpg.Config)
userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent)
Expand Down Expand Up @@ -2947,9 +2928,6 @@ func resourceBigQueryTableImport(d *schema.ResourceData, meta interface{}) ([]*s
if err := d.Set("deletion_protection", true); err != nil {
return nil, fmt.Errorf("Error setting deletion_protection: %s", err)
}
if err := d.Set("allow_resource_tags_on_deletion", false); err != nil {
return nil, fmt.Errorf("Error setting allow_resource_tags_on_deletion: %s", err)
}

// Replace import id for the resource id
id, err := tpgresource.ReplaceVars(d, config, "projects/{{project}}/datasets/{{dataset_id}}/tables/{{table_id}}")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1645,7 +1645,7 @@ func TestAccBigQueryTable_ResourceTags(t *testing.T) {
ResourceName: "google_bigquery_table.test",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"deletion_protection", "allow_resource_tags_on_deletion"},
ImportStateVerifyIgnore: []string{"deletion_protection"},
},
{
Config: testAccBigQueryTableWithResourceTagsUpdate(context),
Expand All @@ -1654,7 +1654,7 @@ func TestAccBigQueryTable_ResourceTags(t *testing.T) {
ResourceName: "google_bigquery_table.test",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"deletion_protection", "allow_resource_tags_on_deletion"},
ImportStateVerifyIgnore: []string{"deletion_protection"},
},
// testAccBigQueryTableWithResourceTagsDestroy must be called at the end of this test to clear the resource tag bindings of the table before deletion.
{
Expand All @@ -1664,7 +1664,7 @@ func TestAccBigQueryTable_ResourceTags(t *testing.T) {
ResourceName: "google_bigquery_table.test",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"deletion_protection", "allow_resource_tags_on_deletion"},
ImportStateVerifyIgnore: []string{"deletion_protection"},
},
},
})
Expand Down Expand Up @@ -4202,7 +4202,6 @@ resource "google_bigquery_dataset" "test" {
resource "google_bigquery_table" "test" {
deletion_protection = false
allow_resource_tags_on_deletion = true
dataset_id = "${google_bigquery_dataset.test.dataset_id}"
table_id = "%{table_id}"
resource_tags = {
Expand Down Expand Up @@ -4240,7 +4239,6 @@ resource "google_bigquery_dataset" "test" {
resource "google_bigquery_table" "test" {
deletion_protection = false
allow_resource_tags_on_deletion = true
dataset_id = "${google_bigquery_dataset.test.dataset_id}"
table_id = "%{table_id}"
resource_tags = {
Expand Down Expand Up @@ -4279,7 +4277,6 @@ resource "google_bigquery_dataset" "test" {
resource "google_bigquery_table" "test" {
deletion_protection = false
allow_resource_tags_on_deletion = true
dataset_id = "${google_bigquery_dataset.test.dataset_id}"
table_id = "%{table_id}"
resource_tags = {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,10 @@ Description of the change and how users should adjust their configuration (if ne

A `view` can no longer be created when `schema` contains required fields

### `allow_resource_tags_on_deletion` is now removed

Resource tags are now always allowed on table deletion.

## Resource: `google_bigquery_reservation`

### `multi_region_auxiliary` is now removed
Expand Down

0 comments on commit 96c360b

Please sign in to comment.