Skip to content

Commit

Permalink
Fixed deprecated list method (#168)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
stgrace authored May 20, 2021
1 parent 01fee36 commit 97dc8ac
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
6 changes: 3 additions & 3 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 97dc8ac

Please sign in to comment.