Skip to main content
Knowledge Base

Terragrunt getting outputs from dependency witha collection and index

Answer

`dependency "vpc" { config_path = find_in_parent_folders("vpc") mock_outputs = { vpc_id = "temp-id" } } inputs = { vpc_id = dependency.vpc.outputs.vpc_id }` the above plan works fine with mock outputs with dependency with terragrunt,terraform and google cloud resources. All fine. I am looking for a similar solution which works with collections of values with index However say my depedency has output which is a collection like below, which is the google cloud resource output to create folders. This module is at this [link](https://github.com/terraform-google-modules/terraform-google-folders/tree/v3.0.0) `"ids": { "value": { "General": "folders/123456789" }` Now i want to refer this ``` dependency "parent_folder" { config_path = "${get_terragrunt_dir()}/../folders" mock_outputs = { ids = { "General": "folders/123456789" } } } inputs = { folder_id = dependency.parent_folder.outputs.ids["General"] } ``` This doesnt work and complains that "Invalid index; The given key does not identify an element in this collection value." The error happens as the folder "General" is not created yet and is a dependency. Any help on this? --- <ins datetime="2024-04-15T18:48:02Z"> <p><a href="https://support.gruntwork.io/hc/requests/110880">Tracked in ticket #110880</a></p> </ins>

found the answer with mock_outputs_merge_strategy_with_state