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.51k stars 4.6k forks source link

Time Exceeded when applying a Subscription #19701

Open Holmern opened 1 year ago

Holmern commented 1 year ago

Is there an existing issue for this?

Community Note

Terraform Version

1.3.5

AzureRM Provider Version

3.30.0

Affected Resource(s)/Data Source(s)

azurerm_subscription

Terraform Configuration Files

resource "azurerm_subscription" "this" {
  subscription_name = "${var.name}-${var.env}"
  billing_scope_id  = data.azurerm_billing_mca_account_scope.this.id
}

module "name_subscription" {
  source = "./subscription"

  for_each            = toset(["dev", "prod"])
  env                 = each.key
  name                = "name-it"
  management_group_id = module.name_management_group.management_group_id

  #VAR                  # Output fra Github Module
  repo_name = module.name_github.repo_name

  #   end_date                         = "" #Not required
  #   role_definition_name             = "" #Not Required
  #   federated_credential_description = "" #Not Required
}

Debug Output/Panic Output

│ Error: creating new Subscription (Alias "xxxxxxxxxxxxxxxxxxxxxxxx"): subscription.AliasClient#Create: Failure sending request: StatusCode=0 -- Original Error: context deadline exceeded

Expected Behaviour

Apply the subscription

Actual Behaviour

Pipeline fails with error: │ Error: creating new Subscription (Alias "472dfbe3-4b90-4ddd-97f9-887a803e16d7"): subscription.AliasClient#Create: Failure sending request: StatusCode=0 -- Original Error: context deadline exceeded

Steps to Reproduce

    - name: Terraform Apply
      env:
          GH_TOKEN: ${{ secrets.GH_TOKEN }}
      run: terraform apply -auto-approve

When running our GitHub Actions pipeline with apply, the output returns a [still creating], it does this for 30 minuts until the pipeline throws an error which states: Original Error: context deadline exceeded. The thing is, I did apply and create the prod subscription, but it won't create the "dev" subscription. Is there something I can do for getting a quicker apply and then provision the Subscription? Internet speed, to many resources that want to apply at the same time (even if we are down to 4 resources) or just bad luck and try again tomorrow

Important Factoids

West Europe

References

non

ms-zhenhua commented 1 year ago

Hi @Holmern, thank you for reaching out. From the error message, it seems that it is the Azure Service who did not respond the request of creating subscription. Do you always meet this issue? If so, could you kindly add 2 environment variables TF_LOG="DEBUG" and TF_LOG_PATH=\<your local directory> according to this document and recreate the subscription by Terraform? Then could you please provide the log(you could first remove any sensitive data) to us to have a further investigation? Thanks.

Holmern commented 1 year ago
PUT /providers/Microsoft.Subscription/aliases/c15354e0-07ea-42b5-ba43-fd024b977f92?api-version=2020-09-01 HTTP/1.1
[31566](https://github.com/Three-Way-Handshake/Bachelor-baseline/actions/runs/3715403153/jobs/6300939810#step:9:31566)
Host: management.azure.com
[31567](https://github.com/Three-Way-Handshake/Bachelor-baseline/actions/runs/3715403153/jobs/6300939810#step:9:31567)
User-Agent: Go/go1.19.3 (amd64-linux) go-autorest/v14.2.1 Azure-SDK-For-Go/v66.0.0 subscription/2020-09-01 HashiCorp Terraform/1.3.6 (+https://www.terraform.io)/ Terraform Plugin SDK/2.10.1 terraform-provider-azurerm/dev pid-222c6c49-1b0a-5959-a213-6608f9eb8820
[31568](https://github.com/Three-Way-Handshake/Bachelor-baseline/actions/runs/3715403153/jobs/6300939810#step:9:31568)
Content-Length: 287
[31569](https://github.com/Three-Way-Handshake/Bachelor-baseline/actions/runs/3715403153/jobs/6300939810#step:9:31569)
Content-Type: application/json; charset=utf-8
[31570](https://github.com/Three-Way-Handshake/Bachelor-baseline/actions/runs/3715403153/jobs/6300939810#step:9:31570)
X-Ms-Authorization-Auxiliary: 
[31571](https://github.com/Three-Way-Handshake/Bachelor-baseline/actions/runs/3715403153/jobs/6300939810#step:9:31571)
X-Ms-Correlation-Request-Id: dbf355ac-72ff-084d-93dd-4f64d4959ace
[31572](https://github.com/Three-Way-Handshake/Bachelor-baseline/actions/runs/3715403153/jobs/6300939810#step:9:31572)
Accept-Encoding: gzip
[31573](https://github.com/Three-Way-Handshake/Bachelor-baseline/actions/runs/3715403153/jobs/6300939810#step:9:31573)
{"properties":{"displayName":"******-prod","workload":"Production","billingScope":"/providers/Microsoft.Billing/billingAccounts/******/billingProfiles/******/invoiceSections/******"}}: timestamp=2022-12-16T18:30:59.924Z
[31575](https://github.com/Three-Way-Handshake/Bachelor-baseline/actions/runs/3715403153/jobs/6300939810#step:9:31575)
2022-12-16T18:31:01.378Z [DEBUG] provider.terraform-provider-azurerm_v3.35.0_x5: AzureRM Response for https://management.azure.com/providers/Microsoft.Subscription/aliases/c15354e0-07ea-42b5-ba43-fd024b977f92?api-version=2020-09-01: 
[31576](https://github.com/Three-Way-Handshake/Bachelor-baseline/actions/runs/3715403153/jobs/6300939810#step:9:31576)
HTTP/2.0 429 Too Many Requests
[31577](https://github.com/Three-Way-Handshake/Bachelor-baseline/actions/runs/3715403153/jobs/6300939810#step:9:31577)
Content-Length: 191
[31578](https://github.com/Three-Way-Handshake/Bachelor-baseline/actions/runs/3715403153/jobs/6300939810#step:9:31578)
Cache-Control: no-cache
[31579](https://github.com/Three-Way-Handshake/Bachelor-baseline/actions/runs/3715403153/jobs/6300939810#step:9:31579)
Content-Type: application/json; charset=utf-8
[31580](https://github.com/Three-Way-Handshake/Bachelor-baseline/actions/runs/3715403153/jobs/6300939810#step:9:31580)
Date: Fri, 16 Dec 2022 18:31:00 GMT
[31581](https://github.com/Three-Way-Handshake/Bachelor-baseline/actions/runs/3715403153/jobs/6300939810#step:9:31581)
Expires: -1
[31582](https://github.com/Three-Way-Handshake/Bachelor-baseline/actions/runs/3715403153/jobs/6300939810#step:9:31582)
Mise-Correlation-Id: d8b6a649-6348-4ee2-9c1c-a076a02fc4a7
[31583](https://github.com/Three-Way-Handshake/Bachelor-baseline/actions/runs/3715403153/jobs/6300939810#step:9:31583)
Ms-Cv: y/zacEKzSk6sUqi2l5w1OQ.0
[31584](https://github.com/Three-Way-Handshake/Bachelor-baseline/actions/runs/3715403153/jobs/6300939810#step:9:31584)
Pragma: no-cache
[31585](https://github.com/Three-Way-Handshake/Bachelor-baseline/actions/runs/3715403153/jobs/6300939810#step:9:31585)
Request-Id: dbf355ac-72ff-084d-93dd-4f64d4959ace
[31586](https://github.com/Three-Way-Handshake/Bachelor-baseline/actions/runs/3715403153/jobs/6300939810#step:9:31586)
Server: Microsoft-IIS/10.0
[31587](https://github.com/Three-Way-Handshake/Bachelor-baseline/actions/runs/3715403153/jobs/6300939810#step:9:31587)
Strict-Transport-Security: max-age=31536000; includeSubDomains
[31588](https://github.com/Three-Way-Handshake/Bachelor-baseline/actions/runs/3715403153/jobs/6300939810#step:9:31588)
X-Aspnet-Version: 4.0.30319
[31589](https://github.com/Three-Way-Handshake/Bachelor-baseline/actions/runs/3715403153/jobs/6300939810#step:9:31589)
X-Content-Type-Options: nosniff
[31590](https://github.com/Three-Way-Handshake/Bachelor-baseline/actions/runs/3715403153/jobs/6300939810#step:9:31590)
X-Gsm: 1.0.0.0
[31591](https://github.com/Three-Way-Handshake/Bachelor-baseline/actions/runs/3715403153/jobs/6300939810#step:9:31591)
X-Ms-Correlation-Request-Id: dbf355ac-72ff-084d-93dd-4f64d4959ace
[31592](https://github.com/Three-Way-Handshake/Bachelor-baseline/actions/runs/3715403153/jobs/6300939810#step:9:31592)
X-Ms-Ratelimit-Remaining-Tenant-Writes: 1197
[31593](https://github.com/Three-Way-Handshake/Bachelor-baseline/actions/runs/3715403153/jobs/6300939810#step:9:31593)
X-Ms-Request-Id: d069f58c-f1b0-47be-bf3c-e065bbcfdef8
[31594](https://github.com/Three-Way-Handshake/Bachelor-baseline/actions/runs/3715403153/jobs/6300939810#step:9:31594)
X-Ms-Routing-Request-Id: EASTUS2:20221216T183101Z:d069f58c-f1b0-47be-bf3c-e065bbcfdef8
[31595](https://github.com/Three-Way-Handshake/Bachelor-baseline/actions/runs/3715403153/jobs/6300939810#step:9:31595)
X-Powered-By: ASP.NET
[31596](https://github.com/Three-Way-Handshake/Bachelor-baseline/actions/runs/3715403153/jobs/6300939810#step:9:31596)
{"error":{"code":"TooManyRequests","message":"Subscription is not created. Please try again later."},"code":"TooManyRequests","message":"Subscription is not created. Please try again later."}: timestamp=2022-12-16T18:31:01.378Z
ms-zhenhua commented 1 year ago

Hi @Holmern, the error is returned by the Azure Service. I have created this issue to ask the reason.

Holmern commented 1 year ago

Hi @ms-zhenhua! Thank you for opening the issue, are there any updates? Besides what is in the issue?

Holmern commented 1 year ago

@ms-zhenhua We can provide you a little more information, we don't receive the error when deploying other resources

ms-zhenhua commented 1 year ago

Hi @Holmern, the Azure service team is still looking into this issue.