I want to create a aws wafv2 ip set using terraform.I have two text file one is blacklist.txt and another is whitelist.txt
Below are the main.tf and variable.tf files
resource "aws_wafv2_ip_set" "this" {
count = var.ip_set_count
name = var.ip_set_name[count.index]
scope = var.ip_set_scope
ip_address_version = var.ip_address_version
addresses = split("\n", file(var.addresses[count.index]))
tags = var.ip_set_tags
}
variable "ip_set_count" {
type = number
default = 2
}
variable "ip_set_name" {
type = list(string)
default = ["IPSetRule01","IPSetRule02"]
}
variable "ip_set_scope" {
type = string
default = "REGIONAL"
}
variable "ip_address_version" {
type = string
default = "IPV4"
}
variable "addresses" {
type = list(string)
description = "The Filename to import IP sets. Specify one or more IP addresses contains by CIDR notation."
default = ["blacklist.txt", "whitelist.txt"]
}
Blacklist.txt containing below ips.
1.1.1.1/32
2.2.0.0/16
whitelist.txt containing below ips.
3.3.3.3/32
4.0.4.0/16
Now while run terraform apply it is give bellow error code.
Error creating WAFv2 IPSet: ValidationException: 1 validation error detected: Value, 10.1.11.0/16]' at 'addresses' failed to satisfy constraint: Member must satisfy constraint: [Member must have length less than or equal to 50, Member must have length greater than or equal to 1, Member must satisfy regular expression pattern: .*\S.*]
│ status code: 400, request id: ea4a5f1b-d482-463d-aa48-39ab2ad3af78
│
│ with aws_wafv2_ip_set.this[0],
│ on main.tf line 5, in resource "aws_wafv2_ip_set" "this":
│ 5: resource "aws_wafv2_ip_set" "this" {
Would appreciate any lead to get rid of this error.