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

aws_networkfirewall_rule_group: Cannot reference ip_sets in source/destination in header for a stateful rule #22727

Closed
vineetsk50 opened this issue Jan 21, 2022 · 4 comments · Fixed by #23482
Labels
bug Addresses a defect in current functionality. service/networkfirewall Issues and PRs that pertain to the networkfirewall service.
Milestone

Comments

@vineetsk50
Copy link

vineetsk50 commented Jan 21, 2022

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 other comments that do not add relevant new information or questions, 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

Terraform CLI and Terraform AWS Provider Version

Terraform v1.1.4
on darwin_amd64

  • provider registry.terraform.io/hashicorp/aws v3.72.0

Affected Resource(s)

  • aws_networkfirewall_rule_group

Terraform Configuration Files

resource "aws_networkfirewall_rule_group" "example" {
  capacity = 100
  name     = "example"
  type     = "STATEFUL"
  rule_group {
    rule_variables {
      ip_sets {
        key = "WEBSERVER_HOSTS"
        ip_set {
          definition = ["10.0.0.0/16", "10.0.1.0/24", "192.168.0.0/16"]
        }
      }
    }
    rules_source {
        stateful_rule {
            action = "PASS"
            header {
                destination = "$WEBSERVER_HOSTS"
                source = "0.0.0.0/0"
                destination_port = "443"
                source_port = "ANY"
                protocol = "TCP"
                direction = "ANY"
            }
            rule_option {
                keyword: "sid:1"
            }
        }
    }
  }
}

Expected Behavior

The source/destination in the header should be able to reference the ip_set. This works via AWS Console, AWS CLI, and CloudFormation. This is not working via Terraform

Actual Behavior

Error: "$WEBSERVER_HOST" is not a valid CIDR block: invalid CIDR address: $WEBSERVER_HOST

References

Similar issue resolved for ip_set - #22268
AWS Documentation on accepted patterns for source/destination - https://docs.aws.amazon.com/network-firewall/latest/APIReference/API_Header.html

@github-actions github-actions bot added needs-triage Waiting for first response or review from a maintainer. service/networkfirewall Issues and PRs that pertain to the networkfirewall service. labels Jan 21, 2022
@justinretzolk justinretzolk added bug Addresses a defect in current functionality. and removed needs-triage Waiting for first response or review from a maintainer. labels Jan 22, 2022
@midestefanis
Copy link

any news about this? i'm having the same issue

ewbankkit added a commit that referenced this issue Mar 3, 2022
fix #22727: allow any character in networkfirewall/stateful_rule/header source/destination per the api docs
@github-actions github-actions bot added this to the v4.4.0 milestone Mar 3, 2022
@github-actions
Copy link

github-actions bot commented Mar 4, 2022

This functionality has been released in v4.4.0 of the Terraform AWS Provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you!

@midestefanis
Copy link

@jordanfelle @ewbankkit @vineetsk50 Does anyone know if it is possible to pass two variables in some way? Don't leave me this way:

resource "aws_networkfirewall_rule_group" "example" {
  capacity = 100
  name     = "example"
  type     = "STATEFUL"
  rule_group {
    rule_variables {
      ip_sets {
        key = "WEBSERVER_HOSTS_2"
        ip_set {
          definition = ["10.48.208.0/23"]
        }
      }
      ip_sets {
        key = "WEBSERVER_HOSTS"
        ip_set {
          definition = ["10.0.0.0/16", "10.0.1.0/24", "192.168.0.0/16"]
        }
      }      
    }
    rules_source {
        stateful_rule {
            action = "PASS"
            header {
                destination = "$WEBSERVER_HOSTS$WEBSERVER_HOSTS_2"
                source = "0.0.0.0/0"
                destination_port = "443"
                source_port = "ANY"
                protocol = "TCP"
                direction = "ANY"
            }
            rule_option {
                keyword: "sid:1"
            }
        }
    }
  }
}

Error:

InvalidRequestException: stateful rule is invalid, ***** , reason: not every address block was properly closed in "[***", 1 missing closing brackets (]). Note: problem might be in a variable.

@github-actions
Copy link

github-actions bot commented May 9, 2022

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 9, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Addresses a defect in current functionality. service/networkfirewall Issues and PRs that pertain to the networkfirewall service.
Projects
None yet
3 participants