Closed neil-yechenwei closed 2 years ago
Hi @neil-yechenwei 👋 Thank you for raising this and apologies for the delayed response.
As far as I know, the SDK only calls and does not modify a given StateChangeConf.Refresh
function, so it is very unlikely that the SDK itself is doing anything different over time. If the API client is dependent on underlying authentication or authorization information on the system in which it is running, it could be that information changed between executions and the API client reacted to those changes. That would be outside this SDK though, which is only just calling the refresh function given.
If you are still experiencing issues with this, my best recommendation would be to open an issue in the Terraform AzureRM Provider repository as those maintainers may know additional details about the behaviors of the particular API client.
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 have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.
terraform-plugin-sdk version: v2.7.0 Terraform version: 1.0.9 AzureRM provider version: 2.82.0
Impacted resource:
https://github.com/hashicorp/terraform-provider-azurerm/blob/v2.82.0/internal/services/monitor/monitor_metric_alert_resource.go
The code snippet for WaitForStateContext in resource Monitor Metric Alert:
Terraform configuration file:
Debug log:
Expected Behavior:
The resource azurerm_monitor_metric_alert should be created successfully without error while using WaitForStateContext.
Actual Behavior:
It intermittently failed to create the resource azurerm_monitor_metric_alert while using WaitForStateContext and threw below error message. Per the error message, seems the authorization header would be removed intermittently while creating this resource with WaitForStateContext.
Error message:
09:15:02 module.xxx.azurerm_monitor_metric_alert.xxx: Creating... 09:15:12 module.xxx.azurerm_monitor_metric_alert.xxx: Still creating... [10s elapsed] 09:15:22 module.xxx.azurerm_monitor_metric_alert.xxx: Still creating... [20s elapsed] 09:15:23 Error: waiting for Monitor Metric Alert: (Name "xxxxx" / Resource Group "xxxxx") to finish provisioning: retrieving Monitor Metric Alert "xxxxx" (Resource Group "xxxxx"): insights.MetricAlertsClient#Get: Failure responding to request: StatusCode=401 -- Original Error: autorest/azure: Service returned an error. Status=401 Code="AuthenticationFailed" Message="Authentication failed. The 'Authorization' header is missing."
Steps to Reproduce:
terraform init
terraform apply