Created
September 16, 2024 01:26
-
-
Save KyMidd/f39cc443af05f613d6f45fecf2e69372 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
terraform { | |
required_providers { | |
azurerm = { | |
source = "hashicorp/azurerm" | |
} | |
} | |
} | |
# Main | |
provider "azurerm" { | |
features {} | |
} | |
# accountB | |
provider "azurerm" { | |
features {} | |
alias = "accountB" | |
subscription_id = "xxxxx-yyyyy-zzzzzz-00000000" | |
} | |
resource "azurerm_resource_group" "rg" { | |
name = "rg_name" | |
location = "East US" | |
} | |
resource "azurerm_maintenance_configuration" "main" { | |
name = "main" | |
resource_group_name = azurerm_resource_group.rg.name | |
location = azurerm_resource_group.rg.location | |
scope = "InGuestPatch" | |
in_guest_user_patch_mode = "User" | |
tags = { | |
GuiltyParty = "Kyler" | |
} | |
window { | |
start_date_time = "${formatdate("YYYY-MM-DD", timestamp())} 23:00" | |
time_zone = "Eastern Standard Time" | |
duration = "03:55" # 3 hour, 55 min | |
recur_every = "Month Second Tuesday" | |
} | |
install_patches { | |
reboot = "Always" | |
windows { | |
classifications_to_include = ["Critical", "Security", "UpdateRollup", "ServicePack", "Definition", "Updates"] | |
kb_numbers_to_exclude = [] | |
kb_numbers_to_include = [] | |
} | |
} | |
# Add ignore for window.start_date_time | |
lifecycle { | |
ignore_changes = [ | |
window[0].start_date_time | |
] | |
} | |
} | |
# Dev one | |
resource "azurerm_maintenance_assignment_dynamic_scope" "accountA" { | |
name = "dynamic-scope-accounta" | |
maintenance_configuration_id = azurerm_maintenance_configuration.main.id | |
filter { | |
os_types = ["Windows"] | |
resource_types = ["Microsoft.Compute/virtualMachines"] | |
tag_filter = "All" | |
tags { | |
tag = "HostType" | |
values = ["Servers"] | |
} | |
} | |
} | |
# accountB one | |
resource "azurerm_maintenance_assignment_dynamic_scope" "accountB" { | |
provider = azurerm.accountB | |
name = "dynamic-scope-accountb" | |
maintenance_configuration_id = azurerm_maintenance_configuration.main.id | |
filter { | |
os_types = ["Windows"] | |
resource_types = ["Microsoft.Compute/virtualMachines"] | |
tag_filter = "All" | |
tags { | |
tag = "HostType" | |
values = ["Servers"] | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment