この場合、tagは変わってもplanするときに変更対象として出ない
1 2 3 4 5 |
lifecycle { ignore_changes = [ tags, ] } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
resource "azurerm_virtual_machine" "main" { name = var.web-vmname location = var.location resource_group_name = azurerm_resource_group.resource_group.name network_interface_ids = [azurerm_network_interface.main.id] vm_size = "Standard_DS1_v2" storage_image_reference { publisher = "MicrosoftWindowsServer" offer = "WindowsServer" sku = "2019-Datacenter" version = "latest" } storage_os_disk { name = var.web-storagename caching = "ReadWrite" create_option = "FromImage" managed_disk_type = "Standard_LRS" } os_profile { computer_name = var.web-hostname admin_username = "testadmin" admin_password = "Password1234!" } os_profile_windows_config { provision_vm_agent = true enable_automatic_upgrades = true } tags = { environment = "Terraform test" } lifecycle { ignore_changes = [ tags, ] } } |