0
votes

Trying to get the newly GA'ed Azure Application Security Groups to work via Terraform. Documentation per https://www.terraform.io/docs/providers/azurerm/r/network_interface.html shows application_security_group_ids as a valid parameter to a NIC, but when attempting to terraform plan the code below I am getting

"Error: azurerm_network_interface.my_nic: : invalid or unknown key: application_security_group_ids"

resource "azurerm_resource_group" "my_vnet_rg" {
  name = "my_vnet_rg"
  location = "US East 2"
}

resource "azurerm_virtual_network" "my_vnet" {
  name = "my_vnet"
  resource_group_name = "my_vnet_rg"
  address_space = ["10.10.0.0/16"]
  location = "US East 2"
}

resource "azurerm_subnet" "my_subnet" {
  name                 = "my_subnet"
  resource_group_name  = "my_vnet_rg"
  virtual_network_name = "my_vnet"
  address_prefix       = "10.10.10.0/24"
  network_security_group_id = "${azurerm_network_security_group.my_nsg.id}"
}

resource "azurerm_network_security_group" "my_nsg" {
  name                = "my_nsg"
  location            = "US East 2"
  resource_group_name = "my_vnet_rg"
}

resource "azurerm_application_security_group" "my_asg" {
  name                = "my_asg"
  location            = "US East 2"
  resource_group_name = "my_vnet_rg"
}

resource "azurerm_network_security_rule" "my_httprule" {
  name                        = "my_httprule"
  priority                    = 100
  direction                   = "inbound"
  access                      = "Allow"
  protocol                    = "Tcp"
  source_port_range           = "*"
  destination_port_range      = "80"
  source_address_prefix       = "*"
  destination_application_security_group_ids = ["${azurerm_application_security_group.my_asg.id}"]
  resource_group_name         = "my_vnet_rg"
  network_security_group_name = "my_nsg"
}

resource "azurerm_network_interface" "my_nic" {
  name                = "my_nic"
  location            = "US East 2"
  resource_group_name = "my_vnet_rg"
  application_security_group_ids = ["${azurerm_application_security_group.my_asg.id}"]

  ip_configuration {
    name                          = "my_nicconf"
    subnet_id                     = "${azurerm_subnet.my_subnet.id}"
    private_ip_address_allocation = "dynamic"
  }
}

Terraform v0.11.6, provider.azurerm v1.3.2

Is this a bug?

1

1 Answers

2
votes

Parameter was in the wrong block, needed to be in the ip_configuration subblock:

resource "azurerm_network_interface" "my_nic" {
  name                = "my_nic"
  location            = "US East 2"
  resource_group_name = "my_vnet_rg"


  ip_configuration {
    name                          = "my_nicconf"
    subnet_id                     = "${azurerm_subnet.my_subnet.id}"
    private_ip_address_allocation = "dynamic"
    application_security_group_ids = ["${azurerm_application_security_group.my_asg.id}"]
  }
}