Terraform-provider-azurerm: Linux VM scale set cannot be created using shared image gallery

Created on 5 Mar 2020  ·  5Comments  ·  Source: terraform-providers/terraform-provider-azurerm

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

Terraform (and AzureRM Provider) Version

Terraform v0.12.21

  • provider.azurerm v2.0.0

Affected Resource(s)

  • azurerm_linux_virtual_machine_scale_set

Terraform Configuration Files

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"

Panic Output

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

References

  • #0000
bug servicvmss

Most helpful comment

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:

All 5 comments

It looks like this should have been fixed in https://github.com/terraform-providers/terraform-provider-azurerm/pull/5901, which did not make it into the 2.0.0 release. When can we expect a new release with this fix?

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:

Fixed via #5901

This has been released in version 2.1.0 of the provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading. As an example:

provider "azurerm" {
    version = "~> 2.1.0"
}
# ... other configuration ...

I'm going to lock this issue because it has been closed for _30 days_ ⏳. This helps our maintainers find and focus on the active issues.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. If you feel I made an error 🤖 🙉 , please reach out to my human friends 👉 [email protected]. Thanks!

Was this page helpful?
0 / 5 - 0 ratings