Skip to content

Commit 02775f8

Browse files
committed
link network security group to bastion nic for public ssh access [MRXNM-52]
1 parent 7c2c682 commit 02775f8

File tree

4 files changed

+14
-0
lines changed

4 files changed

+14
-0
lines changed

infrastructure/base/main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ module "bastion" {
3939
project_name = var.project_name
4040
bastion_ssh_public_keys = var.bastion_ssh_public_keys
4141
bastion_subnet_id = module.network.bastion_subnet_id
42+
bastion_nsg_id = module.network.bastion_nsg_id
4243
dns_zone = module.dns.dns_zone
4344
}
4445

infrastructure/base/modules/bastion/main.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ resource "azurerm_network_interface" "bastion_nic" {
2323
}
2424
}
2525

26+
resource "azurerm_network_interface_security_group_association" "bastion_nic_nsg_association" {
27+
network_interface_id = azurerm_network_interface.bastion_nic.id
28+
network_security_group_id = var.bastion_nsg_id
29+
}
30+
2631
resource "tls_private_key" "ssh_private_key" {
2732
algorithm = "RSA"
2833
rsa_bits = 4096

infrastructure/base/modules/bastion/variables.tf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ variable "bastion_subnet_id" {
2121
description = "The id of the subnet where the bastion host will be placed"
2222
}
2323

24+
variable "bastion_nsg_id" {
25+
description = "The id of the network security group for the bastion host"
26+
}
27+
2428
variable "dns_zone" {
2529
description = "The Azure DNS zone where the bastion A record will be added"
2630
}

infrastructure/base/modules/network/outputs.tf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ output "bastion_subnet_id" {
2626
value = azurerm_subnet.bastion_subnet.id
2727
}
2828

29+
output "bastion_nsg_id" {
30+
value = azurerm_network_security_group.bastion_nsg.id
31+
}
32+
2933
output "firewall_subnet_id" {
3034
value = azurerm_subnet.firewall_subnet.id
3135
}

0 commit comments

Comments
 (0)