data source using for_each

258 vues
Accéder directement au premier message non lu

Krishna Nag

non lue,
19 juin 2021, 03:58:2619/06/2021
à Terraform
i need to get app service plan id's using the data source and use these to create app services.

 i am getting the id if it is single value.


data "azurerm_app_service_plan" "aspnameid" {
  for_each = { for n in var.appservice_plan : n.appservice_plan_name => n }
 name                = each.value.appservice_plan_name
  resource_group_name = var.resource_group_name

   depends_on = [
   module.root_appserviceplan
   ]
}

i was trying use it as below  #appservice_plan_id                  = data.azurerm_app_service_plan.asp_id[each.value.asp_name].id

but this is not working for me. any ideal solution to get multiple app service plan ids and use in creating multiple app services. Thanks

Fernando 🐼

non lue,
19 juin 2021, 06:31:2319/06/2021
à terrafo...@googlegroups.com
I assume your for each is the same index? 

--
Fernando 🐼

--
In the coming weeks, inbound messages to this group will be disabled, and it will be used for outbound announcements only. To prepare for this switch, please direct questions and conversations to our primary medium to communicate with practitioners: https://discuss.hashicorp.com/c/terraform-core/27. We look forward to collaborating with you there!
 
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/hashicorp/terraform/issues
---
You received this message because you are subscribed to the Google Groups "Terraform" group.
To unsubscribe from this group and stop receiving emails from it, send an email to terraform-too...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/terraform-tool/a69435ee-79b7-4337-bf4d-8832f2ca0823n%40googlegroups.com.

Krishna Nag

non lue,
19 juin 2021, 10:51:0719/06/2021
à terrafo...@googlegroups.com
Sorry

i did not get what you mentioned her  "for_each same index"

Thanks



--
Regards,
Krishna Nagubadi

Fernando 🐼

non lue,
19 juin 2021, 10:52:0319/06/2021
à terrafo...@googlegroups.com
Can you share your code.? 

--
Fernando 🐼

Alexandra Freeman

non lue,
21 juin 2021, 10:32:2321/06/2021
à Terraform
Hello and thank you for your question!
On June 3, 2019 HashiCorp launched Discuss, a forum to facilitate dialogue within the HashiCorp community. This format allows answers to be more readily searched and indexed, making it easier to find answers to existing questions and to share knowledge with each other. Please direct all questions and conversations to the discussion forum. We look forward to collaborating with you there!

Cheers!

Krishna Nag

non lue,
21 juin 2021, 10:57:4421/06/2021
à terrafo...@googlegroups.com
Hi 

end up using count and it worked

Répondre à tous
Répondre à l'auteur
Transférer
0 nouveau message