admin管理员组

文章数量:1410697

I have deployed App service (azapp-af-advanced-braintreewebhook-callback-web-qc) with

domain_fqdn                = "events.staging.paynow.aon"
key_vault_certificate_name = "uat-paynow-aon-com-cert"

I have applied this domain and certificate to App gateway in staging successfully.

Now I have to update it in Front Door in staging. But while executing pipeline I'm getting error that key provided can't be find in frontend endpoints Map. But I have provided it in locals.tf in frontend_endpoints_list.

Error: Invalid index
│
│   on ..\..\..\..\..\infra-repo\main.tf line 125, in resource "azurerm_frontdoor_custom_https_configuration" "custom_domain_https_config":
│ 125:   frontend_endpoint_id                          = azurerm_frontdoor.frontdoor.frontend_endpoints["${each.value.custom_endpoint_name}"]  
│     ├────────────────
│     │ azurerm_frontdoor.frontdoor.frontend_endpoints is map of string with 18 elements
│     │ each.value.custom_endpoint_name is "events-staging-paynow-aon-com"
│
│ The given key does not identify an element in this collection value.
╵

In locals.tf I have added the key in frontend_endpoint_list after that there are 19 elements in Map but while running pipeline still it is counting as 18.[] (.png)

I have deployed App service (azapp-af-advanced-braintreewebhook-callback-web-qc) with

domain_fqdn                = "events.staging.paynow.aon"
key_vault_certificate_name = "uat-paynow-aon-com-cert"

I have applied this domain and certificate to App gateway in staging successfully.

Now I have to update it in Front Door in staging. But while executing pipeline I'm getting error that key provided can't be find in frontend endpoints Map. But I have provided it in locals.tf in frontend_endpoints_list.

Error: Invalid index
│
│   on ..\..\..\..\..\infra-repo\main.tf line 125, in resource "azurerm_frontdoor_custom_https_configuration" "custom_domain_https_config":
│ 125:   frontend_endpoint_id                          = azurerm_frontdoor.frontdoor.frontend_endpoints["${each.value.custom_endpoint_name}"]  
│     ├────────────────
│     │ azurerm_frontdoor.frontdoor.frontend_endpoints is map of string with 18 elements
│     │ each.value.custom_endpoint_name is "events-staging-paynow-aon-com"
│
│ The given key does not identify an element in this collection value.
╵

In locals.tf I have added the key in frontend_endpoint_list after that there are 19 elements in Map but while running pipeline still it is counting as 18.[] (https://i.sstatic/LYvKundr.png)

Share Improve this question edited Mar 18 at 12:06 Vinay B 2,8242 gold badges3 silver badges12 bronze badges Recognized by Microsoft Azure Collective asked Mar 7 at 13:42 Aman KumarAman Kumar 111 bronze badge 1
  • Can you please run the command terraform state show azurerm_frontdoor.frontdoor to confirm the new endpoint exists @AmanKumar – Vinay B Commented Mar 10 at 4:06
Add a comment  | 

1 Answer 1

Reset to default 0

Azure Front Door Pipeline Plan failed for Key in frontend_endpoint map not found

The issue occurs in general with the locals file you used because the latest updates that are done on locals was may not be reflecting or updated in your state file. Which is the most common scenario in while using terraform.

So to make this state file to update with the latest update on local file, you may need to use a command terraform refresh. This make sure all the inputs from the locals get updated in the state file.

terraform refresh

& follow-up with

terraform plan

Once you run the above commands, all the elements from the locals you declared.

If it can, try mentioning the commands suggested below, then you may need to confirm the existence of the missing resource in the state file by listing it.

terraform state list

Among the list of resources available in the list, make sure you have resource state show command

terraform state show azurerm_frontdoor.frontdoor

or

terraform state show module.frontdoor.azurerm_frontdoor.frontdoor

Depends on the configuration you're using in the repository.

Check if frontend_endpoints includes "events-staging-paynow-aon-com". If it does not, Terraform has not recognized the command which we tried above.

You can also check with by declaring output plugin as mentioned below

output "frontend_endpoints_debug" {
  value = azurerm_frontdoor.frontdoor.frontend_endpoints
}

Which results in all the endpoints you mentioned in locals if this match the updated locals then the state file gets updated as locals configuration.

Once you're able to see all the endpoints in locals as updated, you follow the steps mentioned from initialization.

- name: Terraform Init
  run: terraform init -reconfigure

And continue with the provisioning of the resources as expected.

本文标签: Azure Front Door Pipeline Plan failed for Key in frontendendpoint map not foundStack Overflow