Useful or not, from you.
terraform-provider-azurerm Linux VM scale set cannot be created using shared image gallery

<!--- Please note the following potential times when an issue might be in Terraform core:

If you are running into one of these scenarios, we recommend opening an issue in the Terraform core repository instead. --->

<!--- Please keep this note for the community --->

Community Note

  • Please vote on this issue by adding a 👍 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

<!--- Thank you for keeping this note for the community --->

Terraform (and AzureRM Provider) Version

Terraform v0.12.21

  • provider.azurerm v2.0.0

Affected Resource(s)

<!--- Please list the affected resources and data sources. --->

  • azurerm_linux_virtual_machine_scale_set

Terraform Configuration Files

<!--- Information about code formatting: https://help.github.com/articles/basic-writing-and-formatting-syntax/#quoting-code --->

resource "azurerm_linux_virtual_machine_scale_set" "current" {
    name                 = "test-vmss"
    location             = "East US2"
    resource_group_name  = "test-rg"
    sku                  = "Standard_D4s_v3"
    zones                = [1,2,2]
    zone_balance         = "true"
    instances            = 1
    provision_vm_agent   = "true"

    computer_name_prefix = "testvmss"
    source_image_id      = "subscriptions/myS/resourceGroups/myRg/providers/Microsoft.Compute/galleries/mygallery/images/myimg"
    custom_data          = base64encode(file(var.vmss_config.cloud_init))

    disable_password_authentication = var.vmss_config.disable_password_authentication
    admin_username                  = var.vmss_config.admin_username
    admin_password                  = var.vmss_config.admin_password
    admin_ssh_key {
        username   = var.vmss_config.admin_username
        public_key = var.vmss_config.admin_ssh_key
    }
    
    lifecycle {
        ignore_changes = [
            # Ignore changes to instances as auto-scale is enabled
            instances
        ]
    }
   
    identity {
        type         = "UserAssigned"
        identity_ids = var.identity_ids
    }

    os_disk {
        caching                   = var.os_disk.caching
        storage_account_type      = var.os_disk.storage_account_type
        disk_size_gb              = var.os_disk.disk_size_gb
        # encryption is not supported for custom OS images
        # disk_encryption_set_id    = data.azurerm_disk_encryption_set.current.id
    }

    network_interface {
        name    = "${var.vmss_prefix}-ip"
        primary = true
        ip_configuration {
            name      = "primary-network"
            primary   = true
            subnet_id = data.azurerm_subnet.current.id
            load_balancer_backend_address_pool_ids = var.lb_backend_address_pool_ids
            application_gateway_backend_address_pool_ids = []
            application_security_group_ids               = []
            load_balancer_inbound_nat_rules_ids          = []
        }
    }

    upgrade_mode         = "Manual"
	health_probe_id      = var.health_probe_id

}

Debug Output

The same error shows up when the specific image version is used.

Error: Can not parse "source_image_id" as a resource id: ID contained more segments than required: "subscriptions/myS/resourceGroups/myRg/providers/Microsoft.Compute/galleries/mygallery/images/myimg"

<!--- Please provide a link to a GitHub Gist containing the complete debug output. Please do NOT paste the debug output in the issue; just paste a link to the Gist.

To obtain the debug output, see the Terraform documentation on debugging. --->

Panic Output

<!--- If Terraform produced a panic, please provide a link to a GitHub Gist containing the output of the crash.log. --->

Expected Behavior

This works for azurerm_virtual_machine_scale_set and is expected to work with the new azurerm_linux_virtual_machine_scale_set

Actual Behavior

Only the direct URL to the image is supported. Error is thrown when shared image gallery is used.

Steps to Reproduce

  1. terraform apply

Important Factoids

<!--- Are there anything atypical about your accounts that we should know? For example: Running in a Azure China/Germany/Government? --->

References

<!--- Information about referencing Github Issues: https://help.github.com/articles/basic-writing-and-formatting-syntax/#referencing-issues-and-pull-requests

Are there any other GitHub issues (open or closed) or pull requests that should be linked here? Such as vendor documentation? --->

  • #0000
That's a useful answer
Without any help

Hi @mb139h & @opsj! While this did not make it into the 2.0.0 release, PR #5901 was recently merged. So, this should be resolved in 2.1.0 which will hopefully happen next week. Thanks :smiley: