-
Notifications
You must be signed in to change notification settings - Fork 200
Description
Summary
When using the google_bigquery_dataset_access resource to manage dataset permissions separately, this module produces a persistent diff because it doesn't ignore changes to the access block within the google_bigquery_dataset resource.
Problem Description
The module currently defines dataset access via the access variable, which is directly translated into access blocks within the google_bigquery_dataset resource. This approach works well when all access controls are managed within the module.
However, for users who prefer to manage dataset access separately using the standalone google_bigquery_dataset_access resource, this creates a conflict. Terraform detects a drift between the state file (which includes the access defined by the module) and the actual state in GCP (managed by the separate resource), resulting in a plan that always shows changes to be applied.
As noted in the google_bigquery_dataset_access documentation, when using this resource, the google_bigquery_dataset resource must either have no defined access blocks or a lifecycle block with ignore_changes = [access].
Proposed Solution
To support this alternative access management pattern, I propose adding a new boolean variable, for example ignore_access_changes, to the module.
When ignore_access_changes is set to true, the module should add a lifecycle block to the google_bigquery_dataset.main resource:
resource "google_bigquery_dataset" "main" {
# ... existing configuration ...
lifecycle {
ignore_changes = [
access
]
}
}This would allow users to decouple dataset access management from the dataset creation, providing greater flexibility.
Steps to Reproduce
- Instantiate the
terraform-google-bigquerymodule to create a dataset. - In a separate Terraform configuration, use the
google_bigquery_dataset_accessresource to grant permissions to the same dataset. - Run
terraform plan. - Observe that Terraform proposes to remove the access granted by the
google_bigquery_dataset_accessresource.