From 97dc8ac6aa8f20b186abba1a6681b3463b7942b4 Mon Sep 17 00:00:00 2001 From: Stef Graces Date: Thu, 20 May 2021 04:36:18 +0200 Subject: [PATCH] Fixed deprecated list method (#168) * Fixed deprecated list method In terraform >= 0.15.0, the deprecated list method is removed. This causes the module to stop working on newer versions. List method has been changed to tolist method. For more information see: - https://www.terraform.io/docs/language/functions/tolist.html - https://github.com/hashicorp/terraform/blob/v0.15/CHANGELOG.md#0150-april-14-2021 * Change BUILD_TERRAFORM_VERSION in Dockerfile to 0.14.4 --- Dockerfile | 2 +- main.tf | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index 5d2a005..bce4590 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ # Pull the base image with given version. -ARG BUILD_TERRAFORM_VERSION="0.13.5" +ARG BUILD_TERRAFORM_VERSION="0.14.4" FROM mcr.microsoft.com/terraform-test:${BUILD_TERRAFORM_VERSION} ARG MODULE_NAME="terraform-azurerm-compute" diff --git a/main.tf b/main.tf index 5d9c897..c62f424 100644 --- a/main.tf +++ b/main.tf @@ -30,7 +30,7 @@ resource "azurerm_storage_account" "vm-sa" { } resource "azurerm_virtual_machine" "vm-linux" { - count = ! contains(list(var.vm_os_simple, var.vm_os_offer), "WindowsServer") && ! var.is_windows_image ? var.nb_instances : 0 + count = ! contains(tolist([var.vm_os_simple, var.vm_os_offer]), "WindowsServer") && ! var.is_windows_image ? var.nb_instances : 0 name = "${var.vm_hostname}-vmLinux-${count.index}" resource_group_name = data.azurerm_resource_group.vm.name location = coalesce(var.location, data.azurerm_resource_group.vm.location) @@ -139,7 +139,7 @@ resource "azurerm_virtual_machine" "vm-linux" { } resource "azurerm_virtual_machine" "vm-windows" { - count = (var.is_windows_image || contains(list(var.vm_os_simple, var.vm_os_offer), "WindowsServer")) ? var.nb_instances : 0 + count = (var.is_windows_image || contains(tolist([var.vm_os_simple, var.vm_os_offer]), "WindowsServer")) ? var.nb_instances : 0 name = "${var.vm_hostname}-vmWindows-${count.index}" resource_group_name = data.azurerm_resource_group.vm.name location = coalesce(var.location, data.azurerm_resource_group.vm.location) @@ -295,7 +295,7 @@ resource "azurerm_network_interface" "vm" { name = "${var.vm_hostname}-ip-${count.index}" subnet_id = var.vnet_subnet_id private_ip_address_allocation = "Dynamic" - public_ip_address_id = length(azurerm_public_ip.vm.*.id) > 0 ? element(concat(azurerm_public_ip.vm.*.id, list("")), count.index) : "" + public_ip_address_id = length(azurerm_public_ip.vm.*.id) > 0 ? element(concat(azurerm_public_ip.vm.*.id, tolist([""])), count.index) : "" } tags = var.tags