Skip to content

Conversation

@GraceAtwood
Copy link

Description

Add support for policyTags as a value in the ignore_schema_changes virtual field on google_bigquery_table. This mirrors the existing dataPolicies implementation (PR #23495, PR #25721) and allows users to ignore externally-applied policy tag changes without having to ignore the entire schema.

Problem

BigQuery policy tags (policyTags) are often managed outside Terraform by automated tools (e.g., PII auto-taggers that scan tables daily). Since the schema attribute is a single JSON blob, ignore_changes cannot target individual fields within it — users must either ignore the entire schema or manually track every tag change in their Terraform config.

The ignore_schema_changes field already supports dataPolicies (data masking policies). This PR extends it to also support policyTags (column-level access control tags), which are a different schema field (TableFieldSchema.policyTags vs TableFieldSchema.dataPolicies).

Related Issues

Behavior

When ignore_schema_changes = ["policyTags"] is set:

  • Policy tags applied outside Terraform (e.g., by an auto-tagger) are preserved during updates
  • Policy tags explicitly set in the Terraform config still override live state
  • Diff suppression prevents plan noise from external tag changes
  • Recursive handling supports nested RECORD/STRUCT types

Changes

  • resource_bigquery_table.go.tmpl: Added mergePolicyTags() and mergePolicyTagsIntoMap() functions, updated diff suppression, CustomizeDiff, and Update logic
  • resource_bigquery_table_internal_test.go.tmpl: Unit tests for diff suppress, merge struct, merge map, isChangeable
  • resource_bigquery_table_test.go: 3-stage acceptance test (TestAccBigQueryTable_PolicyTagsMerge)
  • bigquery_table.html.markdown: Updated docs to mention policyTags alongside dataPolicies
bigquery: added `policyTags` support to `ignore_schema_changes` in `google_bigquery_table` resource

…igquery_table

Add support for 'policyTags' as a value in the ignore_schema_changes
virtual field on google_bigquery_table. This mirrors the existing
'dataPolicies' implementation and allows users to ignore externally-
applied policy tag changes (e.g., from automated PII tagging tools)
without having to ignore the entire schema.

When ignore_schema_changes includes 'policyTags':
- Policy tags set outside Terraform are preserved during updates
- Policy tags explicitly set in the Terraform config override live state
- Diff suppression prevents plan noise from external tag changes
- Recursive handling supports nested RECORD/STRUCT types

Includes unit tests (diff suppress, merge struct, merge map, isChangeable)
and acceptance test (3-stage create/add/merge verification).

:house: Remote-Dev: homespace
@modular-magician modular-magician added the awaiting-approval Pull requests that need reviewer's approval to run presubmit tests label Jan 28, 2026
@github-actions github-actions bot requested a review from slevenick January 28, 2026 06:24
@github-actions
Copy link

Hello! I am a robot. Tests will require approval from a repository maintainer to run.

Googlers: For automatic test runs see go/terraform-auto-test-runs.

@slevenick, a repository maintainer, has been assigned to review your changes. If you have not received review feedback within 2 business days, please leave a comment on this PR asking them to take a look.

You can help make sure that review is quick by doing a self-review and by running impacted tests locally.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting-approval Pull requests that need reviewer's approval to run presubmit tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants