'Terraform aws_wafv2_ip_set delete ip on apply

I have a resource aws_wafv2_ip_set that is used by many different modules.

variable "addresses" {
  type    = set(string)
  default = []
}

resource "aws_wafv2_ip_set" "ip_set" {
  ip_address_version = "IPV4"
  name               = var.name
  scope              = "REGIONAL"
  addresses          = var.addresses
}

I need to create different ip sets that will be filled by a dynamic script from our admin section or directly from AWS console (not from terraform).

The problem is that every single apply detect that the ip set is not empty (like the var address), and so it delete all ip address added by console or by script.

How can I add aws_wafv2_ip_set without delete ip address on apply?

Thank you



Solution 1:[1]

According to the docs, adresses is an array of strings and is required.

Why don't you just go with the tf example:

resource "aws_wafv2_ip_set" "ip_set" {
  name               = "example"
  description        = "Example IP set"
  scope              = "REGIONAL"
  ip_address_version = "IPV4"
  addresses          = ["YOUR_IP_1", "YOUR_IP_2"]
}

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 baduker