-
Notifications
You must be signed in to change notification settings - Fork 10
/
pkg.origin.jenkins.io.tf
63 lines (54 loc) · 2.17 KB
/
pkg.origin.jenkins.io.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
data "aws_instance" "pkg_origin_jenkins_io" {
filter {
name = "tag:Name"
values = ["jenkins-pkg"]
}
}
resource "aws_network_interface_sg_attachment" "ssh_to_pkg" {
security_group_id = aws_security_group.restricted_ssh.id
network_interface_id = data.aws_instance.pkg_origin_jenkins_io.network_interface_id
}
resource "aws_network_interface_sg_attachment" "http_to_pkg" {
security_group_id = aws_security_group.unrestricted_http.id
network_interface_id = data.aws_instance.pkg_origin_jenkins_io.network_interface_id
}
resource "aws_network_interface_sg_attachment" "pkg" {
security_group_id = aws_security_group.pkg.id
network_interface_id = data.aws_instance.pkg_origin_jenkins_io.network_interface_id
}
resource "aws_security_group" "pkg" {
name = "pkg"
description = "Custom network rules for the pkg VM (pkg.origin.jenkins AND updates.jenkins.io)"
vpc_id = data.aws_vpc.default.id
tags = local.common_tags
}
resource "aws_vpc_security_group_egress_rule" "allow_outbound_ssh" {
for_each = toset([
for ip in flatten(concat(
module.jenkins_infra_shared_data.outbound_ips["archives.jenkins.io"], # Sync to archives.jenkins.io with SSH/Rsync
module.jenkins_infra_shared_data.external_service_ips["ftp-osl.osuosl.org"], # Sync to OSUOSL
)) : ip
if can(cidrnetmask("${ip}/32"))
])
description = "Allow outbound SSH for sync"
security_group_id = aws_security_group.pkg.id
cidr_ipv4 = "${each.value}/32"
from_port = 22
ip_protocol = "tcp"
to_port = 22
}
resource "aws_vpc_security_group_egress_rule" "allow_outbound_rsync" {
for_each = toset([
for ip in flatten(concat(
module.jenkins_infra_shared_data.outbound_ips["archives.jenkins.io"], # Sync to archives.jenkins.io with SSH/Rsync
module.jenkins_infra_shared_data.external_service_ips["ftp-osl.osuosl.org"], # Sync to OSUOSL
)) : ip
if can(cidrnetmask("${ip}/32"))
])
description = "Allow outbound SSH for sync"
security_group_id = aws_security_group.pkg.id
cidr_ipv4 = "${each.value}/32"
from_port = 387
ip_protocol = "tcp"
to_port = 387
}