-
Notifications
You must be signed in to change notification settings - Fork 796
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
User Story 89540 #231
Merged
Merged
User Story 89540 #231
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
bd72b68
Fixing Windows VM cluster article code
TomArcherMsft acb0e06
Updates
TomArcherMsft 4dceb66
Edits per Code Review
TomArcherMsft 57033e0
Corrected links for additional info about verified modules
TomArcherMsft 4cd61cf
Added flag to allow for RG deletion when other resources are present
TomArcherMsft 61bd196
Added flag to allow for RG deletion when other resources are present
TomArcherMsft e93d4e4
Changes per Zijie
TomArcherMsft File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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_string" "windows_server_vm_hostname" { | ||
length = 8 | ||
lower = true | ||
upper = false | ||
special = false | ||
} | ||
|
||
resource "random_pet" "windows_server_public_ip_dns" { | ||
prefix = "dns" | ||
} | ||
|
||
resource "random_password" "password" { | ||
length = 16 | ||
special = true | ||
lower = true | ||
upper = true | ||
numeric = true | ||
} | ||
|
||
# The following module is a Terraform Verified Module. | ||
# For more information about Verified Modules, see | ||
# https://github.com/azure/terraform-azure-modules/ | ||
module "windows_server" { | ||
count = 3 # Define 3 Windows Server VMs | ||
source = "Azure/compute/azurerm" | ||
resource_group_name = azurerm_resource_group.rg.name | ||
vnet_subnet_id = module.network.vnet_subnets[0] | ||
is_windows_image = true | ||
vm_hostname = "vm-${random_string.windows_server_vm_hostname.result}-${count.index}" | ||
delete_os_disk_on_termination = true | ||
admin_password = random_password.password.result | ||
vm_os_simple = "WindowsServer" | ||
public_ip_dns = ["${random_pet.windows_server_public_ip_dns.id}-${count.index}"] | ||
} | ||
|
||
# The following module is a Terraform Verified Module. | ||
# For more information about Verified Modules, see | ||
# https://github.com/azure/terraform-azure-modules/ | ||
module "network" { | ||
source = "Azure/network/azurerm" | ||
resource_group_name = azurerm_resource_group.rg.name | ||
version = "5.2.0" | ||
subnet_prefixes = ["10.0.1.0/24"] | ||
subnet_names = ["subnet1"] | ||
use_for_each = true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
output "resource_group_name" { | ||
value = azurerm_resource_group.rg.name | ||
} | ||
|
||
output "windows_vm_public_names" { | ||
value = module.windows_server[*].public_ip_dns_name | ||
} | ||
|
||
output "vm_public_ip_addresses" { | ||
value = module.windows_server[*].public_ip_address | ||
} | ||
|
||
output "vm_private_ip_addresses" { | ||
value = module.windows_server[*].network_interface_private_ip | ||
} | ||
|
||
output "vm_hostnames" { | ||
value = module.windows_server[*].vm_names | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
terraform { | ||
required_version = ">=1.0" | ||
required_providers { | ||
azurerm = { | ||
source = "hashicorp/azurerm" | ||
version = "~>3.0" | ||
} | ||
random = { | ||
source = "hashicorp/random" | ||
version = "~>3.0" | ||
} | ||
} | ||
} | ||
provider "azurerm" { | ||
features {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# Azure Windows VM cluster | ||
|
||
This template deploys a Windows VM cluster on Azure. | ||
|
||
## 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) | ||
- [random_string](https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/string) | ||
- [random_password](https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/password) | ||
|
||
## Terraform modules | ||
|
||
- [windows_server](https://registry.terraform.io/modules/Azure/compute/azurerm) | ||
TomArcherMsft marked this conversation as resolved.
Show resolved
Hide resolved
|
||
- [network](https://registry.terraform.io/modules/Azure/network/azurerm) | ||
|
||
## 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 | | ||
|
||
## Example | ||
|
||
To see how to run this example, see [Configure an Azure VM cluster using Terraform](https://learn.microsoft.com/azure/developer/terraform/create-vm-cluster-module). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
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 value so name is unique in your Azure subscription." | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are these verified modules? (I assume the answer is yes) If so, let's add a comment with a link to the verified module main documentation repo.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was thinking something more like this, which refers to the verified module repo, not the registry:
Below module is a Terraform Verified Module. For more information about Verified Modules see (https://github.com/azure/terraform-azure-modules/)