Skip to content

Instantly share code, notes, and snippets.

@khaliqgant
Created March 29, 2022 11:47
Show Gist options
  • Save khaliqgant/22a613818f0d00fea04727b4cf26c967 to your computer and use it in GitHub Desktop.
Save khaliqgant/22a613818f0d00fea04727b4cf26c967 to your computer and use it in GitHub Desktop.
[Terraform Output] Output from for_each #terraform #infrastructure
# object
output "repo_ids" {
value = {
for idx,repo in aws_ecr_repository.repo : idx => repo.registry_id
}
}
# list
output elastic_ips {
value = [for eip in aws_eip.eip : eip.id]
}
# source https://www.reddit.com/r/Terraform/comments/f4nr7v/how_do_you_capture_the_output_of_subnet_id_from_a/
https://www.hashicorp.com/blog/hashicorp-terraform-0-12-preview-for-and-for-each
# https://stackoverflow.com/questions/60717236/how-to-define-a-list-of-output-when-using-list-and-for-each-in-terraform
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment