terraform-provider-azurerm icon indicating copy to clipboard operation
terraform-provider-azurerm copied to clipboard

Cannot assign "maintenance configuration" to "Scaleset instance"

Open Sanket-Kaware opened this issue 3 years ago • 1 comments

Is there an existing issue for this?

  • [X] I have searched the existing issues

Community Note

  • Please vote on this issue by adding a :thumbsup: reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Description

I have nodes(scaleset instance) in one of my Kubernetes Services node pools and trying to assign the maintenance configuration to it.

I have created a maintenance configuration using resource "azurerm_maintenance_configuration" but didn't find a solution for assigning the configuration to the "Scaleset instance".

I am looking for an option to add "Scaleset instance" via "add machine" in "maintenance configuration". Does terraform/azure have this feature? Able to do this in the portal but looking for terraform resource to add it.

New or Affected Resource(s)/Data Source(s)

azurerm_maintenance_configuration, azurerm_maintenance_assignment_virtual_machine_scale_set

Potential Terraform Configuration

No response

References

No response

Sanket-Kaware avatar Sep 16 '22 20:09 Sanket-Kaware


provider "azurerm" {
  features {}
}

# Define your resource group
resource "azurerm_resource_group" "example" {
  name     = "example-resources"
  location = "East US"
}

# Define the virtual machine scale set
resource "azurerm_virtual_machine_scale_set" "example" {
  name                = "example-vmss"
  location            = azurerm_resource_group.example.location
  resource_group_name = azurerm_resource_group.example.name
  sku {
    name     = "Standard_DS1_v2"
    tier     = "Standard"
    capacity = 2
  }
  upgrade_policy {
    mode = "Automatic"
  }

  # Define the VM scale set instances
  identity {
    type = "SystemAssigned"
  }

  network_profile {
    name    = "example-network-profile"
    primary = true

    ip_configuration {
      name      = "example-ip-config"
      primary   = true
      subnet_id = "<YOUR_SUBNET_ID>"  # Replace with your actual subnet ID
    }
  }

  os_profile {
    computer_name_prefix = "vmss-example"
    admin_username       = "adminuser"
    admin_password       = "P@ssword1234!"
  }

  storage_profile {
    image_reference {
      publisher = "MicrosoftWindowsServer"
      offer     = "WindowsServer"
      sku       = "2019-Datacenter"
      version   = "latest"
    }

    os_disk {
      caching              = "ReadWrite"
      managed_disk_type    = "StandardSSD_LRS"
    }
  }
}

# Create the maintenance configuration
resource "azurerm_maintenance_configuration" "example" {
  name                = "example-maintenance-config"
  resource_group_name = azurerm_resource_group.example.name
  location            = azurerm_resource_group.example.location
  description         = "Maintenance configuration for VMSS instances"

  # Define the maintenance window
  maintenance_window {
    start_time = "2023-10-01T00:00:00Z"  # Start time in UTC
    end_time   = "2023-10-01T02:00:00Z"  # End time in UTC
    frequency  = "Weekly"
    day_of_week = "Sunday"
  }

  # Maintenance configuration settings
  maintenance_mode = "On"
}

# Assign the maintenance configuration to the VM scale set
resource "azurerm_maintenance_assignment_virtual_machine_scale_set" "example" {
  name                           = "example-maintenance-assignment"
  resource_group_name            = azurerm_resource_group.example.name
  maintenance_configuration_id    = azurerm_maintenance_configuration.example.id
  virtual_machine_scale_set_id    = azurerm_virtual_machine_scale_set.example.id
}

ljluestc avatar Oct 19 '24 21:10 ljluestc