Merge pull request #154 from TomArcherMsft/UserStory60501-devtest-lab
User Story 60501: devtest-labs
This commit is contained in:
commit
9deef32e75
55
quickstart/101-devtest-labs/main.tf
Normal file
55
quickstart/101-devtest-labs/main.tf
Normal file
@ -0,0 +1,55 @@
|
||||
resource "random_pet" "rg_name" {
|
||||
prefix = var.resource_group_name_prefix
|
||||
}
|
||||
|
||||
resource "azurerm_resource_group" "rg" {
|
||||
name = random_pet.rg_name.id
|
||||
location = var.resource_group_location
|
||||
}
|
||||
|
||||
resource "random_password" "password" {
|
||||
count = var.password == null ? 1 : 0
|
||||
length = 20
|
||||
special = true
|
||||
min_numeric = 1
|
||||
min_upper = 1
|
||||
min_lower = 1
|
||||
min_special = 1
|
||||
}
|
||||
|
||||
locals {
|
||||
password = try(random_password.password[0].result, var.password)
|
||||
}
|
||||
|
||||
resource "azurerm_dev_test_lab" "lab" {
|
||||
name = var.lab_name
|
||||
location = azurerm_resource_group.rg.location
|
||||
resource_group_name = azurerm_resource_group.rg.name
|
||||
}
|
||||
|
||||
resource "azurerm_dev_test_virtual_network" "vnet" {
|
||||
name = "Dtl${var.lab_name}"
|
||||
lab_name = azurerm_dev_test_lab.lab.name
|
||||
resource_group_name = azurerm_resource_group.rg.name
|
||||
}
|
||||
|
||||
resource "azurerm_dev_test_windows_virtual_machine" "vm" {
|
||||
name = var.vm_name
|
||||
lab_name = azurerm_dev_test_lab.lab.name
|
||||
lab_subnet_name = "Dtl${var.lab_name}Subnet"
|
||||
resource_group_name = azurerm_resource_group.rg.name
|
||||
location = azurerm_resource_group.rg.location
|
||||
storage_type = "Standard"
|
||||
size = var.vm_size
|
||||
username = var.user_name
|
||||
password = local.password
|
||||
allow_claim = false
|
||||
lab_virtual_network_id = azurerm_dev_test_virtual_network.vnet.id
|
||||
|
||||
gallery_image_reference {
|
||||
offer = "WindowsServer"
|
||||
publisher = "MicrosoftWindowsServer"
|
||||
sku = "2019-Datacenter"
|
||||
version = "latest"
|
||||
}
|
||||
}
|
8
quickstart/101-devtest-labs/outputs.tf
Normal file
8
quickstart/101-devtest-labs/outputs.tf
Normal file
@ -0,0 +1,8 @@
|
||||
output "lab_id" {
|
||||
value = azurerm_dev_test_lab.lab.id
|
||||
}
|
||||
|
||||
output "password" {
|
||||
sensitive = true
|
||||
value = local.password
|
||||
}
|
16
quickstart/101-devtest-labs/providers.tf
Normal file
16
quickstart/101-devtest-labs/providers.tf
Normal file
@ -0,0 +1,16 @@
|
||||
terraform {
|
||||
required_version = ">=0.12"
|
||||
required_providers {
|
||||
azurerm = {
|
||||
source = "hashicorp/azurerm"
|
||||
version = "~>2.0"
|
||||
}
|
||||
random = {
|
||||
source = "hashicorp/random"
|
||||
version = "~>3.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
provider "azurerm" {
|
||||
features {}
|
||||
}
|
23
quickstart/101-devtest-labs/readme.md
Normal file
23
quickstart/101-devtest-labs/readme.md
Normal file
@ -0,0 +1,23 @@
|
||||
# Windows virtual machine in an Azure DevTest Lab
|
||||
|
||||
This template deploys a Windows virtual machine within an Azure DevTest Lab.
|
||||
|
||||
## Terraform resource types
|
||||
|
||||
- [random_pet](https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/pet)
|
||||
- [azurerm_resource_group](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/resource_group)
|
||||
- [azurerm_dev_test_lab](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/dev_test_lab)
|
||||
- [azurerm_dev_test_virtual_network](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/dev_test_virtual_network)
|
||||
- [azurerm_dev_test_windows_virtual_machine](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/dev_test_windows_virtual_machine)
|
||||
|
||||
## Variables
|
||||
|
||||
| Name | Description | Default |
|
||||
|-|-|-|
|
||||
| `resource_group_name_prefix` | Prefix of the resource group name that's combined with a random ID so name is unique in your Azure subscription. | rg |
|
||||
| `resource_group_location` | Location of the resource group. | eastus |
|
||||
| `lab_name` | The name of the new lab instance to be created. | |
|
||||
| `vm_name` | The name of the VM to be created. | |
|
||||
| `vm_size` | The size of the VM to be created. | Standard_D4_v3 |
|
||||
| `user_name` | The username for the local account that will be created on the new VM. | |
|
||||
| `password` | The password for the local account that will be created on the new VM. | |
|
42
quickstart/101-devtest-labs/variables.tf
Normal file
42
quickstart/101-devtest-labs/variables.tf
Normal file
@ -0,0 +1,42 @@
|
||||
variable "resource_group_location" {
|
||||
type = string
|
||||
default = "eastus"
|
||||
description = "Location for all resources."
|
||||
}
|
||||
|
||||
variable "resource_group_name_prefix" {
|
||||
type = string
|
||||
default = "rg"
|
||||
description = "Prefix of the resource group name that's combined with a random ID so name is unique in your Azure subscription."
|
||||
}
|
||||
|
||||
variable "lab_name" {
|
||||
type = string
|
||||
description = "The name of the new lab instance to be created"
|
||||
default = "ExampleLab"
|
||||
}
|
||||
|
||||
variable "vm_name" {
|
||||
type = string
|
||||
description = "The name of the vm to be created."
|
||||
default = "example-vm"
|
||||
}
|
||||
|
||||
variable "vm_size" {
|
||||
type = string
|
||||
description = "The size of the vm to be created."
|
||||
default = "Standard_D4_v3"
|
||||
}
|
||||
|
||||
variable "user_name" {
|
||||
type = string
|
||||
description = "The username for the local account that will be created on the new vm."
|
||||
default = "exampleuser"
|
||||
}
|
||||
|
||||
variable "password" {
|
||||
type = string
|
||||
description = "The password for the local account that will be created on the new vm."
|
||||
sensitive = true
|
||||
default = null
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user