diff --git a/quickstart/201-vmss-packer-jumpbox/main.tf b/quickstart/201-vmss-packer-jumpbox/main.tf index 5107d95a..3c525ee5 100644 --- a/quickstart/201-vmss-packer-jumpbox/main.tf +++ b/quickstart/201-vmss-packer-jumpbox/main.tf @@ -15,9 +15,7 @@ resource "azurerm_resource_group" "vmss" { name = var.resource_group_name location = var.location - tags = { - environment = "codelab" - } + tags = var.tags } resource "azurerm_virtual_network" "vmss" { @@ -26,16 +24,14 @@ resource "azurerm_virtual_network" "vmss" { location = var.location resource_group_name = azurerm_resource_group.vmss.name - tags = { - environment = "codelab" - } + tags = var.tags } resource "azurerm_subnet" "vmss" { name = "vmss-subnet" resource_group_name = azurerm_resource_group.vmss.name virtual_network_name = azurerm_virtual_network.vmss.name - address_prefix = "10.0.2.0/24" + address_prefixes = ["10.0.2.0/24"] } resource "azurerm_public_ip" "vmss" { @@ -43,11 +39,8 @@ resource "azurerm_public_ip" "vmss" { location = var.location resource_group_name = azurerm_resource_group.vmss.name allocation_method = "Static" - domain_name_label = azurerm_resource_group.vmss.name - tags = { - environment = "codelab" - } + tags = var.tags } resource "azurerm_lb" "vmss" { @@ -60,13 +53,10 @@ resource "azurerm_lb" "vmss" { public_ip_address_id = azurerm_public_ip.vmss.id } - tags = { - environment = "codelab" - } + tags = var.tags } resource "azurerm_lb_backend_address_pool" "bpepool" { - resource_group_name = azurerm_resource_group.vmss.name loadbalancer_id = azurerm_lb.vmss.id name = "BackEndAddressPool" } @@ -91,11 +81,11 @@ resource "azurerm_lb_rule" "lbnatrule" { } data "azurerm_resource_group" "image" { - name = "myResourceGroup" + name = var.packer_resource_group_name } data "azurerm_image" "image" { - name = "myPackerImage" + name = var.packer_image_name resource_group_name = data.azurerm_resource_group.image.name } @@ -156,9 +146,7 @@ resource "azurerm_virtual_machine_scale_set" "vmss" { } } - tags = { - environment = "codelab" - } + tags = var.tags } resource "azurerm_public_ip" "jumpbox" { @@ -166,11 +154,8 @@ resource "azurerm_public_ip" "jumpbox" { location = var.location resource_group_name = azurerm_resource_group.vmss.name allocation_method = "Static" - domain_name_label = "${azurerm_resource_group.vmss.name}-ssh" - tags = { - environment = "codelab" - } + tags = var.tags } resource "azurerm_network_interface" "jumpbox" { @@ -185,9 +170,7 @@ resource "azurerm_network_interface" "jumpbox" { public_ip_address_id = azurerm_public_ip.jumpbox.id } - tags = { - environment = "codelab" - } + tags = var.tags } resource "azurerm_virtual_machine" "jumpbox" { @@ -226,8 +209,6 @@ resource "azurerm_virtual_machine" "jumpbox" { } } - tags = { - environment = "codelab" - } + tags = var.tags } diff --git a/quickstart/201-vmss-packer-jumpbox/readme.md b/quickstart/201-vmss-packer-jumpbox/readme.md index c8199988..348009b3 100644 --- a/quickstart/201-vmss-packer-jumpbox/readme.md +++ b/quickstart/201-vmss-packer-jumpbox/readme.md @@ -2,16 +2,27 @@ This template deploys an Azure virtual machine scale set with a jumpbox from a Packer custom image. -## Resources - | Terraform Resource Type | Description | | - | - | -| `azurerm_resource_group` | The resource group all resources are deployed into | +[azurerm_image](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/shared_image) | Manages a Shared Image within a Shared Image Gallery.| +[azurerm_lb](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/lb) | Manages a Load Balancer Resource. | +[azurerm_lb_backend_address_pool](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/lb_backend_address_pool) | Manages a Load Balancer Backend Address Pool. | +[azurerm_lb_probe](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/lb_probe) | Manages a LoadBalancer Probe Resource. | +[azurerm_lb_rule](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/lb_rule) | Manages a Load Balancer Rule. | +[azurerm_network_interface](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/network_interface) | Manages a Network Interface. | +[azurerm_public_ip](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/public_ip) | Manages a Public IP Address. | +[azurerm_resource_group](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/resource_group) | Manages a Resource Group. | +[azurerm_subnet](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/subnet) | Manages a subnet. Subnets represent network segments within the IP space defined by the virtual network. | +[azurerm_virtual_machine](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/virtual_machine) | Manages a Virtual Machine. | +[azurerm_virtual_machine_scale_set](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/virtual_machine_scale_set) | Manages a virtual machine scale set. | +[azurerm_virtual_network](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/virtual_network) | Manages a virtual network including any configured subnets. Each subnet can optionally be configured with a security group to be associated with the subnet. | ## Variables | Name | Description | |-|-| +| `packer_resource_group_name` | Name of the resource group in which the Packer image will be created | +| `packer_image_name` | Name of the Packer image | | `resource_group_name` | Name of the resource group in which the resources will be created | | `location` | Location where resources will be create | | `tags` | Map of the tags to use for the resources that are deployed | @@ -22,4 +33,4 @@ This template deploys an Azure virtual machine scale set with a jumpbox from a P ## Example To see how to run this example, see [Create an Azure virtual machine scale set from a Packer custom image by using Terraform -](https://docs.microsoft.com/azure/developer/terraform/create-vm-scaleset-network-disks-using-packer-hcl#create-an-azure-image-by-using-packer). \ No newline at end of file +](https://docs.microsoft.com/azure/developer/terraform/create-vm-scaleset-network-disks-using-packer-hcl#create-an-azure-image-by-using-packer). diff --git a/quickstart/201-vmss-packer-jumpbox/ubuntu.json b/quickstart/201-vmss-packer-jumpbox/ubuntu.json new file mode 100644 index 00000000..efd4eaf6 --- /dev/null +++ b/quickstart/201-vmss-packer-jumpbox/ubuntu.json @@ -0,0 +1,38 @@ +{ + "builders": [{ + "type": "azure-arm", + + "client_id": "0bfc2293-4d69-49b5-83f7-bf0d60d20c45", + "client_secret": "G3.6ytCh44Kcla~_JRPBDLkzsXLOa3edDL", + "tenant_id": "c3fd441d-b8ad-487e-aa27-453079018fca", + "subscription_id": "b162117f-53fa-4f42-8c77-6a65ca966c40", + + "managed_image_resource_group_name": "myPackerImages", + "managed_image_name": "myPackerImage", + + "os_type": "Linux", + "image_publisher": "Canonical", + "image_offer": "UbuntuServer", + "image_sku": "16.04-LTS", + + "azure_tags": { + "dept": "Engineering", + "task": "Image deployment" + }, + + "location": "East US", + "vm_size": "Standard_DS2_v2" + }], + "provisioners": [{ + "execute_command": "chmod +x {{ .Path }}; {{ .Vars }} sudo -E sh '{{ .Path }}'", + "inline": [ + "apt-get update", + "apt-get upgrade -y", + "apt-get -y install nginx", + + "/usr/sbin/waagent -force -deprovision+user && export HISTSIZE=0 && sync" + ], + "inline_shebang": "/bin/sh -x", + "type": "shell" + }] + } \ No newline at end of file diff --git a/quickstart/201-vmss-packer-jumpbox/variables.tf b/quickstart/201-vmss-packer-jumpbox/variables.tf index 574d720c..992cfeba 100644 --- a/quickstart/201-vmss-packer-jumpbox/variables.tf +++ b/quickstart/201-vmss-packer-jumpbox/variables.tf @@ -1,3 +1,18 @@ +variable "packer_resource_group_name" { + description = "Name of the resource group in which the Packer image will be created" + default = "myPackerImages" +} + +variable "packer_image_name" { + description = "Name of the Packer image" + default = "myPackerImage" +} + +variable "resource_group_name" { + description = "Name of the resource group in which the Packer image will be created" + default = "myPackerImages" +} + variable "resource_group_name" { description = "Name of the resource group in which the resources will be created" default = "myResourceGroup"