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 rule_variables in rule_variables #22268

Closed
AL1060005 opened this issue Dec 17, 2021 · 3 comments · Fixed by #22284
Closed

aws_networkfirewall_rule_group: Cannot reference rule_variables in rule_variables #22268

AL1060005 opened this issue Dec 17, 2021 · 3 comments · Fixed by #22284
Labels
bug Addresses a defect in current functionality. service/networkfirewall Issues and PRs that pertain to the networkfirewall service.
Milestone

Comments

@AL1060005
Copy link

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

Provider version: 3.70.0

Description

The aws_networkfirewall_rule_group module allows to define a rule_variables block of ip sets for suricata rules.

The suricata format allows to reference other variables, and to negate them. This is both valid in the AWS console and CloudFormation, but unfortunately doesn't work here.

In this module, IP sets are expected to be in CIDR format only (i.e. A.B.C.D/X) only, with no way to reference other variables.

Expected working example

resource "aws_networkfirewall_rule_group" "example" {
  capacity = 100
  name     = "example"
  type     = "STATEFUL"
  rule_group {
    rule_variables {
      ip_sets {
        key = "WEBSERVERS_HOSTS"
        ip_set {
          definition = ["10.0.0.0/16", "10.0.1.0/24", "192.168.0.0/16"]
        }
      }
      ip_sets {
        key = "EXTERNAL_HOSTS"
        ip_set {
          definition = ["!WEBSERVERS_HOSTS"]
        }
      }
    }
  }
}

Actual Behavior

Error:

╷
│ Error: "!WEBSERVERS_HOSTS" is not a valid CIDR block: invalid CIDR address: !WEBSERVERS_HOSTS
│
│ with module.basic_example.aws_networkfirewall_rule_group.example,
│ on ../../main.tf line 28, in resource "aws_networkfirewall_rule_group" "example":
│ 28: rule_variables {
@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 Dec 17, 2021
@anGie44 anGie44 added bug Addresses a defect in current functionality. and removed needs-triage Waiting for first response or review from a maintainer. labels Dec 17, 2021
@anGie44
Copy link
Contributor

anGie44 commented Dec 17, 2021

Hi @AL1060005 , thank you for raising this issue. From the API specs, an ip_set definition seems to be defined as The list of IP addresses and address ranges, in CIDR notation. but oddly enough the pattern is specified as ^.*$ which i believe should allow for referencing other variables like WEBSERVERS_HOST. This can be addressed by adjusting the validation to the new regex pattern instead of just checking for valid CIDR addresses as seen here in the resource code:

"ip_set": {
Type: schema.TypeList,
Required: true,
MaxItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"definition": {
Type: schema.TypeSet,
Required: true,
Elem: &schema.Schema{
Type: schema.TypeString,
ValidateFunc: verify.ValidIPv4CIDRNetworkAddress,
},

So ValidateFunc: validation.StringMatch(regexp.MustCompile(`^.*$`), ""), may be the better solution.

lenios added a commit to lenios/terraform-provider-aws that referenced this issue Dec 20, 2021
anGie44 added a commit that referenced this issue Dec 21, 2021
fix #22268: allow any character in networkfirewall/ip_sets as per the…
@github-actions github-actions bot added this to the v3.71.0 milestone Dec 21, 2021
@github-actions
Copy link

github-actions bot commented Jan 6, 2022

This functionality has been released in v3.71.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!

@github-actions
Copy link

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 21, 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
2 participants