Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(ci.jenkins.io) allows SSH from private VPN and Jenkins access from internet #349

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 42 additions & 1 deletion ci.jenkins.io.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
resource "azurerm_resource_group" "ci_jenkins_io_controller" {
name = "ci-jenkins-io-controller"
location = "East US 2"

tags = local.default_tags
}

Expand Down Expand Up @@ -39,6 +39,47 @@ resource "azurerm_network_interface" "ci_jenkins_io" {
subnet_id = data.azurerm_subnet.ci_jenkins_io_controller.id
}
}
resource "azurerm_network_security_group" "ci_jenkins_io" {
name = "ci-jenkins-io"
location = azurerm_resource_group.ci_jenkins_io_controller.location
resource_group_name = azurerm_resource_group.ci_jenkins_io_controller.name
tags = local.default_tags
}
resource "azurerm_subnet_network_security_group_association" "ci_jenkins_io" {
subnet_id = data.azurerm_subnet.ci_jenkins_io_controller.id
network_security_group_id = azurerm_network_security_group.ci_jenkins_io.id
}
resource "azurerm_network_security_rule" "allow_ssh_from_private_vpn" {
name = "allow-ssh-from-private-vpn"
priority = 4000 # Higher priority wins
direction = "Inbound"
access = "Allow"
protocol = "Tcp"
source_port_range = "*"
destination_port_range = "22"
source_address_prefixes = data.azurerm_subnet.private_vnet_data_tier.address_prefixes
destination_address_prefix = azurerm_linux_virtual_machine.ci_jenkins_io.private_ip_address
resource_group_name = azurerm_resource_group.ci_jenkins_io_controller.name
network_security_group_name = azurerm_network_security_group.ci_jenkins_io.name
}
#tfsec:ignore:azure-network-no-public-ingress
resource "azurerm_network_security_rule" "allow_jenkins_from_internet" {
name = "allow-jenkins-from-internet"
priority = 3999 # Higher priority wins
direction = "Inbound"
access = "Allow"
protocol = "Tcp"
source_port_range = "*"
destination_port_ranges = [
"80", # HTTP
"443", # HTTPS
"50000", # Inbound protocol
]
source_address_prefix = "*"
destination_address_prefix = azurerm_linux_virtual_machine.ci_jenkins_io.public_ip_address
resource_group_name = azurerm_resource_group.ci_jenkins_io_controller.name
network_security_group_name = azurerm_network_security_group.ci_jenkins_io.name
}
resource "azurerm_managed_disk" "ci_jenkins_io_data" {
name = "ci-jenkins-io-data"
location = azurerm_resource_group.ci_jenkins_io_controller.location
Expand Down
5 changes: 1 addition & 4 deletions trusted.ci.jenkins.io.tf
Original file line number Diff line number Diff line change
Expand Up @@ -326,10 +326,7 @@ resource "azurerm_network_security_group" "trusted_ci_controller" {
name = data.azurerm_subnet.trusted_ci_controller.name
location = data.azurerm_resource_group.trusted.location
resource_group_name = data.azurerm_resource_group.trusted.name

# No security rule: using 'azurerm_network_security_rule' to allow composition across files

tags = local.default_tags
tags = local.default_tags
}

resource "azurerm_subnet_network_security_group_association" "trusted_ci_controller" {
Expand Down