Skip to content

Instantly share code, notes, and snippets.

@nateoconnell
Created April 8, 2023 01:00
Show Gist options
  • Save nateoconnell/7148e9e71c7b0dacc08b06ddc694803a to your computer and use it in GitHub Desktop.
Save nateoconnell/7148e9e71c7b0dacc08b06ddc694803a to your computer and use it in GitHub Desktop.
Terraform apply debug output for VM build failure with azurerm 3.44.0 when referencing OS image in another tenant using auxiliary_tenant_ids provider config option
$ TF_LOG=DEBUG terraform apply
2023-04-07T19:35:29.999-0500 [INFO] Terraform version: 1.4.4
[...]
azurerm_linux_virtual_machine.main: Creating...
2023-04-07T19:36:05.043-0500 [INFO] Starting apply for azurerm_linux_virtual_machine.main
2023-04-07T19:36:05.044-0500 [DEBUG] azurerm_linux_virtual_machine.main: applying the planned Create change
2023-04-07T19:36:05.045-0500 [DEBUG] provider.terraform-provider-azurerm_v3.44.0_x5: setting computed for "termination_notification" from ComputedKeys: timestamp=2023-04-07T19:36:05.045-0500
2023-04-07T19:36:05.045-0500 [DEBUG] provider.terraform-provider-azurerm_v3.44.0_x5: setting computed for "public_ip_addresses" from ComputedKeys: timestamp=2023-04-07T19:36:05.045-0500
2023-04-07T19:36:05.045-0500 [DEBUG] provider.terraform-provider-azurerm_v3.44.0_x5: setting computed for "private_ip_addresses" from ComputedKeys: timestamp=2023-04-07T19:36:05.045-0500
2023-04-07T19:36:05.046-0500 [DEBUG] provider.terraform-provider-azurerm_v3.44.0_x5: error normalising ssh key "": empty string supplied: timestamp=2023-04-07T19:36:05.045-0500
2023-04-07T19:36:05.046-0500 [DEBUG] provider.terraform-provider-azurerm_v3.44.0_x5: Locking "azurerm_virtual_machine.provider-bugcheck-vm": timestamp=2023-04-07T19:36:05.046-0500
2023-04-07T19:36:05.046-0500 [DEBUG] provider.terraform-provider-azurerm_v3.44.0_x5: Locked "azurerm_virtual_machine.provider-bugcheck-vm": timestamp=2023-04-07T19:36:05.046-0500
2023-04-07T19:36:05.547-0500 [DEBUG] provider.terraform-provider-azurerm_v3.44.0_x5: AzureRM Request:
GET /subscriptions/<target_subscription>/resourceGroups/provider-bugcheck-rg/providers/Microsoft.Compute/virtualMachines/provider-bugcheck-vm?api-version=2022-08-01 HTTP/1.1
Host: management.azure.com
User-Agent: Go/go1.19.3 (amd64-darwin) go-autorest/v14.2.1 Azure-SDK-For-Go/v66.0.0 compute/2022-08-01 HashiCorp Terraform/1.4.4 (+https://www.terraform.io) Terraform Plugin SDK/2.10.1 terraform-provider-azurerm/dev pid-XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
X-Ms-Correlation-Request-Id: XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
Accept-Encoding: gzip: timestamp=2023-04-07T19:36:05.547-0500
2023-04-07T19:36:06.003-0500 [DEBUG] provider.terraform-provider-azurerm_v3.44.0_x5: AzureRM Response for https://management.azure.com/subscriptions/<target_subscription>/resourceGroups/provider-bugcheck-rg/providers/Microsoft.Compute/virtualMachines/provider-bugcheck-vm?api-version=2022-08-01:
HTTP/2.0 404 Not Found
Content-Length: 238
Cache-Control: no-cache
Content-Type: application/json; charset=utf-8
Date: Sat, 08 Apr 2023 00:36:05 GMT
Expires: -1
Pragma: no-cache
Strict-Transport-Security: max-age=31536000; includeSubDomains
X-Content-Type-Options: nosniff
X-Ms-Correlation-Request-Id: XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
X-Ms-Failure-Cause: gateway
X-Ms-Request-Id: XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
X-Ms-Routing-Request-Id: WESTCENTRALUS:20230408T003606Z:XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
{"error":{"code":"ResourceNotFound","message":"The Resource 'Microsoft.Compute/virtualMachines/provider-bugcheck-vm' under resource group 'provider-bugcheck-rg' was not found. For more details please go to https://aka.ms/ARMResourceNotFoundFix"}}: timestamp=2023-04-07T19:36:06.003-0500
2023-04-07T19:36:06.521-0500 [DEBUG] provider.terraform-provider-azurerm_v3.44.0_x5: AzureRM Request:
PUT /subscriptions/<target_subscription>/resourceGroups/provider-bugcheck-rg/providers/Microsoft.Compute/virtualMachines/provider-bugcheck-vm?api-version=2022-08-01 HTTP/1.1
Host: management.azure.com
User-Agent: Go/go1.19.3 (amd64-darwin) go-autorest/v14.2.1 Azure-SDK-For-Go/v66.0.0 compute/2022-08-01 HashiCorp Terraform/1.4.4 (+https://www.terraform.io) Terraform Plugin SDK/2.10.1 terraform-provider-azurerm/dev pid-XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
Content-Length: 1932
Content-Type: application/json; charset=utf-8
X-Ms-Correlation-Request-Id: XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
Accept-Encoding: gzip
{"identity":{"type":"None"},"location":"westus3","properties":{"additionalCapabilities":{},"applicationProfile":{"galleryApplications":[]},"diagnosticsProfile":{"bootDiagnostics":{"enabled":false,"storageUri":""}},"extensionsTimeBudget":"PT1H30M","hardwareProfile":{"vmSize":"Standard_A1_v2"},"networkProfile":{"networkInterfaces":[{"id":"/subscriptions/<target_subscription>/resourceGroups/provider-bugcheck-rg/providers/Microsoft.Network/networkInterfaces/provider-bugcheck-nic","properties":{"primary":true}}]},"osProfile":{"computerName":"provider-bugcheck-vm","adminUsername":"adminuser","linuxConfiguration":{"disablePasswordAuthentication":true,"ssh":{"publicKeys":[{"path":"/home/adminuser/.ssh/authorized_keys","keyData":"ssh-rsa <pubkey_data>\n"}]},"provisionVMAgent":true,"patchSettings":{"patchMode":"ImageDefault","assessmentMode":"ImageDefault"}},"secrets":[],"allowExtensionOperations":true},"priority":"Regular","storageProfile":{"imageReference":{"id":"/subscriptions/<source_image_subscription>/resourceGroups/<source_image_rg>/providers/Microsoft.Compute/galleries/<source_image_gallery>/images/<source_image>/versions/<source_image_version>"},"osDisk":{"osType":"Linux","caching":"ReadWrite","writeAcceleratorEnabled":false,"createOption":"FromImage","managedDisk":{"storageAccountType":"Standard_LRS"}},"dataDisks":[]}},"tags":{}}: timestamp=2023-04-07T19:36:06.521-0500
2023-04-07T19:36:06.662-0500 [DEBUG] provider.terraform-provider-azurerm_v3.44.0_x5: AzureRM Response for https://management.azure.com/subscriptions/<target_subscription>/resourceGroups/provider-bugcheck-rg/providers/Microsoft.Compute/virtualMachines/provider-bugcheck-vm?api-version=2022-08-01:
HTTP/2.0 403 Forbidden
Content-Length: 464
Cache-Control: no-cache
Content-Type: application/json; charset=utf-8
Date: Sat, 08 Apr 2023 00:36:05 GMT
Expires: -1
Pragma: no-cache
Strict-Transport-Security: max-age=31536000; includeSubDomains
X-Content-Type-Options: nosniff
X-Ms-Correlation-Request-Id: XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
X-Ms-Failure-Cause: gateway
X-Ms-Request-Id: XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
X-Ms-Routing-Request-Id: WESTCENTRALUS:20230408T003606Z:XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
{"error":{"code":"LinkedAuthorizationFailed","message":"The client has permission to perform action 'Microsoft.Compute/galleries/images/versions/read' on scope '/subscriptions/<target_subscription>/resourceGroups/provider-bugcheck-rg/providers/Microsoft.Compute/virtualMachines/provider-bugcheck-vm', however the current tenant '<target_tenant>' is not authorized to access linked subscription '<source_image_subscription>'."}}: timestamp=2023-04-07T19:36:06.662-0500
2023-04-07T19:36:06.663-0500 [DEBUG] provider.terraform-provider-azurerm_v3.44.0_x5: Unlocking "azurerm_virtual_machine.provider-bugcheck-vm": timestamp=2023-04-07T19:36:06.663-0500
2023-04-07T19:36:06.663-0500 [DEBUG] provider.terraform-provider-azurerm_v3.44.0_x5: Unlocked "azurerm_virtual_machine.provider-bugcheck-vm": timestamp=2023-04-07T19:36:06.663-0500
2023-04-07T19:36:06.663-0500 [ERROR] provider.terraform-provider-azurerm_v3.44.0_x5: Response contains error diagnostic: @module=sdk.proto diagnostic_detail= diagnostic_summary="creating Linux Virtual Machine: (Name "provider-bugcheck-vm" / Resource Group "provider-bugcheck-rg"): compute.VirtualMachinesClient#CreateOrUpdate: Failure sending request: StatusCode=403 -- Original Error: Code="LinkedAuthorizationFailed" Message="The client has permission to perform action 'Microsoft.Compute/galleries/images/versions/read' on scope '/subscriptions/<target_subscription>/resourceGroups/provider-bugcheck-rg/providers/Microsoft.Compute/virtualMachines/provider-bugcheck-vm', however the current tenant '<target_tenant>' is not authorized to access linked subscription '<source_image_subscription>'."" tf_proto_version=5.3 tf_req_id=XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX @caller=github.com/hashicorp/[email protected]/tfprotov5/internal/diag/diagnostics.go:55 diagnostic_severity=ERROR tf_provider_addr=provider tf_resource_type=azurerm_linux_virtual_machine tf_rpc=ApplyResourceChange timestamp=2023-04-07T19:36:06.663-0500
2023-04-07T19:36:06.686-0500 [ERROR] vertex "azurerm_linux_virtual_machine.main" error: creating Linux Virtual Machine: (Name "provider-bugcheck-vm" / Resource Group "provider-bugcheck-rg"): compute.VirtualMachinesClient#CreateOrUpdate: Failure sending request: StatusCode=403 -- Original Error: Code="LinkedAuthorizationFailed" Message="The client has permission to perform action 'Microsoft.Compute/galleries/images/versions/read' on scope '/subscriptions/<target_subscription>/resourceGroups/provider-bugcheck-rg/providers/Microsoft.Compute/virtualMachines/provider-bugcheck-vm', however the current tenant '<target_tenant>' is not authorized to access linked subscription '<source_image_subscription>'."
│ Error: creating Linux Virtual Machine: (Name "provider-bugcheck-vm" / Resource Group "provider-bugcheck-rg"): compute.VirtualMachinesClient#CreateOrUpdate: Failure sending request: StatusCode=403 -- Original Error: Code="LinkedAuthorizationFailed" Message="The client has permission to perform action 'Microsoft.Compute/galleries/images/versions/read' on scope '/subscriptions/<target_subscription>/resourceGroups/provider-bugcheck-rg/providers/Microsoft.Compute/virtualMachines/provider-bugcheck-vm', however the current tenant '<target_tenant>' is not authorized to access linked subscription '<source_image_subscription>'."
│ with azurerm_linux_virtual_machine.main,
│ on main.tf line 51, in resource "azurerm_linux_virtual_machine" "main":
│ 51: resource "azurerm_linux_virtual_machine" "main" {
2023-04-07T19:36:06.710-0500 [DEBUG] provider.stdio: received EOF, stopping recv loop: err="rpc error: code = Unavailable desc = error reading from server: EOF"
2023-04-07T19:36:06.717-0500 [DEBUG] provider: plugin process exited: path=.terraform/providers/registry.terraform.io/hashicorp/azurerm/3.44.0/darwin_amd64/terraform-provider-azurerm_v3.44.0_x5 pid=58198
2023-04-07T19:36:06.717-0500 [DEBUG] provider: plugin exited
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment