PaloAltoNetworks / terraform-azurerm-vmseries-modules

Terraform Reusable Modules for VM-Series on Azure
https://registry.terraform.io/modules/PaloAltoNetworks/vmseries-modules/azurerm/latest
MIT License
49 stars 59 forks source link

vnet module errors out when used with Terraform v1.1.0 #134

Closed migara closed 2 years ago

migara commented 2 years ago

Describe the bug

The following modules does not work with Terraform 1.1.0. Switching to 1.0.10 fixed the issue.

Current behavior


host> vmseries (jolly-branch2) $ terraform --version
Terraform v1.0.10
on darwin_amd64
+ provider registry.terraform.io/hashicorp/azurerm v2.64.0
+ provider registry.terraform.io/hashicorp/random v3.1.0

Your version of Terraform is out of date! The latest version
is 1.1.0. You can update by downloading from https://www.terraform.io/downloads.html
host> vmseries (jolly-branch2) $ tfswitch
Reading required version from terraform file, constraint: >= 0.13, < 2.0
Matched version: 1.1.0
Downloading https://releases.hashicorp.com/terraform/1.1.0/terraform_1.1.0_darwin_amd64.zip to terraform_1.1.0_darwin_amd64.zip
Downloading ...
20089311 bytes downloaded.
Switched terraform to version "1.1.0" 
host> vmseries (jolly-branch2) $ terraform plan --var-file=terraform-sj.tfvars
╷
│ Error: Inconsistent conditional result types
│ 
│   on ../../modules/vnet/main.tf line 19, in locals:
│   19:   virtual_network = var.create_virtual_network ? azurerm_virtual_network.this[0] : data.azurerm_virtual_network.this[0]
│     ├────────────────
│     │ azurerm_virtual_network.this[0] is a object, known only after apply
│     │ data.azurerm_virtual_network.this[0] is a object, known only after apply
│     │ var.create_virtual_network is a bool, known only after apply
│ 
│ The true and false result expressions must have consistent types. The given expressions are object and object, respectively.
╵
host> vmseries (jolly-branch2) $ tfswitch -help
unknown option: -e
Usage: tfswitch [-hluv] [-b value] [-p value] [-s value] [parameters ...]
 -b, --bin=value  Custom binary path. Ex: /Users/username/bin/terraform
 -h, --help       Displays help message
 -l, --list-all   List all versions of terraform - including beta and rc
 -p, --latest-pre=value
                  Latest pre-release implicit version. Ex: tfswitch
                  --latest-pre 0.13 downloads 0.13.0-rc1 (latest)
 -s, --latest-stable=value
                  Latest implicit version. Ex: tfswitch --latest 0.13
                  downloads 0.13.5 (latest)
 -u, --latest     Get latest stable version
 -v, --version    Displays the version of tfswitch
host> vmseries (jolly-branch2) $ tfswitch -l
✔ 1.0.10 *recent
Switched terraform to version "1.0.10" 
host>vmseries (jolly-branch2) $ terraform plan --var-file=terraform-sj.tfvars
Acquiring state lock. This may take a few moments...
module.vnet.azurerm_network_security_group.this["FW-Untrust_nsg"]: Refreshing state... [id=/subscriptions/xxx-xxx-xxx/resourceGroups/test/providers/Microsoft.Network/networkSecurityGroups/FW-Untrust_nsg]
module.vnet.azurerm_network_security_group.this["FW-management_nsg"]: Refreshing state... [id=/subscriptions/xxx-xxx-xxx/resourceGroups/test/providers/Microsoft.Network/networkSecurityGroups/FW-management_nsg]
module.vnet.azurerm_network_security_group.this["FW-Trust_nsg"]: Refreshing state... [id=/subscriptions/xxx-xxx-xxx/resourceGroups/test/providers/Microsoft.Network/networkSecurityGroups/FW-Trust_nsg]
module.vnet.azurerm_route_table.this["mgmt_route_table"]: Refreshing state... [id=/subscriptions/xxx-xxx-xxx/resourceGroups/test/providers/Microsoft.Network/routeTables/mgmt_route_table]
module.vnet.azurerm_route_table.this["public_route_table"]: Refreshing state... [id=/subscriptions/xxx-xxx-xxx/resourceGroups/test/providers/Microsoft.Network/routeTables/public_route_table]
module.vnet.azurerm_route_table.this["private_route_table"]: Refreshing state... [id=/subscriptions/xxx-xxx-xxx/resourceGroups/test/providers/Microsoft.Network/routeTables/private_route_table]
module.vnet.azurerm_virtual_network.this[0]: Refreshing state... [id=/subscriptions/xxx-xxx-xxx/resourceGroups/test/providers/Microsoft.Network/virtualNetworks/T-Vnet]
module.vnet.azurerm_subnet.this["FW-Trust"]: Refreshing state... [id=/subscriptions/xxx-xxx-xxx/resourceGroups/test/providers/Microsoft.Network/virtualNetworks/T-Vnet/subnets/FW-Trust]
module.vnet.azurerm_subnet.this["FW-management"]: Refreshing state... [id=/subscriptions/xxx-xxx-xxx/resourceGroups/test/providers/Microsoft.Network/virtualNetworks/T-Vnet/subnets/FW-management]
module.vnet.azurerm_subnet.this["FW-Untrust"]: Refreshing state... [id=/subscriptions/xxx-xxx-xxx/resourceGroups/test/providers/Microsoft.Network/virtualNetworks/T-Vnet/subnets/FW-Untrust]
module.vnet.azurerm_subnet_network_security_group_association.this["FW-Untrust"]: Refreshing state... [id=/subscriptions/xxx-xxx-xxx/resourceGroups/test/providers/Microsoft.Network/virtualNetworks/T-Vnet/subnets/FW-Untrust]
module.vnet.azurerm_subnet_route_table_association.this["FW-Trust"]: Refreshing state... [id=/subscriptions/xxx-xxx-xxx/resourceGroups/test/providers/Microsoft.Network/virtualNetworks/T-Vnet/subnets/FW-Trust]
module.vnet.azurerm_subnet_route_table_association.this["FW-Untrust"]: Refreshing state... [id=/subscriptions/xxx-xxx-xxx/resourceGroups/test/providers/Microsoft.Network/virtualNetworks/T-Vnet/subnets/FW-Untrust]
module.vnet.azurerm_subnet_network_security_group_association.this["FW-Trust"]: Refreshing state... [id=/subscriptions/xxx-xxx-xxx/resourceGroups/test/providers/Microsoft.Network/virtualNetworks/T-Vnet/subnets/FW-Trust]
michalbil commented 2 years ago

It seems that this issue is caused by a regression introduced in terraform 1.1.0, for more details please take a look at issues linked under release notes for 1.1.1. When 1.1.1+ is used the error is no longer returned. Additionally, it's worth to point out that users should move directly to 1.1.2, since there is another nasty bug still present in 1.1.1. Again - more details in release notes for 1.1.2.