Skip to content
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

Empty Array Treated as Nil in Firewall source_ranges property #20712

Open
JakeCooper opened this issue Dec 17, 2024 · 1 comment
Open

Empty Array Treated as Nil in Firewall source_ranges property #20712

JakeCooper opened this issue Dec 17, 2024 · 1 comment

Comments

@JakeCooper
Copy link

JakeCooper commented Dec 17, 2024

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request.
  • Please do not leave +1 or me too comments, they generate extra noise for issue followers and do not help prioritize the request.
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment.
  • If an issue is assigned to a user, that user is claiming responsibility for the issue.
  • Customers working with a Google Technical Account Manager or Customer Engineer can ask them to reach out internally to expedite investigation and resolution of this issue.

Terraform Version & Provider Version(s)

Terraform vX.X.X
on

  • provider registry.terraform.io/hashicorp/google vX.X.X
  • provider registry.terraform.io/hashicorp/google-beta vX.X.X

Affected Resource(s)

google_compute_firewall

Terraform Configuration

resource "google_compute_firewall" "ddos_block" {
  name          = "ddos-block"
  project       = local.project
  network       = module.railway_network.network_id
  direction     = "INGRESS"
  source_ranges = []
  priority      = 1

  deny {
    protocol = "all"
  }
}

Debug Output

No response

Expected Behavior

Based on understanding of something is provided, just empty string, the provider should likely throw an error or no-op

Actual Behavior

What happens instead is the Firewall rule is applied to everything, instead of the "source_ranges" of none

While this behavior technically makes sense (since Golang interprets the empty array as nil), it's a pretty large footgun if someone empties a list and applies it

Steps to reproduce

  1. terraform apply

Important Factoids

This footgun caused an outage. https://blog.railway.com/p/incident-december-16-2024

References

No response

b/385405821

@JakeCooper JakeCooper added the bug label Dec 17, 2024
@shuyama1 shuyama1 added documentation and removed forward/review In review; remove label to forward labels Dec 20, 2024
@shuyama1
Copy link
Collaborator

shuyama1 commented Dec 21, 2024

Yeah, I believe empty array is considered as nil indicating that no source_ranges are specified. We could explicitly document this case to avoid any confusion.

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

No branches or pull requests

3 participants