I read official TF Doc, I read some articles. Nothing helped to get an idea how it's actually working. So, I'm happy that I found your video. It's perfect explanation. In fact, probably you're the best presenter that I've ever seen (and I've seen a lot of presenters). Please continue doing your good job!
This is a ridiculously good tutorial on complex data structures in terraform. This is literally exactly what I have been looking for to wrap my head around them. I will be honest, this is not something I would expect from someone with 3.75 K subs. More like 375K. Keep on going, cause you are awesome. Edit: It took all of 5 minutes after watching this tutorial to completely refactor my code to be SOOO much more readable, and actually make logical sense. So thank you again.
Hey Ned, Great job on this video. I was looking for a while for a good explanation about the for_loops in Terraform, as their documentation is lacking a lot of information in that space. Now everything is much clearer! Thank you!
Subscribed. This makes what I'm trying to do so much easier knowing what you just said here. Thank you for saving me hours of looping in my brain so I can work on looping inside my terraform files
Thanks for the video. Do you know how we would loop these into a data source? So for instance how would we loop a list of userprincipalnames into azuread_users to return object ids?
Great video! Been trying to get my head round this for some time and your video explains it perfectly! One question - i saw some code that had the following: For i in var.instances: “${i.name} ${i.zone}” => i Trying to work out if => i is making ‘i’ have the values of i.name and i.zone from each iteration in var.instances? Var.instances was an object containing a name value and a zone value. What does => actually mean?
The syntax can be confusing: { for i in var.instances: "${i.name} ${i.zone}" => i } The curly braces indicate the resulting data type with be an object. The var. instances is the source of the for loop. I would guess that var.instances is a list of maps or objects. The "i" is the iterator for the for loop. As the loop iterates, "i" will load a map from the list of maps stored in var.instances. The i.name and i.zone come from the currently loaded map. Since we are creating an object with key value pairs, the "${i.name} ${i.zone}" is the key and the "i" is the value. The => indicates mapping a key to a value. Hopefully that clears things up! Here's the official docs too: www.terraform.io/docs/language/expressions/for.html
If you are able to pass the data to Terraform as a map that would be great. Sometimes you don't have control over the input format or you want to extract a small portion of a larger data structure.
TY Ned another great demo! now there is no need to declare the variables (variables.tf is not needed) no more finding appropriate type as well. Any chance you could update "terraform-Tuesday" repo as a map (Parsing Data with For Loops => 2021-01-25) just use for loop :) Really hard to trace some of old recording, like this video has been dated 01/26 but the repo folder is 01/25. I am not picky just want to share my feedback