Skip to content

Commit

Permalink
Update to 1.0 provider, latest script extensions (Azure#11)
Browse files Browse the repository at this point in the history
* provider 1.0, script extensions latest

* valid default cmd_extension

* azurerm provider 1.0

* Remove unused variable

* Update to 2.0 script extension

* Fix lb ports

* Minor fixes

* fix lint
  • Loading branch information
dtzar authored and VaijanathB committed Jan 26, 2018
1 parent 58e04e3 commit bf71c7c
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 49 deletions.
66 changes: 30 additions & 36 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Deploys a group of Virtual Machines exposed to a public IP via a Load Balancer

This Terraform module deploys a Virtual Machines Scale Set in Azure and opens the specified ports on the loadbalancer for external access and returns the id of the VM scale set deployed.

This module requires a network and loadbalancer to be provider separately. You can provision them with the "Azure/network/azurerm" and "Azure/loadbanacer/azurerm" modules.
This module requires a network and loadbalancer to be provider separately. You can provision them with the "Azure/network/azurerm" and "Azure/loadbalancer/azurerm" modules.

[![Build Status](https://travis-ci.org/Azure/terraform-azurerm-computegroup.svg?branch=master)](https://travis-ci.org/Azure/terraform-azurerm-computegroup)

Expand All @@ -14,27 +14,29 @@ Using the `vm_os_simple`:

```hcl
provider "azurerm" {
version = "~> 0.3"
version = "~> 1.0"
}
variable "resource_group_name" {
default = "terraform-test"
}
module "network" {
source = "Azure/network/azurerm"
location = "westus"
source = "Azure/network/azurerm"
location = "westus"
resource_group_name = "${var.resource_group_name}"
}
module "loadbalancer" {
source = "Azure/loadbalancer/azurerm"
source = "Azure/loadbalancer/azurerm"
resource_group_name = "${var.resource_group_name}"
location = "westus"
prefix = "terraform-test"
"lb_port" {
http = [ "80", "Tcp", "80"]
}
location = "westus"
prefix = "terraform-test"
lb_port = {
http = ["80", "Tcp", "80"]
https = ["443", "Tcp", "443"]
#ssh = ["22", "Tcp", "22"]
}
}
module "computegroup" {
Expand All @@ -50,10 +52,6 @@ module "computegroup" {
vnet_subnet_id = "${module.network.vnet_subnets[0]}"
load_balancer_backend_address_pool_ids = "${module.loadbalancer.azurerm_lb_backend_address_pool_id}"
cmd_extension = "sudo apt-get -y install nginx"
lb_port = {
http = ["80", "Tcp", "80"]
https = ["443", "Tcp", "443"]
}
tags = {
environment = "dev"
costcenter = "it"
Expand All @@ -71,27 +69,29 @@ Using the `vm_os_publisher`, `vm_os_offer` and `vm_os_sku`
```hcl
provider "azurerm" {
version = "~> 0.3"
version = "~> 1.0"
}
variable "resource_group_name" {
default = "terraform-test"
}
module "network" {
source = "Azure/network/azurerm"
location = "westus"
source = "Azure/network/azurerm"
location = "westus"
resource_group_name = "${var.resource_group_name}"
}
module "loadbalancer" {
source = "Azure/loadbalancer/azurerm"
source = "Azure/loadbalancer/azurerm"
resource_group_name = "${var.resource_group_name}"
location = "westus"
prefix = "terraform-test"
"lb_port" {
http = [ "80", "Tcp", "80"]
}
location = "westus"
prefix = "terraform-test"
lb_port = {
http = ["80", "Tcp", "80"]
https = ["443", "Tcp", "443"]
#ssh = ["22", "Tcp", "22"]
}
}
module "computegroup" {
Expand All @@ -109,10 +109,6 @@ module "computegroup" {
vnet_subnet_id = "${module.network.vnet_subnets[0]}"
load_balancer_backend_address_pool_ids = "${module.loadbalancer.azurerm_lb_backend_address_pool_id}"
cmd_extension = "sudo apt-get -y install nginx"
lb_port = {
http = ["80", "Tcp", "80"]
https = ["443", "Tcp", "443"]
}
tags = {
environment = "dev"
costcenter = "it"
Expand All @@ -129,7 +125,7 @@ The module does not expose direct access to each node of the VM scale set for se

```hcl
provider "azurerm" {
version = "~> 0.3"
version = "~> 1.0"
}
variable "resource_group_name" {
Expand All @@ -149,11 +145,12 @@ module "network" {
module "loadbalancer" {
source = "Azure/loadbalancer/azurerm"
resource_group_name = "${var.resource_group_name}"
location = "${var.location}"
prefix = "terraform-test"
"lb_port" {
http = [ "80", "Tcp", "80"]
}
location = "${var.location}"
prefix = "terraform-test"
lb_port = {
http = ["80", "Tcp", "80"]
https = ["443", "Tcp", "443"]
}
}
module "computegroup" {
Expand All @@ -171,9 +168,6 @@ module "computegroup" {
vnet_subnet_id = "${module.network.vnet_subnets[0]}"
load_balancer_backend_address_pool_ids = "${module.loadbalancer.azurerm_lb_backend_address_pool_id}"
cmd_extension = "sudo apt-get -y install nginx"
lb_port = {
http = ["80", "Tcp", "80"]
}
tags = {
environment = "codelab"
}
Expand Down
12 changes: 6 additions & 6 deletions main.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
provider "azurerm" {
version = "~> 0.3"
version = "~> 1.0"
}

module "os" {
Expand Down Expand Up @@ -77,13 +77,13 @@ resource "azurerm_virtual_machine_scale_set" "vm-linux" {

extension {
name = "vmssextension"
publisher = "Microsoft.OSTCExtensions"
type = "CustomScriptForLinux"
type_handler_version = "1.2"
publisher = "Microsoft.Azure.Extensions"
type = "CustomScript"
type_handler_version = "2.0"

settings = <<SETTINGS
{
"commandToExecute": "${var.cmd_extension}"
"script": "${base64encode("${var.cmd_extension}")}"
}
SETTINGS
}
Expand Down Expand Up @@ -146,7 +146,7 @@ resource "azurerm_virtual_machine_scale_set" "vm-windows" {
name = "vmssextension"
publisher = "Microsoft.Compute"
type = "CustomScriptExtension"
type_handler_version = "1.8"
type_handler_version = "1.9"

settings = <<SETTINGS
{
Expand Down
2 changes: 1 addition & 1 deletion test/integration/fixtures/main.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
provider "azurerm" {
version = "~> 0.3"
version = "~> 1.0"
}

module "network" {
Expand Down
7 changes: 1 addition & 6 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -91,14 +91,9 @@ variable "load_balancer_backend_address_pool_ids" {
description = "The id of the backend address pools of the loadbalancer to which the VM scale set is attached"
}

variable "lb_port" {
description = "Protocols to be used for lb health probes and rules. [frontend_port, protocol, backend_port]"
default = {}
}

variable "cmd_extension" {
description = "Command to be excuted by the custom script extension"
default = ""
default = "echo hello"
}

variable "tags" {
Expand Down

0 comments on commit bf71c7c

Please sign in to comment.