Terraform for loop, for_each loop and count - Part 6

  Рет қаралды 44,857

Rahul Wagh

Rahul Wagh

Күн бұрын

Terraform for loop, for_each loop and count
▬▬▬▬▬▬ ⭐️ Instruction's Guides ⭐️ ▬▬▬▬▬▬
1. How to use Terraform for loop, for_each loop and count? - jhooq.com/terraform-for-and-f...
▬▬▬▬▬▬ ⭐️ Previous Terraform tutorials ⭐️ ▬▬▬▬▬▬
Part 1: Terraform Explained | How to create your first terraform infrastructure on AWS and Google Cloud - • Terraform Explained | ...
Part 2: Terraform Input Variable (string, number, boo, list, map...) | How to use Terraform Input Variable - • Terraform Input Variab...
Part 3 : Terraform variable.tf | terraform.tfvars | Terraform command line variables - • Terraform variable.tf ...
Part 4: Terraform Locals | How to use Terraform Locals? - • Terraform Output Value...
Part 5: Terraform output values | How to use Terraform Output Values? - • Terraform Locals | How...
Terraform for, for_each and count loops can be used for iterating over the collections like list, set and map.
▬▬▬▬▬▬ ⭐️ 🕘Timestamps ⭐️ ▬▬▬▬▬▬
0:00 - What is for, for_each and count loops
00:42 - for loop
08:21 - for_each loop
12:17 - count
For more details on Terraform here is the official guide -www.terraform.io/docs/languag...
To learn more on DevOps visit - jhooq.com
Disclaimer/Policy: All the content/instructions are solely mine. The source is completely open-source.
Video is copyrighted and can not be re-distributed on any platform.
#devops #terraform #InfrastructureasCode #cloud

Пікірлер: 75
@newallst
@newallst 2 жыл бұрын
There are a lot of complicated explanations out there on how to do loops / for_each loops using Terraform. You nailed it beautifully. Thank you.
@RahulWagh
@RahulWagh 2 жыл бұрын
Glad you enjoyed it!
@distantignition
@distantignition Жыл бұрын
I want to point out that you should use count as little as possible, especially on resource creation. If you have resource A,B,C,D, that will give you resources 0,1,2,3. If B is then no longer needed, C slides into the "1" slot and D into the "2" slot. This is a huge pain. It will try to force resource recreation, which is fixable, but working around this isn't worth it. Just use for_each and reference the resource index by name. The resources need to be a set or map, but you can convert a list of strings with toset().
@vettomd
@vettomd 2 жыл бұрын
Love the way you explain by adding context and bit of concept.
@RahulWagh
@RahulWagh 2 жыл бұрын
Glad to hear that you like the terraform sessions
@etpienaar
@etpienaar Жыл бұрын
can you use it to iterate through deploying to different regions - like aws config rule applied to multiple regions using the for loops, as there is no region id other than provider Thanks :)
@aalaka330
@aalaka330 2 жыл бұрын
Hi, Thanks for the awesome explanations. Can you please tell, how we can use foreach loop to create multiple widgets in a dashboard?
@joe_wheat
@joe_wheat 2 жыл бұрын
thank you for your knowledge sharing! You make a great work!
@RahulWagh
@RahulWagh 2 жыл бұрын
Thanks for the feedback
@nguyenminh15988
@nguyenminh15988 3 жыл бұрын
Thanks for your videos! It's really nice.
@RahulWagh
@RahulWagh 3 жыл бұрын
Glad you like them!
@ramamt6350
@ramamt6350 2 жыл бұрын
Thank you For Sharing Valuable Concepts.
@twizzoe
@twizzoe 2 жыл бұрын
Thank you very much Rahul, I have learnt a lot from your Terraform videos. I can't wait to get to your other videos. Gracias
@RahulWagh
@RahulWagh 2 жыл бұрын
Glad to hear that
@praveenchintu1312
@praveenchintu1312 2 жыл бұрын
Perfectly explained!
@RahulWagh
@RahulWagh 2 жыл бұрын
Glad you think so!
@ThinkDatahub
@ThinkDatahub Жыл бұрын
Thank you for a very wonderful presentation. However, my question is, since both the for_each and count produce the same results on AWS, am interested in knowing the difference and why should I prefer one over the other? Thank you very much!
@rajrocky8658
@rajrocky8658 11 ай бұрын
Nice explanation. Keep up the good work :)
@HavingFunWithAvyan
@HavingFunWithAvyan 8 ай бұрын
Hi Rahul, thanks but how can test the out value of the functions some times locally
@TrollStdin
@TrollStdin 2 жыл бұрын
This is a pretty good explanation, is so good I even included the link on one of my videos, please keep the good work.
@RahulWagh
@RahulWagh 2 жыл бұрын
Awesome, thank you!
@happylearningtricks
@happylearningtricks Жыл бұрын
learning from your videos Rahul - thanks for your videos
@RahulWagh
@RahulWagh Жыл бұрын
Glad to hear that
@sivarasana3641
@sivarasana3641 Жыл бұрын
Great session sir
@RahulWagh
@RahulWagh Жыл бұрын
Keep watching
@RohitSyd
@RohitSyd Жыл бұрын
Great explanation
@piyushbagani9244
@piyushbagani9244 2 жыл бұрын
So Can for loop be used to create resources or it is used for output only?
@sathishdarshanala5492
@sathishdarshanala5492 2 жыл бұрын
hi rahul you have given count = length(var.user_names) iam littile confusing over here, are you calling another file which you have mentioned already as var.user_names somewhere?
@sudheerk406
@sudheerk406 2 жыл бұрын
You are Awesome man.
@RahulWagh
@RahulWagh 2 жыл бұрын
Thanks I hope you liked the terraform series
@joepinto5066
@joepinto5066 2 жыл бұрын
hi, a question how to output values if we use in resource foreach example: resource "aws_subnet" "public" { for_each = var.pub_subnet vpc_id = aws_vpc.vpc.id cidr_block = each.value.cidr_block
@RahulWagh
@RahulWagh 2 жыл бұрын
You have to write the output block for that
@suneeshmsuresh1092
@suneeshmsuresh1092 3 жыл бұрын
Simply Explained...👍👍👌👌
@RahulWagh
@RahulWagh 3 жыл бұрын
Glad you liked it
@cirishafranky
@cirishafranky 2 жыл бұрын
Great post thank you. Also I found out that 'count' is a parameter of terraform, it cannot be anything else. Having this parameter in the block executes the block 'x' number of times specified in count.
@hasan135
@hasan135 2 жыл бұрын
Thanks for sharing this nice video.
@RahulWagh
@RahulWagh 2 жыл бұрын
So nice of you
@yogeshjagadale7385
@yogeshjagadale7385 3 жыл бұрын
Excellent explanation 👍👍👌👌
@RahulWagh
@RahulWagh 3 жыл бұрын
Glad you liked it
@Masaf_YT
@Masaf_YT Жыл бұрын
Hi Rahul you are a fantastic guy that reflects on your face. my blessing all the time with you and keep making nice videos as always. welldone.
@RahulWagh
@RahulWagh Жыл бұрын
Cheers! Hope the sessions are useful for you
@praashanthkumaarpolla6252
@praashanthkumaarpolla6252 Жыл бұрын
Hi .. i have annissue with the subnet and the error is subnet IDs should be list... I don't know what that exactly but finally I got this place to ask .. pleas please help
@RahulWagh
@RahulWagh Жыл бұрын
It is really hard to suggest without knowing full context
@vinaykorrapati2967
@vinaykorrapati2967 3 жыл бұрын
Amazing Videos and nice explanation. Done with the terraform videos..Requesting you to upload the CI CD pipeline stuff as well..
@RahulWagh
@RahulWagh 3 жыл бұрын
There is more to come in terrafrom as well as CI CD. But meanwhile here is one CI CD video which i could recommend to start with - kzbin.info/www/bejne/ioGwhquph65khaM
@YouTubers-rj9xv
@YouTubers-rj9xv 3 жыл бұрын
Excellent teaching...love from andhra
@RahulWagh
@RahulWagh 3 жыл бұрын
Stay tuned for more upcoming similar session
@mdnishadhussain7131
@mdnishadhussain7131 2 жыл бұрын
Awesome explanation! Could you please clear one doubt as all three create the same thing so when to use each? If you can tell me the actual Use Case for each then it would be a great favor. May God Bless you. Thanks once again!
@RahulWagh
@RahulWagh 2 жыл бұрын
Well the simplest use case of for_each would be the terraform dynamic block - if you havn't chcked how to create the dynamic block then please check and it will make more sense - kzbin.info/www/bejne/qV60ZqKKi7t2ldE
@mdnishadhussain7131
@mdnishadhussain7131 2 жыл бұрын
@@RahulWagh Okay..I will go through it for sure.. Thanks.
@SurajRaghunathansrjd8
@SurajRaghunathansrjd8 Жыл бұрын
can you tell me from which site did you use to create your website sir
@RahulWagh
@RahulWagh Жыл бұрын
The website is developed using Hugo site generator. It is a static site not a wordpress site.
@madhurip6263
@madhurip6263 2 жыл бұрын
Hi,Thanks for the awesome explanations.could you please do some videos on terraform version up gradation.
@RahulWagh
@RahulWagh 2 жыл бұрын
Yes, soon
@thandepapa79
@thandepapa79 Жыл бұрын
What's the need of creating Ec2 when you are creating iam_users ? Example- Count.
@2mahender
@2mahender 2 жыл бұрын
can i use for loop creating multiple ec2 instances?
@RahulWagh
@RahulWagh 2 жыл бұрын
Yes you can use for loop for ec2 instance creation
@2mahender
@2mahender 2 жыл бұрын
@@RahulWagh can u make once video on for loop with ec2 instances, as you have used for outputs only
@basavaraddychittargi3038
@basavaraddychittargi3038 2 жыл бұрын
Could please add video on nested for each Ex:let's say..we have list projects for each project I have to provide owner/editor role to list of user
@RahulWagh
@RahulWagh 2 жыл бұрын
I will try to add it into my todo list but can not promise any time soon
@gk4976
@gk4976 3 жыл бұрын
Rahul bro Can you please segregate all Kubernetes videos, actually I'm beginners in Kubernetes and your way of explaining is amazing, could you please make Kubernetes playlist videos step by steps
@RahulWagh
@RahulWagh 3 жыл бұрын
I am glad you liked the session. Here are playlist - 1. Kubernetes - kzbin.info/www/bejne/mKPMppJ7q51sqdk 2. Helm Chart - kzbin.info/www/bejne/pnmqlGttr61_otE 3. Terraform - kzbin.info/www/bejne/oHu7Z4Zrf6Z6pqs //Rahul
@nerellaprasad1862
@nerellaprasad1862 Жыл бұрын
i under stand your session and following you ..
@RahulWagh
@RahulWagh Жыл бұрын
Glad you like the sesion
@arjunt6791
@arjunt6791 2 жыл бұрын
In for loop why we are using output variable values instead of input variables as you implemented in count, and for each loop...
@RahulWagh
@RahulWagh 2 жыл бұрын
Well it is just for tutorial purpose you can have your own implementation as you want
@shubhamsahu1199
@shubhamsahu1199 Жыл бұрын
bhai please explain the differnence between also?
@pratspatel5698
@pratspatel5698 3 жыл бұрын
Eagerly waiting for upcoming video I planning for Terraform associate certification please advise.
@RahulWagh
@RahulWagh 3 жыл бұрын
Thanks prats for the feedback. Well I am preparing a complete series and you will be seeing many more videos on terraform in upcoming weeks. I have planned the complete terraform series but it would little time to prepare all
@n.sudhirkumarn.sudhirkumar3127
@n.sudhirkumarn.sudhirkumar3127 2 жыл бұрын
sir u explain good.. bt try to differentiate whats the purpose of for count why to use For If we can use COUNT try to tell also in ur next vedios in which situation we use for n in which situation we use COUNT
@yogeshjagadale7385
@yogeshjagadale7385 3 жыл бұрын
Please make more videos on Terraform
@RahulWagh
@RahulWagh 3 жыл бұрын
Its on my calendar. You will see more terrafrom videos in upcoming weeks and months
@arjunt6791
@arjunt6791 2 жыл бұрын
Here in for each loop, how each.value works , please explain briefly
@RahulWagh
@RahulWagh 2 жыл бұрын
each.value is just like an iteration or if you compare with other programming lang then it is a for loop
@aniruddhamalkar4981
@aniruddhamalkar4981 Жыл бұрын
You should have explain the use of for loop for aws users. When you are doing output you can just printing the list through iteration not the actual iteration. Disappointed.
What are terraform Provisioners? - Part 7
22:01
Rahul Wagh
Рет қаралды 30 М.
路飞被小孩吓到了#海贼王#路飞
00:41
路飞与唐舞桐
Рет қаралды 78 МЛН
🤔Какой Орган самый длинный ? #shorts
00:42
- А что в креме? - Это кАкАооо! #КондитерДети
00:24
Телеканал ПЯТНИЦА
Рет қаралды 7 МЛН
Became invisible for one day!  #funny #wednesday #memes
00:25
Watch Me
Рет қаралды 59 МЛН
Choosing Between Count and For-Each
17:53
Ned in the Cloud
Рет қаралды 12 М.
Crowdstruck (Windows Outage) - Computerphile
14:42
Computerphile
Рет қаралды 119 М.
Parsing Data with For Loops
28:28
Ned in the Cloud
Рет қаралды 11 М.
8 Terraform Best Practices that will improve your TF workflow immediately
8:57
Learn how to use Terraform variables
9:39
Cobus Bernard
Рет қаралды 24 М.
Battery  low 🔋 🪫
0:10
dednahype
Рет қаралды 12 МЛН
Сколько реально стоит ПК Величайшего?
0:37
Как правильно выключать звук на телефоне?
0:17
Люди.Идеи, общественная организация
Рет қаралды 1,8 МЛН
Samsung Galaxy 🔥 #shorts  #trending #youtubeshorts  #shortvideo ujjawal4u
0:10
Ujjawal4u. 120k Views . 4 hours ago
Рет қаралды 8 МЛН
ГОСЗАКУПОЧНЫЙ ПК за 10 тысяч рублей
36:28
Ремонтяш
Рет қаралды 540 М.