Skip to content

Commit

Permalink
update (#36)
Browse files Browse the repository at this point in the history
  • Loading branch information
yupwei68 authored Sep 28, 2020
1 parent cfe5948 commit c5bc59e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ module "vnet" {
resource "azurerm_network_security_group" "ssh" {
name = "ssh"
location = "westus"
resource_group_name = "${var.resource_group_name}"
resource_group_name = azurerm_resource_group.example.name
location = azurerm_resource_group.example.location
security_rule {
name = "test123"
Expand Down Expand Up @@ -152,9 +152,9 @@ module "vnet" {
}
resource "azurerm_route_table" "example" {
location = azurerm_resource_group.example.location
name = "MyRouteTable"
resource_group_name = azurerm_resource_group.example.name
location = azurerm_resource_group.example.location
}
resource "azurerm_route" "example" {
Expand Down
16 changes: 7 additions & 9 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -21,23 +21,21 @@ resource "azurerm_subnet" "subnet" {
service_endpoints = lookup(var.subnet_service_endpoints, var.subnet_names[count.index], null)
}

data "azurerm_subnet" "import" {
for_each = var.nsg_ids
name = each.key
resource_group_name = data.azurerm_resource_group.vnet.name
virtual_network_name = azurerm_virtual_network.vnet.name

depends_on = [azurerm_subnet.subnet]
locals {
azurerm_subnets = {
for index, subnet in azurerm_subnet.subnet :
subnet.name => subnet.id
}
}

resource "azurerm_subnet_network_security_group_association" "vnet" {
for_each = var.nsg_ids
subnet_id = data.azurerm_subnet.import[each.key].id
subnet_id = local.azurerm_subnets[each.key]
network_security_group_id = each.value
}

resource "azurerm_subnet_route_table_association" "vnet" {
for_each = var.route_tables_ids
route_table_id = each.value
subnet_id = data.azurerm_subnet.import[each.key].id
subnet_id = local.azurerm_subnets[each.key]
}

0 comments on commit c5bc59e

Please sign in to comment.