hashicorp / terraform-provider-aws

The AWS Provider enables Terraform to manage AWS resources.
https://registry.terraform.io/providers/hashicorp/aws
Mozilla Public License 2.0
9.86k stars 9.21k forks source link

[New]: Data resource for Network Firewall rule groups #39698

Open dsantanu opened 1 month ago

dsantanu commented 1 month ago

Description

Using AWS CLI (and boto3), one can retrive ARNs of the AWS managed rule groups, like this:

aws network-firewall list-rule-groups \
    --scope MANAGED \
    --managed-type AWS_MANAGED_THREAT_SIGNATURES  \
    --query 'RuleGroups[?Name==`ThreatSignaturesBotnetActionOrder`].Arn'

There is no such equivalant feature available for Terraform yet, which is a much needed requirment for adding managed rule-groups, without hard-coding the ARNs manually.

It was requested here: https://github.com/hashicorp/terraform-provider-aws/issues/18026; but doesn't look like ever implemented.

Requested Resource(s) and/or Data Source(s)

New Resource

Potential Terraform Configuration

variable "aws_managed_rule_groups" {
  type        = list(string)
  default     = [
    "ThreatSignaturesBotnetActionOrder",
    "ThreatSignaturesMalwareCoinminingActionOrder",
  ]
  description = "List of AWS managed rule-groups names" 
}

data "aws_networkfirewall_rule_group" "all_managed" {
  scope        = "MANAGED"
  managed_type = "AWS_MANAGED_THREAT_SIGNATURES"
}

data "aws_networkfirewall_rule_group" "specific_managed" {
  for_each        = toset(var.aws_managed_rule_groups)
  scope           = "MANAGED"
  rule_group_name = each.value
}

References

AWS API ref. https://docs.aws.amazon.com/network-firewall/latest/APIReference/API_ListRuleGroups.html

AWS CLI Ref. https://docs.aws.amazon.com/cli/latest/reference/network-firewall/list-rule-groups.html

Boto3 Ref. https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/network-firewall/client/list_rule_groups.html

Would you like to implement a fix?

None

github-actions[bot] commented 1 month ago

Community Note

Voting for Prioritization

Volunteering to Work on This Issue

wyardley commented 1 month ago

Side note that the awscc provider does have awscc_networkfirewall_rule_group and awscc_networkfirewall_rule_groups data sources, however, you can only specify the full ARN vs. name for awscc_networkfirewall_rule_group, and awscc_networkfirewall_rule_groups doesn't seem to return the managed rule groups AFAICT?