How to recover deleted VPC firewall rules

Problem

After deleting a set of firewall rules for a VPC, you may see traffic to the VPC being blocked. You may want to know how to recover the deleted firewall rules to resolve this issue.

Environment

  • VPC Network

Solution

Workaround

  1. Navigate to Logging > Logs Explorer
  2. Use the advanced filter:
    resource.type="gce_firewall_rule" protoPayload.methodName="v1.compute.firewalls.delete"
  3. Look at the protoPayload > resourceOriginalState field. Here, you will be able to see the parameters the firewall rules had prior to being deleted. This will enable you to add the firewall rules back manually.