I have the following terraform file:
variable azure_network_interface_ip_configuration {
default = {
name = "testconfiguration1"
subnet_id = "1" #"${azurerm_subnet.test.id}"
private_ip_address_allocation = "Static"
private_ip_address = "10.0.2.5"
public_ip_address_id = "1" #"${azurerm_public_ip.test.id}"
}
type = object({ name=string, subnet_id=string, private_ip_address_allocation=string, private_ip_address=string, public_ip_address_id=string })
}
resource "azurerm_resource_group" "test" {
name = "experiment"
location = "westeurope"
}
resource "azurerm_virtual_network" "test" {
name = "test-network"
address_space = ["10.0.0.0/16"]
location = "${azurerm_resource_group.test.location}"
resource_group_name = "${azurerm_resource_group.test.name}"
}
resource "azurerm_subnet" "test" {
name = "acctsub"
resource_group_name = "${azurerm_resource_group.test.name}"
virtual_network_name = "${azurerm_virtual_network.test.name}"
address_prefix = "10.0.2.0/24"
}
resource "azurerm_public_ip" "test" {
name = "test-pip"
location = "${azurerm_resource_group.test.location}"
resource_group_name = "${azurerm_resource_group.test.name}"
allocation_method = "Dynamic"
idle_timeout_in_minutes = 30
tags = {
environment = "test"
}
}
resource "azurerm_network_interface" "test" {
name = "test-nic"
location = "${azurerm_resource_group.test.location}"
resource_group_name = "${azurerm_resource_group.test.name}"
ip_configuration = var.azure_network_interface_ip_configuration
}
But when I try to validate it, I get the follwing output.
Error: Unsupported argument
on main.tf line 48, in resource "azurerm_network_interface" "test": 48: ip_configuration = var.azure_network_interface_ip_configuration
An argument named "ip_configuration" is not expected here. Did you mean to define a block of type "ip_configuration"?
I just would like to use a variable as a block. I am using terraform 0.12.8. I know that I could set each parameter individually, but it would be far easier for me, to just set the complete block.