hashicorp / terraform-provider-azurerm

Terraform provider for Azure Resource Manager
https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs
Mozilla Public License 2.0
4.53k stars 4.6k forks source link

azurerm_shared_image_version deployment #3517

Closed rohrerb closed 5 years ago

rohrerb commented 5 years ago

Community Note

Description

Deployments for azurerm_shared_image_version can take 30 minutes to a hour due to terraform waiting for the image replication to complete. Is it possible for terraform to create he resource and complete without waiting for replication to multiple regions.

New or Affected Resource(s)

azurerm_shared_image_version

Example Terraform Configuration

resource "azurerm_shared_image_version" "version" {
  count               = "${var.create ? 1 : 0}"
  name                = "${var.global_image_version}"
  gallery_name        = "${var.gallery_name}"
  image_name          = "${var.image_name}"
  resource_group_name = "${var.resource_group_name}"
  location            = "${var.location}"
  managed_image_id    = "${var.managed_image_id}"

  target_region {
    name                   = "UK South"
    regional_replica_count = 1
  }

  target_region {
    name                   = "Australia East"
    regional_replica_count = 1
  }

  target_region {
    name                   = "Canada Central"
    regional_replica_count = 1
  }
}
rohrerb commented 5 years ago

9 times out of 10 you end up with...

1 error occurred:
        * module.version-windows-com.azurerm_shared_image_version.version: 1 error occurred:
        * azurerm_shared_image_version.version: Error waiting for the creation of Shared Image Version "1.0.1" (Image "Windows" / Gallery "global_image_gallery" / Resource Group "Global"): azure.BearerAuthorizer#WithAuthorization: Failed to refresh the Token for request to https://management.azure.com/subscriptions/7d559a72-xxxx-xxxx-xxxx-5ca5b14a25e7/providers/Microsoft.Compute/locations/uksouth/capsOperations/c29a9c25-xxxx-xxxx-xxxx-6bcef62f9ea9?api-version=2018-06-01: StatusCode=0 -- Original Error: Manually created ServicePrincipalToken does not contain secret material to retrieve a new access token
tombuildsstuff commented 5 years ago

hi @rohrerb

Thanks for opening this issue :)

Deployments for azurerm_shared_image_version can take 30 minutes to a hour due to terraform waiting for the image replication to complete. Is it possible for terraform to create he resource and complete without waiting for replication to multiple regions.

Terraform intentionally waits (ignoring bugs) for a resource to be fully provisioned so that it's possible to chain resources together (to for instance, create a Virtual Machine then add it to a Load Balancer) - as such unfortunately that's not an approach we'd taken.

Taking a look into this, the root cause of this appears to be https://github.com/hashicorp/go-azure-helpers/issues/22 which I'm going to close this in favour of. In addition once version 2.0 of the Azure Provider becomes available you'll be able to use custom timeouts for resources to set a timeout as needed.

Thanks!

ghost commented 5 years ago

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 👉 hashibot-feedback@hashicorp.com. Thanks!