Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
296 changes: 296 additions & 0 deletions examples/airlift/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,296 @@
<!-- BEGIN_TF_DOCS -->
# Simple Windows VM with public IP and additional empty data disk

This example demonstrates the creation of a simple Windows Server 2022 VM with the following features:

- a single private IPv4 address
- a single default OS 128gb OS disk
- an associated public IP address that is autogenerated during creation
- an empty 32 GB data disk that is attached as lun 0
- an autogenerated password that is stored as a secret in the key vault resource.
- an optional bastion resource that can be deployed by uncommenting the bastion elements in the example

It includes the following resources in addition to the VM resource:

- A Vnet with two subnets
- A keyvault for storing the login secrets
- An optional subnet, public ip, and bastion which can be enabled by uncommenting the bastion resources when running the example.

```hcl
module "naming" {
source = "Azure/naming/azurerm"
version = "~> 0.4"
}

module "regions" {
source = "Azure/regions/azurerm"
version = "=0.8.1"
}

locals {
tags = {
scenario = "windows_w_data_disk_and_public_ip"
}
}

resource "random_integer" "region_index" {
max = length(module.regions.regions_by_name) - 1
min = 0
}

resource "random_integer" "zone_index" {
max = length(module.regions.regions_by_name[module.regions.regions[random_integer.region_index.result].name].zones)
min = 1
}

module "get_valid_sku_for_deployment_region" {
source = "../../modules/sku_selector"

deployment_region = module.regions.regions[random_integer.region_index.result].name
}

resource "azurerm_resource_group" "this_rg" {
location = module.regions.regions[random_integer.region_index.result].name
name = module.naming.resource_group.name_unique
tags = local.tags
}

resource "azurerm_virtual_network" "this_vnet" {
address_space = ["10.0.0.0/16"]
location = azurerm_resource_group.this_rg.location
name = module.naming.virtual_network.name_unique
resource_group_name = azurerm_resource_group.this_rg.name
tags = local.tags
}

resource "azurerm_subnet" "this_subnet_1" {
address_prefixes = ["10.0.1.0/24"]
name = "${module.naming.subnet.name_unique}-1"
resource_group_name = azurerm_resource_group.this_rg.name
virtual_network_name = azurerm_virtual_network.this_vnet.name
}

resource "azurerm_subnet" "this_subnet_2" {
address_prefixes = ["10.0.2.0/24"]
name = "${module.naming.subnet.name_unique}-2"
resource_group_name = azurerm_resource_group.this_rg.name
virtual_network_name = azurerm_virtual_network.this_vnet.name
}

# Uncomment this section if you would like to include a bastion resource with this example.
resource "azurerm_subnet" "bastion_subnet" {
address_prefixes = ["10.0.3.0/24"]
name = "AzureBastionSubnet"
resource_group_name = azurerm_resource_group.this_rg.name
virtual_network_name = azurerm_virtual_network.this_vnet.name
}

resource "azurerm_public_ip" "bastionpip" {
allocation_method = "Static"
location = azurerm_resource_group.this_rg.location
name = module.naming.public_ip.name_unique
resource_group_name = azurerm_resource_group.this_rg.name
sku = "Standard"
zones = ["1", "2", "3"]
}

resource "azurerm_bastion_host" "bastion" {
location = azurerm_resource_group.this_rg.location
name = module.naming.bastion_host.name_unique
resource_group_name = azurerm_resource_group.this_rg.name

ip_configuration {
name = "${module.naming.bastion_host.name_unique}-ipconf"
public_ip_address_id = azurerm_public_ip.bastionpip.id
subnet_id = azurerm_subnet.bastion_subnet.id
}
}


data "azurerm_client_config" "current" {}

module "avm_res_keyvault_vault" {
source = "Azure/avm-res-keyvault-vault/azurerm"
version = "=0.7.1"
tenant_id = data.azurerm_client_config.current.tenant_id
name = module.naming.key_vault.name_unique
resource_group_name = azurerm_resource_group.this_rg.name
location = azurerm_resource_group.this_rg.location
network_acls = {
default_action = "Allow"
}

role_assignments = {
deployment_user_secrets = {
role_definition_id_or_name = "Key Vault Secrets Officer"
principal_id = data.azurerm_client_config.current.object_id
}
}

wait_for_rbac_before_secret_operations = {
create = "60s"
}

tags = local.tags
}

module "testvm" {
source = "../../"
#source = "Azure/avm-res-compute-virtualmachine/azurerm"
#version = "0.15.1"

enable_telemetry = var.enable_telemetry
location = azurerm_resource_group.this_rg.location
resource_group_name = azurerm_resource_group.this_rg.name
os_type = "Windows"
name = module.naming.virtual_machine.name_unique
sku_size = module.get_valid_sku_for_deployment_region.sku
zone = random_integer.zone_index.result

generated_secrets_key_vault_secret_config = {
key_vault_resource_id = module.avm_res_keyvault_vault.resource_id
}

source_image_reference = {
publisher = "MicrosoftWindowsServer"
offer = "WindowsServer"
sku = "2022-datacenter-g2"
version = "latest"
}

network_interfaces = {
network_interface_1 = {
name = module.naming.network_interface.name_unique
ip_configurations = {
ip_configuration_1 = {
name = "${module.naming.network_interface.name_unique}-ipconfig1"
private_ip_subnet_resource_id = azurerm_subnet.this_subnet_1.id
create_public_ip_address = true
public_ip_address_name = module.naming.public_ip.name_unique
}
}
}
}

data_disk_managed_disks = {
disk1 = {
name = "${module.naming.managed_disk.name_unique}-lun0"
storage_account_type = "Premium_LRS"
lun = 0
caching = "ReadWrite"
disk_size_gb = 32
}
}

shutdown_schedules = {
test_schedule = {
daily_recurrence_time = "1700"
enabled = true
timezone = "Pacific Standard Time"
notification_settings = {
enabled = true
email = "example@example.com;example2@example.com"
time_in_minutes = "15"
webhook_url = "https://example-webhook-url.example.com"
}
}
}

tags = {
scenario = "windows_w_data_disk_and_public_ip"
}

depends_on = [
module.avm_res_keyvault_vault
]
}
```

<!-- markdownlint-disable MD033 -->
## Requirements

The following requirements are needed by this module:

- <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) (~> 1.6)

- <a name="requirement_azurerm"></a> [azurerm](#requirement\_azurerm) (~> 3.108)

- <a name="requirement_random"></a> [random](#requirement\_random) (~> 3.6)

## Resources

The following resources are used by this module:

- [azurerm_bastion_host.bastion](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/bastion_host) (resource)
- [azurerm_public_ip.bastionpip](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/public_ip) (resource)
- [azurerm_resource_group.this_rg](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/resource_group) (resource)
- [azurerm_subnet.bastion_subnet](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/subnet) (resource)
- [azurerm_subnet.this_subnet_1](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/subnet) (resource)
- [azurerm_subnet.this_subnet_2](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/subnet) (resource)
- [azurerm_virtual_network.this_vnet](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/virtual_network) (resource)
- [random_integer.region_index](https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/integer) (resource)
- [random_integer.zone_index](https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/integer) (resource)
- [azurerm_client_config.current](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/data-sources/client_config) (data source)

<!-- markdownlint-disable MD013 -->
## Required Inputs

No required inputs.

## Optional Inputs

The following input variables are optional (have default values):

### <a name="input_enable_telemetry"></a> [enable\_telemetry](#input\_enable\_telemetry)

Description: This variable controls whether or not telemetry is enabled for the module.
For more information see https://aka.ms/avm/telemetryinfo.
If it is set to false, then no telemetry will be collected.

Type: `bool`

Default: `true`

## Outputs

No outputs.

## Modules

The following Modules are called:

### <a name="module_avm_res_keyvault_vault"></a> [avm\_res\_keyvault\_vault](#module\_avm\_res\_keyvault\_vault)

Source: Azure/avm-res-keyvault-vault/azurerm

Version: =0.7.1

### <a name="module_get_valid_sku_for_deployment_region"></a> [get\_valid\_sku\_for\_deployment\_region](#module\_get\_valid\_sku\_for\_deployment\_region)

Source: ../../modules/sku_selector

Version:

### <a name="module_naming"></a> [naming](#module\_naming)

Source: Azure/naming/azurerm

Version: ~> 0.4

### <a name="module_regions"></a> [regions](#module\_regions)

Source: Azure/regions/azurerm

Version: =0.8.1

### <a name="module_testvm"></a> [testvm](#module\_testvm)

Source: ../../

Version:

<!-- markdownlint-disable-next-line MD041 -->
## Data Collection

The software may collect information about you and your use of the software and send it to Microsoft. Microsoft may use this information to provide services and improve our products and services. You may turn off the telemetry as described in the repository. There are also some features in the software that may enable you and Microsoft to collect data from users of your applications. If you use these features, you must comply with applicable law, including providing appropriate notices to users of your applications together with a copy of Microsoft’s privacy statement. Our privacy statement is located at <https://go.microsoft.com/fwlink/?LinkID=824704>. You can learn more about data collection and use in the help documentation and our privacy statement. Your use of the software operates as your consent to these practices.
<!-- END_TF_DOCS -->
4 changes: 4 additions & 0 deletions examples/airlift/_footer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<!-- markdownlint-disable-next-line MD041 -->
## Data Collection

The software may collect information about you and your use of the software and send it to Microsoft. Microsoft may use this information to provide services and improve our products and services. You may turn off the telemetry as described in the repository. There are also some features in the software that may enable you and Microsoft to collect data from users of your applications. If you use these features, you must comply with applicable law, including providing appropriate notices to users of your applications together with a copy of Microsoft’s privacy statement. Our privacy statement is located at <https://go.microsoft.com/fwlink/?LinkID=824704>. You can learn more about data collection and use in the help documentation and our privacy statement. Your use of the software operates as your consent to these practices.
16 changes: 16 additions & 0 deletions examples/airlift/_header.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Simple Windows VM with public IP and additional empty data disk

This example demonstrates the creation of a simple Windows Server 2022 VM with the following features:

- a single private IPv4 address
- a single default OS 128gb OS disk
- an associated public IP address that is autogenerated during creation
- an empty 32 GB data disk that is attached as lun 0
- an autogenerated password that is stored as a secret in the key vault resource.
- an optional bastion resource that can be deployed by uncommenting the bastion elements in the example

It includes the following resources in addition to the VM resource:

- A Vnet with two subnets
- A keyvault for storing the login secrets
- An optional subnet, public ip, and bastion which can be enabled by uncommenting the bastion resources when running the example.
Loading