-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k

Description
Description
Please provide a clear and concise description of the issue you are encountering, and a reproduction of your configuration (see the examples/*
directory for references that you can copy+paste and tailor to match your configs if you are unable to copy your exact configuration). The reproduction MUST be executable by running terraform init && terraform apply
without any further changes.
If your request is for a new feature, please use the Feature request
template.
- ✋ I have searched the open/closed issues and my issue is not listed.
⚠️ Note
Before you submit an issue, please perform the following first:
- Remove the local
.terraform
directory (! ONLY if state is stored remotely, which hopefully you are following that best practice!):rm -rf .terraform/
- Re-initialize the project root to pull down modules:
terraform init
- Re-attempt your terraform plan or apply and check if the issue still persists
Versions
-
Module version [Required]: 4.16.2 (latest)
-
Terraform version:
Terraform v1.3.6
on darwin_arm64 -
Provider version(s):
- provider registry.terraform.io/hashicorp/aws v4.45.0
- provider registry.terraform.io/hashicorp/local v2.2.3
- provider registry.terraform.io/hashicorp/time v0.9.1
- provider registry.terraform.io/hashicorp/tls v4.0.4
Reproduction Code [Required]
# create ingress security group, from rules
module "sg_with_prefix_lists" {
source = "terraform-aws-modules/security-group/aws"
version = "~> 4.16"
name = "Test SG"
description = "Security group to test prefix lists with custom rules"
vpc_id = data.aws_vpc.this.id
ingress_prefix_list_ids = [pl_one.id, pl_two.id]
ingress_with_cidr_blocks = [
{
from_port = 9000
to_port = 9000
protocol = 6 # "tcp"
description = "Arbitrary TCP port"
# prefix_list_ids = [pl_one.id, pl_two.id]
# prefix_list_ids = format("[%s]", join(",", [pl_one.id, pl_two.id]))
},
]
}
Steps to reproduce the behavior:
No. Yes. Attempted to use module to create security group with custom rules and prefix lists.Expected behavior
After using this module extensively in other contexts, I have started migrating my CIDR blocks into prefix lists. I first updated my named rules, which worked as-expected. When I got to my custom rules -- previously specified with CIDR blocks -- I expected the ingress_with_cidr_blocks
variable to work (without specifying a CIDR block) after exchanging "ingress_cidr_blocks" for "ingress_prefix_list_ids".
Actual behavior
The Terraform interpolation for the "cidr_blocks" variable appears to return a list with an empty string instead of an empty list, which results in an error in the resource.
Terminal Output Screenshot(s)
│ Error: "" is not a valid CIDR block: invalid CIDR address:
│
│ with module.sg_with_prefix_lists.aws_security_group_rule.ingress_with_cidr_blocks[0],
│ on .terraform/modules/sg_with_prefix_lists/main.tf line 197, in resource "aws_security_group_rule" "ingress_with_cidr_blocks":
│ 197: cidr_blocks = split(
│ 198: ",",
│ 199: lookup(
│ 200: var.ingress_with_cidr_blocks[count.index],
│ 201: "cidr_blocks",
│ 202: join(",", var.ingress_cidr_blocks),
│ 203: ),
│ 204: )
│
Additional context
FYI: I'm wrapping Terraform with Terragrunt.