Skip to content

Commit

Permalink
Merge pull request #110 from dduportal/fix/ci.jio/allow-inbound-jnlp-…
Browse files Browse the repository at this point in the history
…from-gateways

feat(ci.jenkins.io) allow inbound JNLP from public NAT gateways IPs instead of private subnet CIDRs as we use public DNS
  • Loading branch information
dduportal authored Jan 23, 2025
2 parents 79b85e4 + 6a737f4 commit a4c0449
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 20 deletions.
24 changes: 7 additions & 17 deletions eks-cijenkinsio-agents-2.tf
Original file line number Diff line number Diff line change
Expand Up @@ -133,25 +133,15 @@ module "cijenkinsio_agents_2" {
},
}

# Allow egress from nodes (and pods...)
# Allow JNLP egress from pods to controller
node_security_group_additional_rules = {
egress_jenkins_jnlp = {
description = "Allow egress to Jenkins TCP"
protocol = "TCP"
from_port = 50000
to_port = 50000
type = "egress"
cidr_blocks = ["0.0.0.0/0"]
ipv6_cidr_blocks = ["::/0"]
},
egress_http = {
description = "Allow egress to plain HTTP"
protocol = "TCP"
from_port = 80
to_port = 80
type = "egress"
cidr_blocks = ["0.0.0.0/0"]
ipv6_cidr_blocks = ["::/0"]
description = "Allow egress to Jenkins TCP"
protocol = "TCP"
from_port = 50000
to_port = 50000
type = "egress"
cidr_blocks = ["${aws_eip.ci_jenkins_io.public_ip}/32"]
},
}

Expand Down
6 changes: 3 additions & 3 deletions network-security.tf
Original file line number Diff line number Diff line change
Expand Up @@ -553,12 +553,12 @@ resource "aws_vpc_security_group_egress_rule" "allow_cifs_out_private_subnets" {
}

resource "aws_vpc_security_group_ingress_rule" "allow_jnlp_in_private_subnets" {
for_each = toset(module.vpc.private_subnets_cidr_blocks)
count = length(module.vpc.nat_public_ips)

description = "Allow inbound JNLP Jenkins Agent protocol from private subnet ${each.key}"
description = "Allow inbound JNLP Jenkins Agent protocol from agents outbound IP ${module.vpc.nat_public_ips[count.index]}"
security_group_id = aws_security_group.ci_jenkins_io_controller.id

cidr_ipv4 = each.key
cidr_ipv4 = "${module.vpc.nat_public_ips[count.index]}/32"
from_port = 50000
ip_protocol = "tcp"
to_port = 50000
Expand Down

0 comments on commit a4c0449

Please sign in to comment.