Skip to content

Commit

Permalink
feat: jumphost subnet
Browse files Browse the repository at this point in the history
Signed-off-by: Fredrik Klingenberg <[email protected]>
  • Loading branch information
fredrkl committed Nov 5, 2023
1 parent 5de714d commit 480d957
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 7 deletions.
9 changes: 5 additions & 4 deletions terraform/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,16 @@ module "network" {
module "aks" {
source = "./modules/aks"
resource_group = azurerm_resource_group.aks
subnet_id = module.network.aks_subnet_id
subnet_id = module.network.aks_dataplane_subnet_id

count = var.enable_aks ? 1 : 0
}

module "bastion" {
source = "./modules/bastion"
resource_group = azurerm_resource_group.aks
subnet_id = module.network.bastion_subnet_id
source = "./modules/bastion"
resource_group = azurerm_resource_group.aks
subnet_id = module.network.jumphost_subnet_id
subnet_jumphost_id = module.network.jumphost_subnet_id

count = var.enable_bastion ? 1 : 0
}
Expand Down
2 changes: 1 addition & 1 deletion terraform/modules/bastion/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ resource "azurerm_network_interface" "example" {

ip_configuration {
name = "internal"
subnet_id = var.subnet_id
subnet_id = var.subnet_jumphost_id
private_ip_address_allocation = "Dynamic"
}
}
Expand Down
7 changes: 6 additions & 1 deletion terraform/modules/bastion/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,10 @@ variable "resource_group" {

variable "subnet_id" {
type = string
description = "The ID of the subnet to place the AKS nodes."
description = "The ID of the subnet to place the bastion in."
}

variable "subnet_jumphost_id" {
type = string
description = "The ID of the subnet to place vm interface in"
}
6 changes: 6 additions & 0 deletions terraform/modules/network/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ resource "azurerm_subnet" "api-server" {
virtual_network_name = azurerm_virtual_network.example.name
address_prefixes = ["10.1.3.0/27"]
}
resource "azurerm_subnet" "jumphost_subnet_id" {
name = "jumphost_subnet_id"
resource_group_name = var.resource_group.name
virtual_network_name = azurerm_virtual_network.example.name
address_prefixes = ["10.1.3.40/27"]
}

resource "azurerm_network_security_group" "example" {
name = "example-nsg"
Expand Down
12 changes: 11 additions & 1 deletion terraform/modules/network/outputs.tf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
output "aks_subnet_id" {
output "aks_dataplane_subnet_id" {
description = "The ID of the subnet"
value = azurerm_subnet.aks-data-plane.id
}
Expand All @@ -7,3 +7,13 @@ output "bastion_subnet_id" {
description = "The ID of the subnet"
value = azurerm_subnet.bastion.id
}

output "api_server_subnet_id" {
description = "The ID of the subnet"
value = azurerm_subnet.api-server.id
}

output "jumphost_subnet_id" {
description = "The ID of the subnet"
value = azurerm_subnet.jumphost_subnet_id.id
}

0 comments on commit 480d957

Please sign in to comment.