Skip to content

Commit e6fc58c

Browse files
pv93bwhaley
andauthored
Add option to specify CIDR blocks to allow for ingress (#82)
* Add option to specify CIDR blocks to allow for ingress * Update modules/terraform-aws-alternat/main.tf Co-authored-by: Ben Whaley <[email protected]> --------- Co-authored-by: Ben Whaley <[email protected]>
1 parent 0141b69 commit e6fc58c

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

modules/terraform-aws-alternat/main.tf

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,16 @@ resource "aws_security_group_rule" "nat_instance_ingress" {
280280
source_security_group_id = local.nat_instance_ingress_sgs[count.index]
281281
}
282282

283+
resource "aws_security_group_rule" "nat_instance_ip_range_ingress" {
284+
count = length(var.ingress_security_group_cidr_blocks) > 0 ? 1 : 0
285+
286+
type = "ingress"
287+
protocol = "-1"
288+
from_port = 0
289+
to_port = 0
290+
security_group_id = aws_security_group.nat_instance.id
291+
cidr_blocks = var.ingress_security_group_cidr_blocks
292+
}
283293

284294
### NAT instance IAM
285295

modules/terraform-aws-alternat/variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,12 @@ variable "ingress_security_group_ids" {
7979
default = []
8080
}
8181

82+
variable "ingress_security_group_cidr_blocks" {
83+
description = "A list of CIDR blocks that are allowed by the NAT instance."
84+
type = list(string)
85+
default = []
86+
}
87+
8288
variable "lifecycle_heartbeat_timeout" {
8389
description = "The length of time, in seconds, that autoscaled NAT instances should wait in the terminate state before being fully terminated."
8490
type = number

0 commit comments

Comments
 (0)