Have Keyvault in Subscription A and Storage account in Subscription B. While creating customer_managed_keygetting error.
Terraform (and AzureRM Provider) Version
Terraform v0.12.26
+ provider.azurerm v2.46.0
Affected Resource(s)
azurerm
azurerm_key_vault_key
azurerm_storage_account
azurerm_storage_account_customer_managed_key
Terraform Configuration Files
provider "azurerm" {
version = "2.46.0"
features {}
}
provider "azurerm" {
alias = "be"
version = "2.46.0"
subscription_id = "00000000-0000-0000-0000-000000000000"
features {}
}
module "stg" {
source = "../res1"
}
module "stg_enc" {
providers = {
azurerm = azurerm.be
}
source = "../res2"
storage_account_id = module.stg.id
key_vault_id = var.key_vault_id
key_name = var.key_name
}
Error in Terraform Apply:
module.mod.module.stg_enc.azurerm_storage_account_customer_managed_key.example: Creating...
Error: Error retrieving Storage Account "rgtfaccountstg" (Resource Group "rg-tf"): storage.AccountsClient#GetProperties: Failure responding to request: StatusCode=404 -- Original Error: autorest/azure: Servicereturned an error. Status=404 Code="ResourceGroupNotFound" Message="Resource group 'rg-tf' could not be found."
on ../res3/main.tf line 13, in resource "azurerm_storage_account_customer_managed_key" "example":
13: resource "azurerm_storage_account_customer_managed_key" "example" {
Debug Output
2021/07/22 13:45:22 [TRACE] EvalReadState: reading state for module.mod.module.stg_enc.azurerm_storage_account_customer_managed_key.example
2021/07/22 13:45:22 [TRACE] EvalReadState: no state present for module.mod.module.stg_enc.azurerm_storage_account_customer_managed_key.example
2021/07/22 13:45:22 [TRACE] module.mod.module.stg_enc: eval: *terraform.EvalReduceDiff
2021/07/22 13:45:22 [TRACE] module.mod.module.stg_enc: eval: *terraform.EvalIf
2021/07/22 13:45:22 [TRACE] module.mod.module.stg_enc: eval: terraform.EvalNoop
2021/07/22 13:45:22 [TRACE] module.mod.module.stg_enc: eval: *terraform.EvalApplyPre
2021/07/22 13:45:22 [TRACE] module.mod.module.stg_enc: eval: *terraform.EvalApply
2021/07/22 13:45:22 [DEBUG] module.mod.module.stg_enc.azurerm_storage_account_customer_managed_key.example: applying the planned Create change
2021/07/22 13:45:22 [TRACE] GRPCProvider: ApplyResourceChange
2021-07-22T13:45:22.342Z [DEBUG] plugin.terraform-provider-azurerm_v2.46.0_x5: [DEBUG] Locking "azurerm_storage_account.rgtfaccountstg"
2021-07-22T13:45:22.342Z [DEBUG] plugin.terraform-provider-azurerm_v2.46.0_x5: [DEBUG] Locked "azurerm_storage_account.rgtfaccountstg"
2021-07-22T13:45:22.342Z [DEBUG] plugin.terraform-provider-azurerm_v2.46.0_x5: [DEBUG] AzureRM Request:
2021-07-22T13:45:22.342Z [DEBUG] plugin.terraform-provider-azurerm_v2.46.0_x5: GET /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg-tf/providers/Microsoft.Storage/storageAccounts/rgtfaccountstg?api-version=2019-06-01 HTTP/1.1
2021-07-22T13:45:22.342Z [DEBUG] plugin.terraform-provider-azurerm_v2.46.0_x5: Host: management.azure.com
2021-07-22T13:45:22.342Z [DEBUG] plugin.terraform-provider-azurerm_v2.46.0_x5: User-Agent: Go/go1.15.5 (amd64-linux) go-autorest/v14.2.1 Azure-SDK-For-Go/v49.2.0 storage/2019-06-01 HashiCorp Terraform/0.12.26 (+https://www.terraform.io) Terraform Plugin SDK/1.13.1 terraform-provider-azurerm/2.46.0 cloud-shell/1.0 pid-222c6c49-1b0a-5959-a213-6608f9eb8820
2021-07-22T13:45:22.342Z [DEBUG] plugin.terraform-provider-azurerm_v2.46.0_x5: X-Ms-Correlation-Request-Id: d7210652-a1cf-d4dd-ab6c-0be0ead53c71
2021-07-22T13:45:22.342Z [DEBUG] plugin.terraform-provider-azurerm_v2.46.0_x5: Accept-Encoding: gzip
2021-07-22T13:45:22.342Z [DEBUG] plugin.terraform-provider-azurerm_v2.46.0_x5:
2021-07-22T13:45:22.342Z [DEBUG] plugin.terraform-provider-azurerm_v2.46.0_x5:
2021-07-22T13:45:22.554Z [DEBUG] plugin.terraform-provider-azurerm_v2.46.0_x5: [DEBUG] AzureRM Response for https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg-tf/providers/Microsoft.Storage/storageAccounts/rgtfaccountstg?api-version=2019-06-01:
2021-07-22T13:45:22.554Z [DEBUG] plugin.terraform-provider-azurerm_v2.46.0_x5: HTTP/2.0 404 Not Found
2021-07-22T13:45:22.554Z [DEBUG] plugin.terraform-provider-azurerm_v2.46.0_x5: Content-Length: 97
2021-07-22T13:45:22.554Z [DEBUG] plugin.terraform-provider-azurerm_v2.46.0_x5: Cache-Control: no-cache
2021-07-22T13:45:22.554Z [DEBUG] plugin.terraform-provider-azurerm_v2.46.0_x5: Content-Type: application/json; charset=utf-8
2021-07-22T13:45:22.554Z [DEBUG] plugin.terraform-provider-azurerm_v2.46.0_x5: Date: Thu, 22 Jul 2021 13:45:22 GMT
2021-07-22T13:45:22.554Z [DEBUG] plugin.terraform-provider-azurerm_v2.46.0_x5: Expires: -1
2021-07-22T13:45:22.554Z [DEBUG] plugin.terraform-provider-azurerm_v2.46.0_x5: Pragma: no-cache
2021-07-22T13:45:22.554Z [DEBUG] plugin.terraform-provider-azurerm_v2.46.0_x5: Strict-Transport-Security: max-age=31536000; includeSubDomains
2021-07-22T13:45:22.554Z [DEBUG] plugin.terraform-provider-azurerm_v2.46.0_x5: X-Content-Type-Options: nosniff
2021-07-22T13:45:22.554Z [DEBUG] plugin.terraform-provider-azurerm_v2.46.0_x5: X-Ms-Correlation-Request-Id: d7210652-a1cf-d4dd-ab6c-0be0ead53c71
2021-07-22T13:45:22.554Z [DEBUG] plugin.terraform-provider-azurerm_v2.46.0_x5: X-Ms-Failure-Cause: gateway
2021-07-22T13:45:22.554Z [DEBUG] plugin.terraform-provider-azurerm_v2.46.0_x5: X-Ms-Request-Id: 97665b11-9ccd-4997-bf19-c390956d8a03
2021-07-22T13:45:22.554Z [DEBUG] plugin.terraform-provider-azurerm_v2.46.0_x5: X-Ms-Routing-Request-Id: JIOINDIAWEST:20210722T134522Z:97665b11-9ccd-4997-bf19-c390956d8a03
2021-07-22T13:45:22.554Z [DEBUG] plugin.terraform-provider-azurerm_v2.46.0_x5:
2021-07-22T13:45:22.554Z [DEBUG] plugin.terraform-provider-azurerm_v2.46.0_x5: {"error":{"code":"ResourceGroupNotFound","message":"Resource group 'rg-tf' could not be found."}}
2021-07-22T13:45:22.555Z [DEBUG] plugin.terraform-provider-azurerm_v2.46.0_x5: [DEBUG] Unlocking "azurerm_storage_account.rgtfaccountstg"
2021-07-22T13:45:22.555Z [DEBUG] plugin.terraform-provider-azurerm_v2.46.0_x5: [DEBUG] Unlocked "azurerm_storage_account.rgtfaccountstg"
2021/07/22 13:45:22 [DEBUG] module.mod.module.stg_enc.azurerm_storage_account_customer_managed_key.example: apply errored, but we're indicating that via the Error pointer rather than returning it: Error retrieving Storage Account "rgtfaccountstg" (Resource Group "rg-tf"): storage.AccountsClient#GetProperties: Failure responding to request: StatusCode=404 -- Original Error: autorest/azure: Service returned an error. Status=404 Code="ResourceGroupNotFound" Message="Resource group 'rg-tf' could not be found."