Skip to content

Re-deprecate enable_flow_logs #3691

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

modular-magician
Copy link
Collaborator

closes hashicorp/terraform-provider-google#21950

This PR re-deprecates enable_flow_logs and removes its functionality by reverting the expander logic related to it.

Testing the config mentioned in this comment: hashicorp/terraform-provider-google#21950 (comment)
gpaste/5824658669305856 shows enableFlowLogs and logConfig.enabled to be correctly set to true.

Unfortunately, GoogleCloudPlatform/magic-modules#13093 also set log_config to Optional + Computed, which removed its ability to be removed. To fix this, I removed default_from_api but also modified the diffsuppress for log_config to check whether or not the log_config exists in the user's config. If it does not exist but the deprecated enable_flow_logs does, we should suppress the diff so users aren't hit with a breaking change to disable their flow logs.
To test this, I applied the following config in 6.27:

resource "google_compute_subnetwork" "this" {
  provider      = google-beta
  name          = "<name>"
  ip_cidr_range = "10.2.0.0/16"
  region        = "us-central1"
  network       = google_compute_network.custom-test.name

  enable_flow_logs = true
}

Here is the difference when upgrading to versions with the fix w/ and w/o diffsuppress:

Without diffsuppress + enable_flow_logs=true + no log_config:

  # google_compute_subnetwork.this will be updated in-place
  ~ resource "google_compute_subnetwork" "this" {
      - log_config {
          - aggregation_interval = "INTERVAL_5_SEC" -> null
          - flow_sampling        = 0.5 -> null
          - metadata             = "EXCLUDE_ALL_METADATA" -> null
          - metadata_fields      = [] -> null
            # (1 unchanged attribute hidden)
        }
    }

With diffsuppress

No changes. Your infrastructure matches the configuration.

Given the circumstances of the O+C in log_config only being present in 6.26-6.27, and the diff suppress, I believe we move forward with removing O+C. There's a possibility that someone created a subnetwork in 6.26 or 6.27, enabled flow logs WITHOUT enable_flow_logs or log_config (maybe outside of Terraform), and upgrading to 6.28 will show a diff to remove flow logs since log_config is not in their configuration and no longer O+C. I believe this should be a very small set and we'd be saving more user pain overall.

compute: deprecated `enable_flow_logs` in favor of `log_config`.  If `log_config` is present, flow logs are enabled and `enable_flow_logs` can be safely removed.
compute: fixed a regression in `google_compute_subnetwork` where setting `log_config` would not enable flow logs without `enable_flow_logs` also being set to true. To enable or disable flow logs, please use `log_config`. `enable_flow_logs` is now deprecated and will be removed in the next major release.

Derived from GoogleCloudPlatform/magic-modules#13485

[upstream:644ea10a2b33f2863a1edcdc2fb3986bf8ca0518]

Signed-off-by: Modular Magician <[email protected]>
@modular-magician modular-magician requested a review from a team as a code owner March 28, 2025 19:17
@modular-magician modular-magician requested review from shuyama1 and removed request for a team March 28, 2025 19:17
@modular-magician modular-magician merged commit 77d553d into GoogleCloudPlatform:main Mar 28, 2025
5 of 7 checks passed
kotatut pushed a commit to kotatut/terraform-google-conversion-antonkot that referenced this pull request Apr 18, 2025
[upstream:644ea10a2b33f2863a1edcdc2fb3986bf8ca0518]

Signed-off-by: Modular Magician <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Deprecated field enable-flow-logs was reintroduced in terraform-google-provider version 6.26.0
1 participant