Skip to playerSkip to main content
Learn how to use Terraform for_each loops to create multiple AWS EC2 instances with different server names in this step-by-step DevOps tutorial. Master Infrastructure as Code automation and improve your cloud deployment workflow.

🔥 What You'll Learn:
✅ How to implement for_each loops in Terraform
✅ Creating dev, test, and prod servers with unique names
✅ Using toset() function for dynamic resource creation
✅ Best practices for Infrastructure as Code
✅ AWS EC2 automation techniques

About Energetic Technologies:
Expert DevOps tutorials and cloud automation guides. Subscribe for weekly Terraform, AWS, and Infrastructure as Code content!

Follow us: @nareshitech

#Terraform #DevOps #AWS #InfrastructureAsCode #CloudAutomation

Category

📚
Learning
Transcript
00:00Hello guys, welcome to Narisha Technologies.
00:02My name is Raham Sheikh and in today's video,
00:04I am going to talk about for each loop in Terraform.
00:07Let's say you want to create three different servers.
00:10But all of the three different servers need to have different kind of names.
00:14Let's say server number one will be dev,
00:16server number two will be test,
00:18and server number three will be prod.
00:19With the help of the account,
00:21we cannot create the server with different names.
00:23But we can use for each loop in order to make
00:26server's name with different different names.
00:28So you can go and see,
00:29I am taking for each loop.
00:31And in order to get the values,
00:32I am using two set function.
00:34It's a function and I am defining three different values.
00:37Dev, test and prod server.
00:39So I can see my AMI,
00:41instance type as same.
00:42But when it comes to name each dot key,
00:44what is the first key here?
00:45Dev server.
00:46So once dev server got created,
00:48again the loop will repeat.
00:50Again, I will get second value as test server,
00:52same AMI, same instance type.
00:55Again loop will repeat.
00:56Same AMI, same instance type,
00:57but the third one is going to be prod server.
00:59Like that we can create a different,
01:01different server names with the help of for each.
Comments

Recommended