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(updates.jenkins.io) restrict SA to only a few administrative IPs #570

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
2 changes: 0 additions & 2 deletions locals.tf
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ locals {
"keyserver.ubuntu.com" = ["162.213.33.8", "162.213.33.9"]
}

privatek8s_outbound_ip_cidr = "20.22.6.81/32"

default_tags = {
scope = "terraform-managed"
repository = "jenkins-infra/azure"
Expand Down
10 changes: 6 additions & 4 deletions publick8s.tf
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,19 @@ resource "azurerm_kubernetes_cluster" "publick8s" {
"%s/32",
flatten(
concat(
[for key, value in module.jenkins_infra_shared_data.admin_public_ips : value]
[for key, value in module.jenkins_infra_shared_data.admin_public_ips : value],
# privatek8s outbound IP (traffic routed trhough gateways)
module.jenkins_infra_shared_data.outbound_ips["privatek8s.jenkins.io"],
# trusted.ci subnet (UC agents need to execute mirrorbits scans)
module.jenkins_infra_shared_data.outbound_ips["trusted.ci.jenkins.io"],
module.jenkins_infra_shared_data.outbound_ips["trusted.sponsorship.ci.jenkins.io"],
)
)
),
# private VPN access
data.azurerm_subnet.private_vnet_data_tier.address_prefixes,
# privatek8s nodes subnet
data.azurerm_subnet.privatek8s_tier.address_prefixes,
[local.privatek8s_outbound_ip_cidr],
# trusted.ci subnet (UC agents need to execute mirrorbits scans)
formatlist("%s/32", module.jenkins_infra_shared_data.outbound_ips["trusted.ci.jenkins.io"]),
)
}

Expand Down
36 changes: 29 additions & 7 deletions updates.jenkins.io.tf
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,37 @@ resource "azurerm_resource_group" "updates_jenkins_io" {
}

resource "azurerm_storage_account" "updates_jenkins_io" {
name = "updatesjenkinsio"
resource_group_name = azurerm_resource_group.updates_jenkins_io.name
location = azurerm_resource_group.updates_jenkins_io.location
account_tier = "Standard"
account_replication_type = "LRS"
min_tls_version = "TLS1_2" # default value, needed for tfsec
public_network_access_enabled = "true" # Explicit default value, we want this storage account to be readable from anywhere
name = "updatesjenkinsio"
resource_group_name = azurerm_resource_group.updates_jenkins_io.name
location = azurerm_resource_group.updates_jenkins_io.location
account_tier = "Standard"
account_replication_type = "LRS"
min_tls_version = "TLS1_2" # default value, needed for tfsec

# No public access as the storage is only access through middlewares (mirrorbits) or Azure API (azcopy)
allow_nested_items_to_be_public = false
public_network_access_enabled = false

tags = local.default_tags

network_rules {
default_action = "Deny"
ip_rules = setunion(
# admins
formatlist(
"%s/30",
flatten(
concat(
[for key, value in module.jenkins_infra_shared_data.admin_public_ips : value],
module.jenkins_infra_shared_data.outbound_ips["trusted.ci.jenkins.io"],
module.jenkins_infra_shared_data.outbound_ips["trusted.sponsorship.ci.jenkins.io"],
module.jenkins_infra_shared_data.outbound_ips["privatek8s.jenkins.io"]
)
)
),
)
bypass = ["Metrics", "Logging", "AzureServices"]
}
}

resource "azurerm_storage_share" "updates_jenkins_io" {
Expand Down