Skip to content

feat(firewall): add firewall management resources#344

Open
tphilll wants to merge 6 commits into
CrowdStrike:mainfrom
capitalone-contributions:feat-firewall-resources
Open

feat(firewall): add firewall management resources#344
tphilll wants to merge 6 commits into
CrowdStrike:mainfrom
capitalone-contributions:feat-firewall-resources

Conversation

@tphilll
Copy link
Copy Markdown

@tphilll tphilll commented Apr 13, 2026

Summary

Add crowdstrike_firewall_rule_group, crowdstrike_firewall_policy, and crowdstrike_firewall_policy_precedence resources for managing CrowdStrike Falcon Host-Based Firewall via Terraform.

Closes #99

What's included

  • crowdstrike_firewall_rule_group - manage firewall rule groups with nested rules
  • crowdstrike_firewall_policy - manage firewall policies with host groups and settings
  • crowdstrike_firewall_policy_precedence- control policy ordering/priority
  • crowdstrike_firewall_policies data source - query existing firewall policies
  • crowdstrike_firewall_rule_groups data source - query existing rule groups

Design decisions

  • Dual API pattern for policies: Policy basic fields use FirewallPolicies API, while container settings (default_inbound/outbound, enforce, test_mode, local_logging, rule_group_ids) use FirewallManagement.GetPolicyContainers/UpdatePolicyContainer APIs.
  • Temp ID ordering for rule updates: When adding new rules via JSON Patch, temp_ids must be in ascending order in both rule_ids and diff_operations arrays to satisfy API requirements.
  • Log field handling: The API doesn't return the log field on rules, so the plan value is preserved in state to avoid perpetual drift.
  • Single port handling: When start == end for port ranges, normalized to end=0 for API compatibility and restored on read.
  • Dynamic precedence state: For dynamic enforcement, plan IDs are preserved in state to avoid drift from concurrent policy changes.
  • ICMP wildcard handling: ICMP type/code values of "*" are treated as null/empty in API payloads.
  • Platform-specific validations: Linux platform restricts certain protocols (IGMP, IP-IN-IP, IPV6 ENCAPSULATION, GRE) and FQDN rules are Windows/Mac only.
  • Empty vs null rule_group_ids: Only set rule_group_ids in state when there are actual rule groups to avoid null vs empty list drift.

Testing

  • TestAccFirewallRuleGroupResource_* — 8 tests covering basic CRUD, multiple rules, platform tests, edge cases
  • TestAccFirewallPolicyResource_* — 8 tests covering basic CRUD, rule group attachments, host groups, all settings
  • TestAccFirewallPolicyPrecedenceResource_* — 2 tests covering dynamic enforcement and updates
  • TestAccFirewallPoliciesDataSource_* — 5 tests for policy data source queries
  • TestAccFirewallRuleGroupsDataSource_* — 6 tests for rule group data source queries
  • Verified against a live CrowdStrike tenant (us-2)

Checklist

  • go build passes
  • golangci-lint — 0 issues
  • make gen — documentation generated and committed
  • Acceptance tests pass (29 total)
  • Example configurations and import scripts included
  • Sweeper implemented for test cleanup
  • Resources registered in provider

tphilll and others added 6 commits April 9, 2026 16:05
…rces

Implements CrowdStrike firewall management capabilities for Terraform:

Resources:
- crowdstrike_firewall_rule_group: Manage firewall rule groups with nested rules
- crowdstrike_firewall_policy: Manage firewall policies with host groups and settings
- crowdstrike_firewall_policy_precedence: Control policy ordering/priority

Data Sources:
- crowdstrike_firewall_policies: Query existing firewall policies
- crowdstrike_firewall_rule_groups: Query existing rule groups

Closes CrowdStrike#99
…tion

Bug fixes discovered during verification testing:

1. Log field not preserved: API doesn't return log field, causing drift
   - Preserve plan's log value in wrapRules when reading back from API

2. Single port handling: start=443, end=443 caused API 'duplicate ports' error
   - Convert to end=0 when sending to API
   - Restore plan's end value when reading back (if plan had start==end)

3. Precedence dynamic enforcement race condition:
   - Parallel tests changing policy count caused failures
   - Preserve plan IDs in state for dynamic mode instead of reading from API
   - Changed precedence tests to sequential to avoid interference

All 29 acceptance tests pass.
This removes all duplicate calls that were introduced during the merge conflict resolution
@tphilll
Copy link
Copy Markdown
Author

tphilll commented Apr 29, 2026

@ffalor Initial failed checks was caused by duplicate RegisterSweeper() calls that was introduced during merge conflict resolution. This has since been fixed. What is the typical ETA for getting changes merged? I know this PR is HUGE. If you have any questions please let me know, thanks!

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.

Add ability to create endpoint security firewall policies, rule groups, and rules

1 participant