Skip to content
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

Add var.tags to OS-disk #32

Merged
merged 5 commits into from
Sep 25, 2024
Merged
Show file tree
Hide file tree
Changes from 4 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
2 changes: 1 addition & 1 deletion .github/workflows/module-ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ on:

jobs:
module-ci:
uses: cloudeteer/terraform-governance/.github/workflows/module-ci.yaml@main
uses: cloudeteer/terraform-governance/.github/workflows/module-ci.yaml@44-terraforms-azureapi-provider-seems-to-not-use-the-az-login-session
neonwhiskers marked this conversation as resolved.
Show resolved Hide resolved
permissions:
contents: write
id-token: write
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ The following providers are used by this module:

The following resources are used by this module:

- [azapi_resource_action.this](https://registry.terraform.io/providers/azure/azapi/latest/docs/resources/resource_action) (resource)
- [azurerm_backup_protected_vm.this](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/backup_protected_vm) (resource)
- [azurerm_key_vault_secret.this](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/key_vault_secret) (resource)
- [azurerm_linux_virtual_machine.this](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/linux_virtual_machine) (resource)
Expand All @@ -139,6 +140,7 @@ The following resources are used by this module:
- [azapi_client_config.current](https://registry.terraform.io/providers/azure/azapi/latest/docs/data-sources/client_config) (data source)
- [azapi_resource.virtual_machine_image](https://registry.terraform.io/providers/azure/azapi/latest/docs/data-sources/resource) (data source)
- [azapi_resource_list.virtual_machine_images](https://registry.terraform.io/providers/azure/azapi/latest/docs/data-sources/resource_list) (data source)
- [azurerm_managed_disk.this](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/data-sources/managed_disk) (data source)

## Required Inputs

Expand Down Expand Up @@ -463,6 +465,8 @@ Description: Should the Windows VM be patched without requiring a reboot? [more

**NOTE**: Hotpatching can only be enabled if the `patch_mode` is set to `AutomaticByPlatform`, the `provision_vm_agent` is set to `true`, your `source_image_reference` references a hotpatching enabled image, and the VM's `size` is set to a [Azure generation 2 VM](https://learn.microsoft.com/en-gb/azure/virtual-machines/generation-2#generation-2-vm-sizes).

**CAUTION**: The setting `bypass_platform_safety_checks_on_user_schedule_enabled` is set to `true` by default. To enable hotpatching, change it to `false`.

Type: `bool`

Default: `false`
Expand Down
15 changes: 15 additions & 0 deletions r-vm.tf
Original file line number Diff line number Diff line change
Expand Up @@ -209,3 +209,18 @@ resource "azurerm_windows_virtual_machine" "this" {
]
}
}

data "azurerm_managed_disk" "this" {
name = local.virtual_machine.os_disk[0].name
resource_group_name = var.resource_group_name
}

resource "azapi_resource_action" "this" {
type = "Microsoft.Compute/disks@2022-03-02"
neonwhiskers marked this conversation as resolved.
Show resolved Hide resolved
resource_id = data.azurerm_managed_disk.this.id
method = "PATCH"

body = {
tags = var.tags
}
}
5 changes: 5 additions & 0 deletions tests/examples/mocks/azurerm_managed_disk.tfmock.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
mock_data "azurerm_managed_disk" {
defaults = {
id = "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/RG-MOCK/providers/Microsoft.Compute/disks/DISK-MOCK"
}
}
5 changes: 5 additions & 0 deletions tests/local/mocks/azurerm_managed_disk.tfmock.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
mock_data "azurerm_managed_disk" {
defaults = {
id = "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/RG-MOCK/providers/Microsoft.Compute/disks/DISK-MOCK"
}
}
2 changes: 2 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,8 @@ variable "hotpatching_enabled" {
Should the Windows VM be patched without requiring a reboot? [more infos](https://learn.microsoft.com/windows-server/get-started/hotpatch)

**NOTE**: Hotpatching can only be enabled if the `patch_mode` is set to `AutomaticByPlatform`, the `provision_vm_agent` is set to `true`, your `source_image_reference` references a hotpatching enabled image, and the VM's `size` is set to a [Azure generation 2 VM](https://learn.microsoft.com/en-gb/azure/virtual-machines/generation-2#generation-2-vm-sizes).

**CAUTION**: The setting `bypass_platform_safety_checks_on_user_schedule_enabled` is set to `true` by default. To enable hotpatching, change it to `false`.
neonwhiskers marked this conversation as resolved.
Show resolved Hide resolved
EOT

type = bool
Expand Down