Skip to content

Commit

Permalink
link network security group to bastion nic for public ssh access [MRX…
Browse files Browse the repository at this point in the history
…NM-52]
  • Loading branch information
hotzevzl committed Sep 13, 2024
1 parent a303f03 commit 0dc52cd
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions infrastructure/base/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ module "bastion" {
project_name = var.project_name
bastion_ssh_public_keys = var.bastion_ssh_public_keys
bastion_subnet_id = module.network.bastion_subnet_id
bastion_nsg_id = module.network.bastion_nsg_id
dns_zone = module.dns.dns_zone
}

Expand Down
5 changes: 5 additions & 0 deletions infrastructure/base/modules/bastion/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ resource "azurerm_network_interface" "bastion_nic" {
}
}

resource "azurerm_network_interface_security_group_association" "bastion_nic_nsg_association" {
network_interface_id = azurerm_network_interface.bastion_nic.id
network_security_group_id = var.bastion_nsg_id
}

resource "tls_private_key" "ssh_private_key" {
algorithm = "RSA"
rsa_bits = 4096
Expand Down
4 changes: 4 additions & 0 deletions infrastructure/base/modules/bastion/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ variable "bastion_subnet_id" {
description = "The id of the subnet where the bastion host will be placed"
}

variable "bastion_nsg_id" {
description = "The id of the network security group for the bastion host"
}

variable "dns_zone" {
description = "The Azure DNS zone where the bastion A record will be added"
}
4 changes: 4 additions & 0 deletions infrastructure/base/modules/network/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ output "bastion_subnet_id" {
value = azurerm_subnet.bastion_subnet.id
}

output "bastion_nsg_id" {
value = azurerm_network_security_group.bastion_nsg.id
}

output "firewall_subnet_id" {
value = azurerm_subnet.firewall_subnet.id
}
Expand Down

0 comments on commit 0dc52cd

Please sign in to comment.