azurerm_virtual_machine_gallery_application_assignment

Manages a Virtual Machine Gallery Application Assignment.

data "azurerm_virtual_machine" "example" {
  name                = "example-vm"
  resource_group_name = "example-resources-vm"
}

resource "azurerm_resource_group" "example" {
  name     = "example-resources"
  location = "West Europe"
}

resource "azurerm_shared_image_gallery" "example" {
  name                = "examplegallery"
  resource_group_name = azurerm_resource_group.example.name
  location            = azurerm_resource_group.example.location
}

resource "azurerm_gallery_application" "example" {
  name              = "example-app"
  gallery_id        = azurerm_shared_image_gallery.example.id
  location          = azurerm_resource_group.example.location
  supported_os_type = "Linux"
}

resource "azurerm_storage_account" "example" {
  name                     = "examplestorage"
  resource_group_name      = azurerm_resource_group.example.name
  location                 = azurerm_resource_group.example.location
  account_tier             = "Standard"
  account_replication_type = "LRS"
}

resource "azurerm_storage_container" "example" {
  name                  = "example-container"
  storage_account_name  = azurerm_storage_account.example.name
  container_access_type = "blob"
}

resource "azurerm_storage_blob" "example" {
  name                   = "scripts"
  storage_account_name   = azurerm_storage_account.example.name
  storage_container_name = azurerm_storage_container.example.name
  type                   = "Block"
  source_content         = "[scripts file content]"
}

resource "azurerm_gallery_application_version" "example" {
  name                   = "0.0.1"
  gallery_application_id = azurerm_gallery_application.example.id
  location               = azurerm_gallery_application.example.location

  manage_action {
    install = "[install command]"
    remove  = "[remove command]"
  }

  source {
    media_link = azurerm_storage_blob.example.id
  }

  target_region {
    name                   = azurerm_gallery_application.example.location
    regional_replica_count = 1
  }
}

resource "azurerm_virtual_machine_gallery_application_assignment" "example" {
  gallery_application_version_id = azurerm_gallery_application_version.example.id
  virtual_machine_id             = data.azurerm_virtual_machine.example.id
}

Arguments Reference

The following arguments are supported:

Attributes Reference

In addition to the Arguments listed above - the following Attributes are exported:

Timeouts

The timeouts block allows you to specify timeouts for certain actions:

Import

Virtual Machine Gallery Application Assignments can be imported using the resource id, e.g.

terraform import azurerm_virtual_machine_gallery_application_assignment.example subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/mygroup1/providers/Microsoft.Compute/virtualMachines/machine1|/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/group1/providers/Microsoft.Compute/galleries/gallery1/applications/galleryApplication1/versions/galleryApplicationVersion1