Master Classs: Terraform for AWS (Beginner to Pro) | Hashtag Learning | Skillshare

Playback Speed


  • 0.5x
  • 1x (Normal)
  • 1.25x
  • 1.5x
  • 2x

Master Classs: Terraform for AWS (Beginner to Pro)

teacher avatar Hashtag Learning

Watch this class and thousands more

Get unlimited access to every class
Taught by industry leaders & working professionals
Topics include illustration, design, photography, and more

Watch this class and thousands more

Get unlimited access to every class
Taught by industry leaders & working professionals
Topics include illustration, design, photography, and more

Lessons in This Class

32 Lessons (5h 46m)
    • 1. 1 0 CoursePromo

      5:26
    • 2. 1.1 What is Terraform?

      6:48
    • 3. 1.2 What & Why Infrastructure as Code

      8:03
    • 4. 1.3 Course Requirements

      1:38
    • 5. 1.4 Installing Terraform

      4:34
    • 6. 1.5 Setting up AWS CLI

      10:55
    • 7. 2.1 Section Introduction

      2:21
    • 8. 2.2 Terraform Helloworld & Essential Commands

      6:55
    • 9. 2.3 Terraform Statefiles

      6:21
    • 10. 2.4 Terraform Provider & AWS Access

      12:14
    • 11. 2.5 Terraform Variables

      18:17
    • 12. 2.6 Terraform Inputs & Outputs

      6:28
    • 13. 3.1 Section Introduction

      1:24
    • 14. 3.2 S3 Using Terraform

      22:48
    • 15. 3.3 Launch EC2 Instance using Terraform

      25:41
    • 16. 3.4 Section Conclusion

      3:00
    • 17. 4 1 What is Terraform Modules

      2:50
    • 18. 4 2 Terraform First Module

      10:38
    • 19. 4 3 Terraform Second Module

      15:28
    • 20. 4 4 Terraform Reuse Module

      7:56
    • 21. 4 5 Terraform Multiple Environements Problem

      5:01
    • 22. 4 6 Terraform Workspaces

      14:29
    • 23. 4 7 EnvironmentSpecific local variables

      8:20
    • 24. 4 8 Env specific Shared Vars Acrossmodules

      19:17
    • 25. 4 9 section conclusion

      2:29
    • 26. 5 1 ProjectIntro

      4:28
    • 27. 5 2 ProjectSetup SG Setup

      23:40
    • 28. 5 3 ALB TG Listener Setup

      29:31
    • 29. 5 4 launch configuration

      21:43
    • 30. 5 5 Autoscaling Group

      28:54
    • 31. 5 6 Production workspace

      7:04
    • 32. 6 1 Course Conclustion

      1:20
  • --
  • Beginner level
  • Intermediate level
  • Advanced level
  • All levels
  • Beg/Int level
  • Int/Adv level

Community Generated

The level is determined by a majority opinion of students who have reviewed this class. The teacher's recommendation is shown until at least 5 student responses are collected.

566

Students

--

Projects

About This Class

Why this course ?

In current Cloud Industry, Terraform is considered as one of the leaders for Infrastructure as a code platform. With its flexibility and compatibility with many different cloud providers like (AWS, Azure, GoogleCloud, Digital Ocean and many others), Terraform makes it Very easy to manage the workloads that are provisioned in different cloud providers at one place.

Having the skills to write and maintain the infrastructure using Terraform gives an edge to a cloud practitioner's profile.

In this course I have covered a lot of ground on Terraform which will help all levels of students (Beginner to pro) to get a good understanding and practical implementation.

This course is structured in an Hands On way and students who practice along with the lessons will get the most out of it.

Course Structure

Introduction Section:

  1. What is Terraform ?

  2. What & Why Infrastructure as a code ?

  3. Course Requirements

  4. Installing Terraform

  5. Setup AWS CLI

Terraform Basics:

  1. First Terraform File

  2. What is state file and its importance

  3. Different ways to give access to tf

  4. Terraform Variables and its uses

  5. Terraform input variables

  6. Terraform output variables

Basic AWS Components:

  1. Introduction

  2. Create S3 bucket and upload files

  3. Launch new EC2 instance

  4. Next steps

Advanced Terraform Concepts:

  1. Terraform Modules & Why we need them ?

  2. First Terraform Module

  3. Providing Inputs to the Module

  4. Module Reuse with different Inputs

  5. Multiple Environments Problem

  6. Terraform Workspaces

  7. Environment Specific Local Variables

  8. Shared Vars for different Environments

  9. Conclusion

AWS Project:

  1. Project Introduction

  2. Project Setup & Security Groups

  3. Setup ALB and Target Groups

  4. Setup Launch Configurations

  5. Setup Autoscaling & Launching EC2 instances

  6. Provision Multiple Environments(staging/production)

Meet Your Teacher


 My name is Sai Kiran Rathan and I am currently working   as  an AWS System Administrator and Solutions Architect   for a software company in New Jersey. 

I hold AWS Certified Solutions Architect Associate & Professional,  AWS Certified Developer Associate, AWS Certified Sysops Administrator Certifications.
I am a huge cloud fan and i love to share everything i know about cloud.
My courses not only teach you about all the services that are offered in the cloud but also teach you how it is implemented in the real world scenarios.

See full profile

Class Ratings

Expectations Met?
  • Exceeded!
    0%
  • Yes
    0%
  • Somewhat
    0%
  • Not really
    0%
Reviews Archive

In October 2018, we updated our review system to improve the way we collect feedback. Below are the reviews written before that update.

Why Join Skillshare?

Take award-winning Skillshare Original Classes

Each class has short lessons, hands-on projects

Your membership supports Skillshare teachers

Learn From Anywhere

Take classes on the go with the Skillshare app. Stream or download to watch on the plane, the subway, or wherever you learn best.

Transcripts

1. 1 0 CoursePromo: Hello and welcome to hashtag learning courses. My name is Sai and this is the telephone masterclass for AWS Beginner to pro Now, first of all, I want to thank you all for taking your time toe. Check this course out and I want to begin by giving a brief introduction about myself. And then I will go on and walk you through what this course offers and what you'll get by the end of this course. Now I like I said, I'm science and I'm a cloud solutions architect. And I've bean are detecting in the cloud for a long time now. And I am an AWS certified professional and I hold all the 58 of your certifications. And, um, let's begin by discussing about water for Mrs and why you need toe learn terra form as a cloud practitioner. Right? So terra form is one off the very critical skills because it is a platform for you to off right your infrastructure as code and easily manage. And one main important advantage off the reform is that it is cross platform and you can have several cloud providers integrated into your single code, meaning if you have multiple workloads which are provisioned and multiple cloud providers. Then terra form is one way for you to unified them all and bring it in 100 1 particular script or one particular project. And you can save them all in in your source control and use it to manage your infrastructure. Now, why should you take this course? Because I have put in a lot off information in this course which I have gathered in my journey off cloud architect ing. And I thought you all the skills that are really important and some of them you even might have not found it in the in the Internet by searching it because I've found few days off using things in terra form which are really useful when you're having multi environment workloads. So I've put in all those information in this. Now, let me give you a brief introduction off like what this course curriculum would look like. So we'll start off by giving a basic introduction off what terra form is. I'm going to walk you through how to install terra form, how toe, uh, create your project structure. And like what other different components that go along when you create a telephone project . Once we go through that, then we go ahead and create some of the basic things like variables and inputs and outputs . Once we finished that part, we'll go ahead and provisions some off. The AWS resource is right. So we experimented with s tree and easy to And once we get hold off how you work with the AWS provider and how you can create some of the resources, we'll go ahead and learn the some off the advanced topics off the telephone. Like more jewels and workspaces. I will show you their how toe create variables which are specific toe environment across different work spaces. And I will also teach you how to use shared variables concept across multiple models that you can leverage in your infrastructure. Then, um, once we cover all those basic advanced topics in there, I will go ahead and teach you how to create a two tier application in AWS, and that would be a complete project off creating multiple environments creating, um, security groups. Launch configurations are scaling group lord balance or center on and so forth it is have have covered most of the stuff in a hands on way. So if you guys follow along with me, when When I'm when I'm going through different parts off the course, you really benefit from practicing it along with me and this this particular knowledge off terra form and how to do things in the cloud will really take your career to the next level . Because in every interviewer in every company that you go, the first thing they check if you are a cloud practitioner is like how you're managing your infrastructure as a cold. And when you say that you know, telephone, then you really have edge in getting that job. Are If you're already in a cloud practicing job than it, it will really take your carrier to a next level because it will really help you. How help you to manage your infrastructure in l very, very efficient way than just going ahead and provisioning things manually. So I'm really looking forward for you tojoin my course, and I will, um, I will be here to help you out with any questions that you might have. And I really do think that you will not face your money your time by going through this course. So I'm really hoping that you'll continue and come along and join the course. And I will see you there. Thank you so much for watching. 2. 1.1 What is Terraform?: Hello and welcome back to another lesson off hash tag learning courses. And in this lesson, we're going to see what Esther form. Now, I know that off. You are here for terra form because this entire courses designed around terra form and I felt like I need to give a little but off introduction off water for miss and give you a walk through off like who developed it. What is a website? How does it look like? And, uh, what do we get out off it. And how are we going to use it to build our infrastructure? Now, once we get a quick introduction off Ward, this is And like, um, the quick walk through off the website were going toe like, Go in depth off. Like, what is infrastructures accord? And, um what exactly? I mean, the cow to install terra form, like how to set up your aws and so on and so forth. So if you're if you already know what performance, you can just get this lesson. This is for someone who really don't know anything about our farm. We're just going to get a start from, like, absolutely taking a perspective off the student knowing nothing about terra form. So, um, so that said we will get started. So first thing is, terra form is infrastructure asset cord tool. Meaning you were going toe script. Your entire infrastructure That is going to be your maybe your AWS resources. Or it could be, um, any objects that you want to put in s three or or anything that is related to your infrastructure that you're going toe, specify it in a form off a terror farm script, and you're going to save it in a washing. Control are wherever you want. Toe. Put it in a secure place. Now, in the next lesson, I'm going to show you like I'm going to tell you what Waters infrastructures accord and like what exactly? You get off it. But in this lesson, let's just go and take a quick look at the website itself and see what their farmers. Okay, so this is how their form website looks like. It is basically the doctor from that, are you and ah, Terra form is a open source tool. So basically it is free for you to use and it is developed by hash card. No hash carp is a kind of a very good community contributor in terms off any clouding cloud , any tools that are like used in cloud applications, you can check out like the other tools which hashing carp offers their tools, like Reagan, their tools like Packer, which are used for different purposes. Now, terra form is basically infrastructure as a court platform, which, um which is almost basically you to write, plan and create infrastructure as a court. Now, Well, why do we need terra form like you could you could argue, saying that AWS provides cloud formation, right? So cloud formation is another infrastructure as it court to. Now, if you're hosted completely native, Yes, you kind of get a question like Why do I need to use Terra form? Like, Why? Why not cloud formation now to answer that cloud formation is basically you're tying yourself into AWS, and whatever form does this, it gives you an opportunity toe kind off, have your infrastructure open toe a multi cloud thing, and you can always have like I mean, you can have always have the same terra form court. And if they had more components from other cloud providers like Let's say you have the sources, like easy to instances or whatever from AWS, and you want to use some other cloud services like, um, as your or any other cloud provider. So basically, you can have everything set up in one place, and you can use the same tools toe kind of organize your entire infrastructure so that it's one off the, um, benefits off using their form. It is cross cloud platforms, and it's kind of easy to use. Now. You must be wondering, like, what is the language that I'm going to use to write this Terra form script? It is basically, um, head seal. It is called hash carp language, and it's it's kind off mawr off a declarative language where you're going to specify, Okay, I need a W s easy to instance with these in these properties. It is quite simple. Ended this, like any programmer, are like even I would say, like even if there is no past programming experience, you could easily get around and get hold off this writing inter form script, and I'm going to walk you through the different different steps that that will be our I'll be walking you through, like all the different competent off this terra forming scripting. And I'm going to show you exactly like, what is the best way to do it? I have used Terra form in all my experience. And then I figured out a lot of these which are which are actually not documented. And I've kind of have techniques around like workarounds for situations which are not natively supported by terra form. Like using variables like in a different. They have experimented a lot in terra form, and I'm going to show you a lot of things. So, uh, this is a quick introduction off whatever. Form it. So now, um, we can't stop our lesson here. You I just allow you to go ahead and visit the website, check out the documentation, or like whatever the guys that you want to see. You can read through all of these. I don't need to like this. Read through our, like, explain. Warded does so basically like a set of home is an infrastructure, as it's called tool. And it gives us a lot off, um, out of options. Oh, and you can use the same tool for different cloud service providers and so on and so forth . Now I'm going to stop this lesson here, and we in the next lesson off Will, Will, Will Seymour about her farm and infrastructure as a cord. So thank you for watching. And I will see you in the next one. 3. 1.2 What & Why Infrastructure as Code: hello and welcome back to another lesson off hashtag lending courses. And in this lesson, we're going to see what is infrastructures accord and why do we need it? So in the previous lesson, we have taken a quick look at what performers and we have seen, like whoever perform and like how the website looks like and off. What language do we need to learn for this? And and a brief introduction now in this lesson, let's take a step back and let's analyze, like, why did hash carp even develop him to like terra form? What is the problem that they're trying to solve now? If you think off it, the problem here is basically let's say you have a cloud infrastructure you have. Let's a let's talk about AWS now most off, you know, like some off the AWS Resources like Lord balancers are easy to instance are are the scaling groups or s three buckets any off that? So what you usually do it's like you go to your console. You open it up, You you go. You walk through the, uh, different visits to kind of create your resources. Like Lord balancers are easy to instance underwater Where this and let's say if you're doing a simple task, that is fine. But if you are actually working on an enterprise application, are you are. If you are like building a huge infrastructure for your company, then you need to keep track off each and every resource that you create, and you need to know exactly how you created it. And, uh, it is nearly impossible for anyone to remember why they have created a particular resource . And what is the reason for it? If you ask them, like six months later, when they often they're like, moved on to some other project and then they go back and try to think, Why did I even create this like who changed this? That's another thing. Let's say multiple people are managing your infrastructure and you go back and see. This is not what I've configured of the security group. I've never opened the sport who opened the sport. Can you go back and check and can go back and track and easily? Can you go back and fix it like do you even remember what it waas? So these are the problems that that a typical adminstrator or a typical AWS guy or any clouds guy will face in his dignity. Job operations now using telephone like normally terra form any other infrastructure as accord basically here what? We're trying to solve this. Trying to keep track off what resources were creating, who created what and now when you have infrastructure as accord. Now let's say script saying that, Okay, I need a load balancer. I need any Zito and I need a security group. And here are the rules that I'm going to put in this security group now all those rules that you've specifying the security group and you run that script. Your resources are created in your cloud environment. And once they're created, what you're do is like you're just check those changes in in tow, any version control, like git or subversion. Now, once you do that, what you're doing is basically keeping track off saying that OK, so they have created these particular resource is in my cloud, and this is the reason that I've created it. You log it in your comment message or you can even throw in some comments in your terra form or like any infrastructure as a code or document and, uh, later, if you like, go back like, come back to it after six months, then you know exactly why something was, um, Prohibition. Innocent in a way. So that is the main problem that we're trying to solve. So we want to document what we're creating. We want to know why we're creating and we want to keep track off who created stuff. And not only that, no, let's talk about handling multiple environment in your infrastructure. Let's say you're working for the enterprise company. Typically, they have, like death stack U. S stock and production stack. Now let's say you have created a stack for a specific application, and it needs, like Lord balance or orders killing group security groups. What? Not right. So you go ahead and create it for death Stack. Now let's say once they've stack is all done. Everything everybody liked your obligation are are your infrastructure stack and they want to promote it pre prod or like Q A or production. Are you going to go and like run? I mean, are you going to go ahead and create all the stuff that we have created manually in a different environment. How much time your spending their tryingto recollect and it is not even guaranteed that you're going to create the same infrastructure that you have created there. This is There were so many little things that you might actually miss when you're configuring the cloud infrastructure. So this infrastructure as accord also solved this problem. Because now what you're trying to do is like, basically, you're saying you change that in para matters in your own accord, which is like pointing to different security groups are different creating with a different name or something like that. And basically you're running the same infrastructure. I mean same court that you have used in depth and you're replicating it in Cuba and production. Now you're saving time. You're making sure your infrastructure IHS like same across different environment, which is really essential, Right? So if you're testing so certain security issue and your devils different from Q is different from production, then how are you going to figure out if there is, say, issue which is in production, and if you see no issue endeavor Q A. So these are the kind of problems that we're trying to solve using infrastructure as a court. So now that we know, like what and why Infrastructure as accord. Now let's talk about like Why do you stare? For now, Terra form is a amazing tool and it is loved by all the guys that are working in the cloud . And I personally love it and I have been using for more than two years now. I used literally terra form for every AWS operations that I make for, for for publishing, any resource is in aws Oh, and basically one off. The main reasons why people choose terra form is that it is a cross platform. Now let's say you have an infrastructure which is scaling across different clouds, multi cloud infrastructure or hybrid cloud things like that. So Terra form supports many different cloud providers, and you can have all off them scripted under the same terra form file. You can target different cloud platforms, and it is easy to manage easy to learn, easy to kind of maintained, and there are different strategies that I'm going to discuss in in the coming lessons, like have having the remote state files. I mean, I'll get to that special fix off like bandages off terra form as as and when we come to those topics along the course. So I really hope that you got a good understanding off like, what is Infrastructures Accord and why we actually need this. I'm going to stop this lesson here and in the next lessons, we're going to continue more on Terra form the installation in the set apart. So that's it for this lesson. And thank you so much for watching. 4. 1.3 Course Requirements: hello and welcome back to hash tag learning courses. And in this lesson, we're goingto take a look at all the requirements for this course and ah, let's get started. So the first thing that we need is, of course, we need our terra form software to be installed. And once we have to reform software installed, we need a AWS account. I mean, like, we're basically in this course we're covering a lot off AWS things and are kind off. Do the examples that I'm showing you here you would need an AWS account and you need to set up AWS credentials by creating a user. And you need to set those credentials in your local system and, uh, um, for editing the court itself. You need a coordinator. It could be a visual studio. Or it could be nor pad plus place are it could be a sublime words. Sublime editor. That's that's up to you. Whatever the corner there, you want to use it. It's fine. And then last, but not the least you need in the west off your choice, Which is which could be Mac Windows, Lennox, wherever the system that you choose to so that's pretty much about it. And in the next lessons, we're going to go ahead and, uh, install or the required software and, uh, make our system ready so that we can go ahead and do some cool stuff using the terra form. That's it for less this lesson. Thank you for watching and Elsie in the next one. 5. 1.4 Installing Terraform: Hello and welcome back to hash tag learning courses. And in this lesson, we're going toe install terra form for our course and, ah, let's get started. So the first thing that you would do is basically going toe your web browser and, um Justine www dot terra form dot io and you'll be landing onto this site now all you got to do is go to the downloads section here and then select the west that you are currently working on. Now, basically, this is not installer like a typical Mac or Windows installer. It is just a zip file that you're gonna download and you gotta configure your part variable still kind off, figure out like what that a farm resolves to, and that's pretty much it. So let's do this for Windows. And it is pretty much similar in all the other operating systems as well. So let's go ahead and download it for Window 64 bit. I'm currently working on 64 bit. I'm going to create a new folder here saying that terra form latest and inside this I am going toe. I'm just copy this part and then I'm going to save it. here. So one studies downloaded and saved. The next thing that we're going to do is go to that folder and extract that file. So once we have that extracted, now you can see that we just have the Terra formed or e x c here. Oh, and this is already like a it's ready to use. And you won't need to install anything here like I said previously. So all you gotta do is like, configure your part to point to this. Now, let me open up my power shell and let's see if I've have terra form already set up and let's see. Ah, So what folder My terra form is currently pointing to, uh, we can say get to come and form. Okay. So you can see that currently, my terra form part is being pointed toe C program files Terra form and terra form dot e x c . So this is where I put my terra form file. Um, now I can change that by saying that in my part, variables Aiken, goto my, uh, it system, environment variables and I can say environment variables, and I can check for my pot and inside this Ah, you can see that this is my order from. But now I can, uh, did this. And I can say this is my new telephone pot. And then click. OK, In your case, there wouldn't be an entry here. So we all your do is basically select the new and, uh, give the folder pathway over your turf form dirty, etc. Is present, and you'll just hit, OK, and then Okay. So once you're done with that, now this. Now we have to restart this parcel because it won't pick up the changes. Um, right away way have toe, reopen the partial. And once we re open now, if you do get command Terra form, it should actually show us the new part, which is our documents. Ah, terra form, which is whatever the part that we have here. So now the terra form is basically set up in our no system. Now, let's just do a test command off like terra form version. So yeah, so you got back to terra form version, which means, like your terror for miss properly set up. So that's pretty much it for this lesson. And I hope you liked it and, uh if you have any questions you can always get to me like by messaging in the channel are like personal messaging through through the course. Andi, I'll get back to your questions. So that's it for this lesson, and I will see in the next ones. Thanks for watching. 6. 1.5 Setting up AWS CLI: Hello and welcome back to hashtag landing courses. And today, in this lesson, we're going to see how toe do it'll be a seal I set up. Now they're a couple of things. So first thing that you're going to do is basically download the AWS Eli from Amazon site and you're going to install the program. And once you're done installing that program, you're going to go back to your AWS console. Um, like I said in my earlier videos, for this course, you would need a AWS account eso that Ah, you can create your user. You can download your access keys and secret access keys, and also you can follow along the lab so that you can create the resources which I am creating now. Ah, So, like I said, we're going to download the AWS Eli, first install it, then we're going to go back to AWS console, create user if you don't have already, if you already have a user, then we can just go to the user, created the im Ah, credentials, thesis, acuity, access key and secret access key. And we're going to configure it has a profile using your head of your Seelye, Because for using it Ah, for forgiving terra form the access to go ahead and create resources or delete resources or whatever you want to do. Your terra form needs to be authenticated with, Ah, the AWS system. So ah, creating a profile using CLI is one off the ways in doing it. And you can also give your access keys and secret access keys directly to your terra form, which is not a good practice. But I'm still going to show you the different approaches that you can take toe. Give access to your AWS system from your telephone. So let's get started. So the first thing that will do is down or d a wc like so to do that first, just go to any browser and just type down. Lord, have you see live already searched for it. I think the last time eso basically can just go to any first link that you see. Ah, if you're using alien X version, you can you can follow the instructions here. Now I'm going to show you how to install for a windows, so I'm just going toe select the one install AWS Eli on windows and there is an M Asai installer. If you want to choose another part, you can choose. I'm just going to download the installer, which is a lot more easy to work with. So I'm just going to download in this folder. We copy the pot so that I can go there, so I don't need the Seelye wants to see allies downloaded. What I'm going to do is open it so I'm just waiting till the download complete? Yep. So it is known ordered here. So all you got to do, it's like, ah, double click it and then select next, accept the license next and then installed. Uh, just give it a couple of minutes, and it should be done. And Okay, so the aws eli set up this complete. Now, we can open up a power shell or command prompt whatever you prefer. And you can just do, uh, get command hated. Yes. In lieu Mexican do which aws in partial you can do get command aws, and you can see the it is resolving to something. So we know AWS see allies installed. You can do AWS health and it's going to show you a bunch of different options that you can use with the Seelye and Ah, well, let's not go deep into this because this is not, ah, the topic that we're going to discuss here. But, um, that's want to the next step. So the next step that we have is to go to AWS, Eli. I mean, AWS console and create a user. And if you already have a user, you're going to go ahead and create access keys and ticket access keys. Now, I already have a user. Eso I'm just going to go ahead and create new access, key and tickle access key in your case if you don't. Ah, it's always best practice to create a user and use it instead off using a root account. So I would suggest you toe use a, um, use a I am user instant off the truth account. So I already have the user. So I'm just going to go to my I am console here, search for it. And once you're here, all you got to do is go to your users, select search for your user, and inside that user, you're going to go to the security credential. Step no. Inside the stab you should see Ah, part here now. I already have a access key and secret access key theater. In your case, you wouldn't see anything if you're new to this. If you already have access key and Secret Access key, you can completely skipped the step and use the ones which you have already. And ah, even though I have it here, I'm just going to create a new one for this lessons purpose so that I can go ahead and do it after this lesson. And ah, you guys can even though if it is visible, you technically have no access. So, um, let me just copy these in tow. The my I copied in a note pad just for now, because one thing to remember, it's like you can only see the secret access key once, and you have to copy it or download the CSE file here. Uh, and you can always see that get the access key from logging into do your I am council, and you should be. It should be visible, but secret access key. Make sure no one gets hold off it because they can technically do anything that that your user has access to. So just be careful with er. Do not share it with anyone and save it in a secure place. All right, so the next thing that you're going to do is now that we have this Ah, the next thing that you have to make sure it's like you have appropriate permissions snow. For this examples that I'm going to choose. I just gave my user the administrator access just so that you know, I can do anything that I want with dark access keys. Now, if you are touching a few resources which your which you don't have permission toe if you want toe experimented with, just give access to yourself temporarily. And once you're done with the lessons, you can just get your offered. All right, so now that we have our AWS access key sensical access keys, now let's plug them into our AWS Eli and create a profile. So to do that, the first thing that you were going to do is aws ah, profile. And you have to give the profiling name so that you can use that profile name in your telephone script. So I'm just going to say aws profile. Ah, dust, Ash profile and have to give it a name. So I'm just going to say a Stratton Dash data form, of course. All right. And, uh, once they go into this Oh, my bad. So you have to do AWS configure, configure, dash, dash profile and Xstrata national reform courses. Mind profiling. You can give it whatever you want. So once you do that, it's going to ask you for the access key and, uh, dusky and the access key that you have created earlier and the secret access key goes in here. Okay, Now you can choose the default region. I'm going toe for this course. I'm going to use you Best one. Ah, you can choose whatever the region called that you would like to use. Ah, it's completely up to. It's just setting a default region, meaning if you don't specify a region in your AWS comment, you're going to end up using this particular region. So it really doesn't matter if you're specifying it anyways. But it's always handy when you have the default region said so that you don't have to supplied every time you run a specific it of this command All right. So I'm going to choose the you vest one here. And once it is done, you can choose the default output format, whatever the default is, and we're pretty much done. So let's go ahead and see or test Like what, exactly? I mean, if this if this particular profile configuration worked or not, and do the AWS help again? I think everything should be fixed. Yes. So, no, let's try to run. I am. Ah, let's I just want to see if my configuration worked or not. So I just I'm trying to retrieve the users from here, So retrieve users is like, uh, I want to use list list users. Yeah, I can choose this. Lets users can come out off this command. Klier aws I am list users. Oh, I have toe supply the profile, right. We have created a profile for it. So profile, um, Hazrat on dash, uh, uniform course. And like Like I said, you can see all the users that are there in my account, and ah, this confirms that we have our aws eli set up properly. Okay, so that's it for this lesson. It's bean really long lesson and um we have successfully installed our AWS alive. We have created our AWS I am user. We have created our access key secret access keys And then we have configured in our aws Eli a za profile with a profile name set. And then we have tested that our set of books. So that's pretty much it for this lesson. And I will see in the next lessons. Thank you so much for watching. 7. 2.1 Section Introduction: Hello and welcome back. So this is another lesson from hashtag landing courses and ah, in this lesson, we're going to give a quick introduction to what we're going to cover in this particular section off terra form basics. And we're going to cover the first part off the start from basic scores. So let me just walk you through the, um, different lessons that we're going to cover in this particular section. So we're going to start off by creating our first uniform file and ah, we're going toe initialize our telephone file and I'm just going to show you what is the extension and what are the file studied create? And once we're done with that, we're going toe talk about the state file, and it's important. Ah, missing the state file is something which gets created when you run your stuff. It keeps track off the resources that you've created. Ah, In the third lesson, we're going toe cover like, how are we going to give access to our eight of your system? Like, how do we supply credentials, toe? Um, our terra form file And what are the different ways to do it in the next thing that we're going to cover is the most important one, which is the terra form variables. Now you're going to play around a large off. I mean, you're going to use the variables a lot in your in your in your infrastructure building because I mean, like, it's one of the core competence that you need to learn in terra form. And ah, second thing is, the next thing would be their form input variables like, how are you going to give input to your particular terra form script from external command line? And the next important thing is like, How are you going? Toe output specific variable if you are. If you have created something, If you have created a resource, how are you going? Toe output a specific value so that you can use in Ah, in some other case are like if you want to view it as an output in your in your council itself. So these are the pretty much basics that we're going to cover in this particular section. And, um, I'm just going to quickly stop this. Listen and I'll create. I mean, I'll start a new ah lesson just in a bit. And then we will cover the first uniform file there. So that's it for this lesson. Thank you for watching. And I hope you enjoy this particular part off the scores. 8. 2.2 Terraform Helloworld & Essential Commands: Hello and welcome back to another lesson in hashtag landing courses. And, um, in this lesson, we're going to go ahead and create our first telephone file and ah, let's get started. So first thing, what you have to do is you have to create a folder or a directory, depending on, like, no. Which operating system you're choosing? Um, I'm in my course folder, and I'm going to just create a new folder saying First tear a farm file and inside this folder, I'm going to create a new file. So the extension that you're going to use is dot the F. So I'm going to create a new file, which is going to be it, so I can just call it Hello word RTF now. Hello. World really doesn't make any sense in this particular piece off example. But it is a way off learning anything new in computer world. So I'm just going to use hello world as the name. So I'm using hell award dot TF as my, um what do you call this terra form file? So inside, Once you have this, all you have to do it's like open up your command, prompt or power shell. And inside this, whenever you create a new telephone file or you want to run anything you have tow initialized this particular telephone fight to do that, you have the command off that'll form in it. So this is the first thing that you have to do whenever you're creating a uniform file. So once you do it in it, you can see that there are former successfully initialized. So basically, what this does is lets say, right now you don't have anything in your terra form supplied. But if you have anything like, let's say in the next lessons will be doing this anyway. So what we're going to do, it's like we're going to still like Okay, I'm going to use AWS as my provider and, ah, I'm going to include some module or I'm going to include this particular file or that particular file, whatever it is. So in order for terra form toe like ah, like, get that information saying that, Okay, I'm going to use this pretty waiting for that particular in for before I run anything. This initialization step will go ahead and figure out those details and it will kind off download the dependencies are add. The dependence is that this particular terra form file eat. Now, In our case, this is a very blank terra form file and it doesn't have any information in there. So that's why it's just saying like, OK, their former successfully initialized and it doesn't have anything in there. So So this is our basically blacked out a farm file, and we have initialized it. Now there are some of the some of the important commands that you're going toe run in this particular course are terra form plan. Now, telephone plan is something like a dry run off your off your script, saying that when you run this terra form planets going to actually check Ward, all it is going to create and it's going to list out the things that it will create saying that. Okay, let's say you have listed out, then the sources that you want to create in your telephone file and Iran Terra form plan. It is going to show you by verifying with the console AWS console or like whichever cloud provider that you're using and it will tell us like, Okay, I'm going to create so into resource, and I'm going to delete. So in so resource and I'm going to update, so interest soars. So those are the kind off Brighton information that it's going to provide, and it is always the best practice to run terra form plan. Before you said anything before you apply those changes because you have to know, um, what changes you're making. And you should be sure that, uh, if before you delete something or before you operate something so that you don't mess up the current state off your infrastructure, so that is for telephone plan is going to help you with. So we're Esther. A farm plan. So right now, you can see that there is no infrastructure change and infrastructure is up to date. Um, and there's no changes that not going to get applied. The second thing is uniform a play. Now when you do there from apply all it is going to do, it's like it's going to check. Is there anything toe apply? It's going toe again. Do a plan, ah thing. And then it's going to list to you all the resources that it is going to touch, whether it's going to create whether it's going to delete or whether it's going to update stuff so you can see terra form apply. There's nothing in this file again, so that's why there's there's nothing you'll see here, and the third important command is terra form. Destroy No, a terror farm Destroy is a is a really scary comment because it is going toe nail down the infrastructure that you have specified in the state of farm file. So it is. It is like basically deleting everything that you have created using this particular telephone file. So before running this, you have to be always careful about, um, running this command as it's really scary to take down the entire infrastructure. So whenever you run this command, Terra Form is going to ask you for a confirmation. It is also going to ask you for a telephone, apply conformation. Right now, we don't have any resources. That's why he didn't ask for apply. But for destroy. It is always going to ask you for a confirmation whether you really want to run this command or not. So I'm going to say yes and it is going to destroy whatever it is there, so really These are the most important commands that you're going toe work with initially. And, ah, in the advanced lesson, I'm going to show you more commands. But for now, you have to just remember three commands, which is telephone plan. Oh, I'm I'm sorry. You have to remember four comets with this terra form in it there. Form plant, terra form apply, and terra form destroyed. So these are the only four commands that you need to by heart. And, uh, that's pretty much it for your first terra form file. And in the next lesson, let's go ahead and talk about their from state files and their farm. Yeah, basically there from state violence. What is it and why is it so important? All right, so that's it for this lesson. And I will see in the next one. Thank you for watching 9. 2.3 Terraform Statefiles: Hello and welcome back to another lesson in hashtag lending courses. So in this lesson, we're going toe continue from where we left off in the previous lesson. So in the previous lesson, um, to give you a quick recap, we have created our test. Ah, first uniform files with Saleh World rtf. And then we learned her a few commands, which is there for minute there from planter from applying there from destroyed. Now, Um, now you Once you have written something in your terra form file and you have run something like the reform plan Terra form apply. You are going to create some resources, right? Like of if you Let's say, if you have created an E C two instance are you have created a load balancer you have created You have uploaded industry filed something like that. When you do something like that, there should be somewhere. Um I mean, terra form should record that information somewhere and keep it right. I mean, it should keep track off what resources created and like, one of the ideas that that that got written from AWS and like those kind of information. So all those information are stored in a terra form state file, which is It has an extension off dot PF state. No, this t of state is really, really important because whenever you run the telephone plan, basically terra form uses this terra form state file and it basically compares your current state with, ah, the reform that you have currently specified in there. Not be a file. Meaning Let's say you have created an easy two instance early and you have run that as it there from plan and terra form Apply now what happened? This you have created that resource in the AWS system like you have a new easy to instance running there. Now you're terra form state file will have that information saying that. Okay, um, for this pretty little farm folder, we have created a easy to instance. And here the properties. Now, once you have that information in there you go in your telephone Dr file and you add a new resource saying that Okay, I also want a load balancer. No, technically, when you're running, you should go and create a least two instance as well as a load balancer. Right? But you don't want that to happen you want the Terra form to go ahead and check? I already had. Easy to instance. Now I need a load balance. So whatever form does this first it checks the state fight and it verifies if you're terra form state file is in sync with what you are there form filers. You'll have a mismatch there saying that. Okay, I had just had an easy to incidence. Now, I also have a load balancer. So I have to create a load balancer. So in your plan statement, it's going to tell you Oh, you already have a C two instance running. It also verifies, if that instituted instances still running or not. If Randy will try to create one Now that you're easy to instances already running, you need a new lord bands that it's going to say, Um, I want to create one resource. I want to modify no resources, Tyrone, to destroy no resources, that is one create zero destroys. You don't modify. So that's how you kind off create new resources and keep track off. Old resource is that you have already created. So that is why don t a file, but are not the DF state file, which is the state file is really important. And it is going toe keep track off all the resources that that you have created. So there are different ways to manage the start. State file. Naughty of state file. Ah one. It's like, um either having it checked in into your version controlling or you can have a remote state fire. Like whenever you run something your ST file gets updated in s three are or were there with the remote destination that you have chosen. Now, those are some of that. Once topics will come to its Ah, at the point. Once we are like very much comfortable with terra form. But let's focus on, like, their form state file. So whenever you apply something, you, you your dark TF state file is created. And, um, now, in the previous example, when we learned a bunch of comment, you can see here that there are few come a few files that are created oneness the estate and the estate dart back up. Now, the steve ST dot backup is something like you have run. You had a first run, and then you run a second time. You running third time. It's going to, like, have the most current information and daughter file and all the states that it was it had earlier, It will save it in the dark day off backup file. So this is not that much often important, Really. All you need to care about this start e of state files. So in this file, this is this is just going to be a Jason file, which, which has, like, Okay, this is my version three because I ran it three times, right? Um and then I have my telephone version, which is, um, telling like this is a worsen off terra form that I'm running. And, ah, currently, you don't have any output or more deals are your resources are dependencies, right? So all this information get Paul gets populated once you have some resources that are created in here. So that's why terra form state the estate file is really important. And in the next lessons, you're going to see when you create new resources how this terra form state fight is going to get populated. All right, so that's it for this lesson. And, uh, I will see you in the next lesson. We're goingto go ahead and configure our AWS, um, permissions in your telephone file so that you can start creating new resources. So I'll see you in the next one. Thank you. 10. 2.4 Terraform Provider & AWS Access: Hello and welcome back to one of the lesson with ah hashtag landing courses. And in this lesson, we're going to cover ah, different ways to give access to terra form to go ahead and, um, access. The AWS resource is using your credentials. So let's get started. So the first thing that we're going to do is like, we'll go back to our first hello world, ah dot Theophile that we've created in our previous lesson. And, uh, let me just clarify one thing if if you were having any questions in your previous, um example And if you're, like, kind of or burn don't worry at all about it because we are going toe do so many examples that you clearly understand by what I mean with terra form state files and, like water, the different comments. You'll just get used to it once you see like ah, sufficient number off examples. All right, so let's get back to this. So how are you going to give access to your AWS console to your telephone fight? So first you need to specify that. Okay, I'm going to use AWS as my provider, right? I mean, like I mentioned in the introduction classes. That terra form is a multi cloud of compatible infrastructure. As a court to meaning like you can, you can create resources or you can manage infrastructure in many clouds. Like it could be a sure it could be AWS. Or it could be any other provider which which terra form support. So the first thing that you need to do is basically still terra form that Okay, I am going to be using the AWS as my provider. So how do we specify that? Let's check it out. So first thing you need to do, it's like open up your hello world rtf. I'm going to open it up with my sublime Let me bring up my sublime and I'm going to open up this particular file here. All right, so in my Terra form file, what we need to do is basically we need to select our provider, right? So the provider you're going toe specify it by saying, Okay, I need a provider and you need to open this calibration close curly brace. And ah, you need to specify here aws because AWS is my provider, right? So provider provide a name which in court and then you're just going toe. Save it here. Now this provider would take inputs like access, key, secret access key or a profile name or region. Whatever the properties that you supplied, when you're setting up your AWS providing your see like lesson, those are the some of the properties that this is going to take. But for now, what we're going to do is we're just going to save this as it is just saying that. Okay, I'm going to use AWS provider and let's see what happens if we run Ah, uniform. If you run the terra form plant on, I mean terra form in it because we're adding a new provider. We have to re initialize it because it needs to add the provider details. Let's see what it's going to do. So we're going to do terra form in it, right? So first thing it did was it checked? Okay, this is a provider that he's going to use, and what it is saying is it's downloading the plug ins for that provider. So this plug in will have all the information off, like how the AWS is going to interact with this particular terra form file. It is going toe like use. This plug into kind of creative resource is like issue commands to a rate of your system. All right, so you can see that we have downloaded our provider plug in, which is AWS and it this off version 1.39 Now, telephone has active contribution contributors and get up. And, like, there are there. They're solving issues and box every single day. And they're like and they keep on updating the versions here, which is a good thing, because the more the contributors, the more the issues get solved. Right, So coming back to this. Okay, so now we have the AWS Ah, provider. Um, what do you call this? Blufgan is installed for this particular ah telephone file. Now, if you go back to your folder, you can see there is dot terra farm for low created, and within this, you can see that. Okay, I am using this particular ah telephone provider. And this it is going to use this particular executable toe. Execute the comments coming back to here. Now, let's open up the Terra form file uniform website itself, and I want to just quickly show you how the documentation looks like and how you can help yourself by going into the guides or the documentations to figure out stuff. Now we have created the provider block, and we want to see what properties this particular provider will be able to take. Now, if you if you want to check that, you have to go here and then go to Doc's and you can see providers. And like I said, terra form is a multi cloud thing. You can see that there are so many providers that terra form support now the one which we're interested in is basically AWS. Now, if you go here, you can see that these are the properties that it is going to stake in, and this is an example off it. So provider AWS and it's going to take access, key, Secret Access, key region and, um, you can create resources like Aws instance Web. We're going to come back to this particular part later, but all we're interested in this seeing how we can supply our credit chills. Like I said, there's like, multiple ways to supply. Ah, one way is toe supply the credentials directly saying that. Okay, this is taxes key. This is a secret access key The other way is ah, saying that. Okay, um, I have my profile in my shared credentials file. Um, I'm going to say Okay, this is my credentials file. And ah, this is the profile that I want to use now it you can if you If you're using just the default credential file and you have a profile set in there, you don't have to specify share the credential file. Now, in our example, we have used the default rate and she'll file so we don't have toe specify the path so that ah, and you can directly usedto profile. So that is how you're going to basically use T um, shared credit shall file or the profiler you've created and the other ways to use the assume roll, like if you're basically using STS was just session. I mean, it's a way to issue temporary credentials to a user, and those credentials usually expire after a certain ah, certain period of time. In those circumstances, you're going toe, specify the session, name and session, the role they are an extra for this course. We're not going to use that particular way off accessing date of this credentials. So let's go and try to weighs one s to, um run this with the with the access key and secret access key. And the other way is to use the shared credentials file. So let's go back to our, um, sublime. And then we'll just take We're going to save region. We're going to say region equal to us. You West one. And we're going to say access key equality. Oh, I think I have it. Open access key is this guy and secret key ISS this guy. Now I can go and do a terror farm. If I'm you can see that. Ah, the It has refreshed and there is no infrastructure change because you are not creating. You haven't created anything yet, but it gave us a It gave us no errors. That means that we have confiscated properly. So this is one way off supplying the credit chills and the other way is I can just comment this out. Ah, not sure why they come in Keystone working anyway, so we can just get it off thes two and we can say profile equal to, and we quickly double check so you can see Yeah, profile equal. Do one of the profile. So my profile is Esther on Dash Ted A farm? Uh, of course. So this is my profile name. And if I just go back and run that a form plan again, it's going toe run it and then it's not throwing any others, which means it has been configured properly. So now you have two options, right? You have either specifying the access key, secret access key and the other ways to specify profile. Now, which one do you need to choose? The answer is simple. Always choose to profile because it is always a good practice not to check in your seek access key and secret access key and also you when you when you're working as a team, there are multiple people who are actually modifying stuff to your infrastructure, right? In that case, you want to be able to track like who ran these particular, um, changes are who added this particular resources. And if you have a shared credit, chills and say OK, I'm just going to check in a credentials for terra form, and I'm just going to allow everyone in my team. Then if someone deletes something or if someone does anything bad to your infrastructure, how are you going to figure out who is the person that ran that particular script, right? So in order to do that, you need your profiles and every developer can have his own local profile set. And when he's ran some stuff, I mean, when he creates something in the AWS will record as saying that. Okay, so and so person has created toe into resource. So that's how you can keep track off who created the resources as less you can keep track off. I mean, you can keep your access key, sent secret access key in a secure in a secure place without sharing them or exposing them in your version controlling. So I hope you understood, like how to create a provider in terra form and supply your credentials. Do it so that you can go ahead and create the resources. So that's it for this lesson, and I am going to see you in the next one. Thank you for watching 11. 2.5 Terraform Variables: hello and welcome back to one of the lesson in hashtag landing courses. And in this lesson, we're going to look at terra form variables. Now, As you know, variables kind of play very important role in any programming language and similarly inter form. We do have support for variables, and let's look at the different types off variable stars of order here. Now the types off variables that are supported here are basically strength maps, lists and billions. Now these are like common types that you find in any programming languages. And let's look at the syntax off, how to use these variables and, like how toe kind of use. I mean, how do declare these variables and also how to consume these variables? So let's look at the 1st 1 which is the strengths Now. Strength is kind off a commonly used variable because you can declare stuff like, Oh, you're name off the specific resource, our name off vpc or idea of VPC or or anything anything that relates to your infrastructure . You can declare it as a string, and then you can consume it. A zey. You can continue it as a variable within within any terra form blocks that you would like to oh, create our utilize. So let's go ahead and write some court and test it out to see whether that works out or not . So I'm going to open up my same file, which worse, which was used earlier in the years. Example. Which is my hello world rtf now within this hello world rtf. What I'm going to do is I'm going toe type in the court that we see on the street on the screen. So let's declare some strength. Now I'm going toe commenting that Is this a string available? Okay, now to declare a variable that this it is really simple. All you got to say, it's like I'm declaring a variable. It's variable and followed by a key. So KIIS, like the name off the variable with which you would be suffering within your uniform script . Now I can say my first strength, and I should open a curly brace. Close curly brace inside that you have to declare the type type is strength. Now, if you don't specify a type and if you just specify the default value, it will automatically assume that it is a strength. If it is a string and kind off in a kind of flick, self evaluates to a string, but it is always a good practice toe. Specify what type of variable it is. Eso Well, we're gonna say type equal to string. And inside this we're going to say default equal to and one of the value that you want to give saying that this is my first strength. So that's how you declare strength now how to consume mystery. So let's talk about I'm just going to put in the output variable here. Ah, my first output. I'm going to explain you when and why We need output variables in the next lesson. But for now, just, uh, just look at it as like, Okay, this is how you're going. Toe output. Uh, I'm going to explain why and when we'll be using the output variables, so just ignore it for this lesson. So I'm just going to say value equal to now. Here's the important part. So this is the reason why I'm using here. I'm showing you how to consume this particular variable within any block, so I'm just condemning it here in output so that I can show you the output that that's strangers consumed. So do use any very well. You need to open double coats inside that you need to specify dollar open calibrates close calibration. And inside this, you're going to save our dart first string. Now you're saying, OK, I want the value off variable off for strength. So that's what you declared here. Now hit. Save. Now go back to your power shadow and inside your power shell. What you're going to do is you're going to again do terra form plan. Okay, The event added anything to the infrastructure. So it saying it's up to date. But let's just apply their form. Apply now. Once you apply, you should see the output variables getting printed. If you see here in my output variable, you should see my first output. Music will do. This is my first strength. So that's what you have declared here. So that's how you declare a string and consume it. Now there must. There are certain cases where you will need my feline strings to kind of input your variables in tow. Let's say use the data scripts for easy to R s awesome commands are. It could be any use case. I mean, stuff like uploading eyes, a document to your s tree by customizing that that string within the Terra form script there can be any use case. So that's why they also support multi line strings. So the value declare Moneyline strings would be Let me just copy this variable here, and, uh, you can say model B lying spring inside this, you're still going to be calling it the type of string. And instead, off this open coats, you're going to say of your edge and here you're going to say, this is a month. This is a marty line thing. New line. I'm just making up things here, and you have to end it with us again. So it starts with, ah to left out of rackets and then you etch and then the content that you want to put into that string and ended with again you etch and let's output this variable and see. So I'm just going to copy this outward variable. And I had it here. I'm going to say my multi lying output and I'm going to say multi lying strength right now if I go back and do tear off form fine again. There should be no changes, and I'm just going to apply. And you should see that. Okay, my multi line output. This is a multi lion string new line. So it's all printing out nicely, and we have now used strings Moneyline strings and also we have up output it those variables. I mean, we have consumed those variables within the terra form, so that's how you use the strength. Now, let's go ahead and look at this some other type of variables and see how it's going to be used. Now let's start with the maps now. Maps is typically used for key value pairs. Let's say, if you have variable that's holding multiple keys and multiple values and, um, you kind off need them all grouped together in a one variable. That's when you use the maps. The good example for this would be, let's say, if your family or with AWS and you should be family with regions and a mice. Okay, so let's say you have a set off am I that you've created in each different region and you want a one terra form to be used and you want to specify a different Am I when you're running in a different region, right? So So in that case, what you could do is basically you can create a map variable. Ah, and you can say if I if I'm saying, if I'm if I want us East, I want this Pacific, Am I? And if I say us rest, I want this specific. Am I? So that's one off the use case that you can use maps for and there are many other use cases . We're going to use it in the coming examples. When we're actually working with the infrastructure we can. I'll be showing you many different examples how to use maps and, like, very fits properly. So for this example, we're going toe, create the same court and let's see how it's going to work out. Now. Here what? I'm going to do this. I'm going to say this is my maps example and here we're going to say again, variable and we can say map example. And inside this, we're going to say type equal to map. Now again, if you are declaring a map here and if you don't specify type equal to map. It's still going toe. Read it as map if you are formatted it properly, But it is the best practice toe declared the type of variable that you are declaring here. So here we're going to say the fall equal to and here we have to open a open and close the curly brace. And inside that you gain against, say, the you can specify the key values. So I'm saying, am I wand you vest? Am I too? Right. So this is how you have declared the air mice and I mean the map and the way you're going toe output, this output map output. And here, inside this, we're going to say, uh, value equals We're going to say again, we have to open dollar could open curly brace, close, cuddly brace. And inside this, we're going to save our dart map example right. And here you have to refer to the specific key by opening and closing square bracket. And inside that you have tose specified in double court saying us east or if you you vest, whatever the value that you want to use. Now, if I save this and run my terror farm saying form plan again. There's no infrastructure change from a play. Now you should see Ah, my map output equal to am I want right, So that's the map output, and we got out with us A my one. So that's how you use them available. Now, if you want to use the other map, I mean, other key. You can just say you rest, and if you see you apply, you should see my about critical do. Am I, too? Because now you're using the second key here. So that's how basically maps are used. And, ah, like I said, I'm going to show you many different applications off this map in the coming lessons. Ah, and that's it for this map. So now let's go ahead and see another valuable type. It is our lists. Now. Lists are basically a race, and, uh, there is no special interaction that's required for her. Why and went to user is there are many use cases where arrays are used, so let's go ahead and look at how to use the array Now are a or the list, whatever you call it. So this is a race or lists OK, And in this, we're going to say variable. Uh, my aim. I know. Let's call it my security group list. No, the way you can use list is basically, you can say our type equal to list again. And inside this, you can say default equal to you have to specify open square bracket. And within this, you can say security group one security group to security group three so on and so forth. And you can use this as output. You can say security group output, and inside this you can say value equal to again. You have toe open up early for dollar open. Cuddly brace, close curly brace. And within this, all you got to say is my security group list off. You have to specify the index off a specific element. If you want to choose a specific element from within the list now, you can just say save it. Clear this out. There a form planned Teoh form planned, huh? Oh, yeah, My bad. So I have toe do this. I thought my security group because I'm refering to a variable and I forgot to put wire there. That's why it kind of complained that we clear the screen, so I'm going to run again to the farm planned and no changes again from apply. Now, if you see, you should have an output variable saying SG output equal to SG one. So that's what we're refering to SG one here. Now, in some cases, you need toe like you might need to apply all the security groups. Let's say if you are multiple security groups and you want to assign all those secondary groups to your easy to incentives you're creating In that case, you can just say Okay, I want everything from this list. So how do you do that? So you just don't need to specify this particular index in the square brackets. You can just leave it like that and it should work. Now if you see as the output is in a day off S C one and C two industries three. So that's how you basically used the lists, and that's how you're going toe output them or consume them. So that's about it for the less. And let's go ahead and take a look at the other um, variable type, which is billions now. Brilliance is also one of the most commonly used, most commonly used data type. And, ah, we're going to check out check it out. How to use it now for bullion. You don't need to specify the type. It's going to figure it out based on value, true or false Now. Also, there's two ways off declaring it so you can say variable, uh, test bull, and you can say it as default equal to weaken. You can declare it as a string, or you can declare it just like true. Now, if you declare it as a string, it will also treat it as a bull when it is applied to a appropriate available. Let's say you have a bull flag expecting I mean, you have a bull variable expected in a terra form, um, in it a form block and you're supplying a string off bull, which is like, true in the din, a double courts. It's going to still treat it as a bull if you specify it without the strings. It's also going t o treated as a bull, so it really doesn't matter. But if you look up the documentation for terra form, it's going to specify, saying that it's going to tell Tell you that there is some version incompatible t so you can choose either ways. Um, I would prefer to just say true instead off having it in a double court. So it's up to you whether to use it in a double court or not. So I'm just going to say Default equal to true. And if you output this, let's say output, uh, full output. And again, I'm going to say Value quarter to dollar open, close and inside this where I thought the school. Now, if I are put this, I will not get true or false in a string. I'll just get zero or one. So that's how the bulls are represented. And let's open up or tell a power shell clear off it and run the command again. Terra form plan and applies to form a play. Now you should see your pull out for this one because it's true now. If I set it to false save it and run terra form, apply again. You should see my bull output equal to zero. So that's how the billions are used in telephone, and that's pretty much it about the variables and I'm going toe talk to you about more about thes variables as and when they come up in the in the examples that we're doing and that's pretty much it for this lesson. And it's been a really long lesson, and I really hope you got to learn all about the variables in terra form and I will see in the next one. Thank you for watching. 12. 2.6 Terraform Inputs & Outputs: Hello and welcome back to another lesson in hashtag landing courses. And in two days listen, we're going to learn about input and output variables in our terra form course. So basically, ah, in the previous lessons, we have seen how to use variables. And what are the different types of variables that you can create in terra form? Now, in this lesson, we're going to see how you can utilize the feature off in putting the variables toe ah, terra form script so that you can pass in some dynamic variables and how you can utilize output toe kind off, see those variables and also ill talk about, like where else you can use the output variables. So let's get started. So the first thing that we're going to do is like to see how we're going to take the input to a specific variable. So what I'm going to do is I'm going to open up my same ah telephone file that we have used in the previous lesson. Now, in this, I'm going to say variable input. My input variable name really doesn't matter. Here. All it matters is what type we're going to use. So I'm going to say type equals the string. Now, here. What I'm just going to do is inside this. Uh, I'm not going to specify a default value. I'm just going to leave it like this now. What I'm going to do is I'm going toe output this variable, just like I did in the previous lessons. So my output variable. And inside this I'm just going to say value equals. Ah, and I'm going to refer to the variable that I'm going to input from the console. I mean, the power shell. And let's see how it outputs it now to reference to this I all have to do is var dot my input variable. And that's pretty much it. Now, if I run my terra form using terra form planned Ah, invalid key value. Ah, yes. So this is not a valuable this. This should be output. Right? So we're all putting that value, so that shouldn't be a variable. So let me clear this. I'm going to do terra form plan. Now. You see, it's asking me to input the variable, which is ah which is going to take in the value that I'm going to specify here and store it in tow that variable and it is going to output back again because we're specified in output variable to put that information out. So I'm going to say this is my test input and hit enter. And now when you do terra form Oh, no. So in telephone plan it doesn't do anything because it's not actually out putting stuff. It's just a test plan. But if you do terra form apply, it's gonna ask you for the same input again. So in this time it is going toe outward. So this is my test input. Now, if you see, you should see my output valuable equal do. This is my test input Now. You might have observed one thing that the output here is not in a specific order off what we have written in our script, because terra form of not follow the order in which that you have specified here it it follows always the dependency model, wherein you can say a certain resource depends on ah, specifically source. Then it will wait. Then it will create the resource in the order off the dependencies, Let's say is dependent on B and B is dependent on sea. Then it will create, see first and then it will create. Be then followed by a because is dependent on B and B is dependent on sea. So that's how it follows the order. But it doesn't follow the same order that you have specified in the script, so always keep that in mind. So So you know, you have seen the input variables. I mean taking an input. And also you have seen how do output this now another important thing about output is basically, let's say you are putting out some sensitive data, right? So let's say you're creating some secret keys are stuff like that and you are are putting it and you don't want it to be visible toe the person who is executing those commands. Then, in that case, what you can do is you can supply a perimeter called sensitive equal toe true. And when you do this, you will see you not see the output. But you'll just see that this is a sensitive piece off information, and it will not show you that piece off information getting out in the country so we can clear out from here and we can say terra form. Apply again and this is my test in port and you should see that my output variable equal to sense toe, which means the output variable has that information, but it is not showing us here. But if you use the output variables when you're when you're when you're dealing with models , I'll come to the models part when when we're living with that section. So basically you can. The reason why you have all put variables is one to show it to the user who is running and to if you want toe share your variables across different models when you are when you're when you're when you're you re using some off the telephone competent in another terra form scripts, that's when you kind of fused the output variables. So that's pretty much about the important output variables. And if you need more info, you can always go to terra form dot io website and you can check out the docks about different types off in ports and airports and also the different types off Variables are supported there, so that's pretty much it for this lesson. If you have more questions, you can always being me through the course, and I will be happy to respond to those questions. So that's it for this lesson, and I will see in the next one. Thank you for watching. 13. 3.1 Section Introduction: Hello and welcome back to another lesson in hashtag landing courses. And in this lesson, we're going to give you a quick introduction off what we're going to cover in this particular section. So in the previous section, we have covered the basics off uniform like terra form variables, inputs and outputs. And in this in this section, we're going toe cover the basic AWS confidence that you will be creating using the Terra form. Now, here are some of the competence that you'll be creating. So the first we're going to start off by creating an extra bucket and we'll upload the files. And during this process, we'll also see how to use terra form destroy toe. Actually, delete the resources that you have created followed by you'll create a new ah, easy to instance, we'll also look in tow, how to create application load balancers and target groups. And we'll also see an example from Cloudwatch and will treat an S and S topic in this particular section. You'll also experience, like, how to use variables in this how to use input. And I'm going to cover our all the basic stuff that I've, uh, that I start in the previous section. It will be using all those things in this particular section. So I'm really excited to start this particular section. Let's go ahead and start with the creating office to Bucket and I will see in the next one . Thank you so much for watching. 14. 3.2 S3 Using Terraform: Hello and welcome back to one of the lesson in hashtag landing courses. And in this lesson, we're going to create industry bucket and upload a test file using the Terra Form script. Now, before getting started, I want to show you how to use terra form documentation. You're toe kind of figure out like what resources do any to choose and like what? Ah, input video was that I need to supply. And, uh what what are the required variables and what are the optional stuff that I can use to configure? So to get started, let's go to the website. There are formed out i o. Now here we are, basically trying toe go ahead and create industry bucket. So let's go and see how toe find that s t bucket resource documentation. No. So find documentation. All you have to do is go to the dark section here and you need to choose the provider now, Like I said in the introductory lesson, saying that their farm is supported by many different providers, you can find all those providers here. The one which we are interested in here is basically aws. Now, inside this aws, we are there Are there two types of things. There are data resource. There are data sources and there are resources. So we're not looking for the data sources here. Data sources is like when you create a specific resource. What type off output information that specific resource is going to provide. That is not what we're looking for. We're looking first. The AWS resource is itself. So I'm going to search for A S three. Now, if you search for s three, this is a data resource. You can see your so as three resource is. So this is what we're looking for and we want to create the bucket. So click on that and you should see that AWS s three bucket is the resource name. And so you'll specify resource whatever the resource name is AWS s T bucket And whatever the while uh um reference name that you want to give within your terra form script so that you can refer to it s so this is like a variable name. So you can specify whatever you want here and inside that it is expecting a bucket. Uh, bucket is the bucket name that you want to create and, um, what is the issue? L which is like, who wants toe access that by default it would be private, and, uh, your you can specify some off the tags here. Now, if you want toe, create a static website hosting these all the parameters that it is expecting. And if you want to utilize cars so that you can specify cars rules and these are all the examples that he the documentation is showing. But if you want toe, see, what are all the supported arguments you can scroll more down and you can see argument reference. You can see what other option is values for the required values and all those things. You can see which region it is asking you to create. And those are Those are all the different properties that you can specify now, for over example, we're just going to go ahead and create a nest Reebok it in Ireland region. So let's see how to do it. So I'm just going to minimize this. I'm opening my power show in my course folder. What? I Lewis, I'll create a new to the form folder which is going to be s three bucket right inside That s t bucket or I have to do is create a new terra form file, which I'm going to say Main don t f All right, So my main Dr Jeff has created. Now I'm going to edit it with my, um very my sublime. Let me open Sublime first. Okay, this is our previous file. It's open file, Mr Bucket. Okay, so my main dot t afis ah opened. And I want to copy the same stuff that we have used in the previous lesson. That is are you have to specify our provider. So I'm going to use the same provider here, were specified the region, and, uh, let's go ahead and create our first s three bucket using this particular telephone file. So to do that Ah, we can see that we need resource AWS history Bucket, right? We can just replicate what it what is here? If we can say resource if to give the what type of resource you want to create and you are to give it a name so I'll say my bucket and open close inside this you're saying bucket mimic will do my bucket, uh, underscores are not separated. Say the of course and you'll say today's date 10 11 18. And this is just to make sure that we're not creating something which is already existing, because S three doesn't allow in duplicate name. So I'm just making up some random name for you. It might be a meaningful name, so I'm just leaving it like that. We just need a private one. We can also specify the region. We've already specified the region. Here you est one. We don't need to specify a region, but still, if you want, you can omit this part and you can specify the region here individually to different resources. So I'm going to specify a region here to say, uh, you rest one. And, uh, I just give it a name inside the tax, you can say name equal. Do what is a tag name of this college name. And I say, uh oh, no. So inside tax, you can say bag that name intact value, so I can say name. I could just call it let's call it. And while meant death, right? I just want to give one pack for now and let's see if there's anything interesting that weaken supply more here. So bucket bucket prefix A C l policy tags force destroyed. Website Carcelle Worsening logging. Uh, I think that's pretty much how I don't want a war complicate this particular part. I would just go with the basic, uh, S T bucket creation. So now, now that we have this, we can go ahead and create the bucket. So the way we'll create iss, basically go to the folder s three bucket and inside this will do terra form plan. Okay, Something went wrong. So what did I save? Whenever you're creating a new terror farm file, always remember to initialize the file. So I'm clearing this and doing terra form in it. Now, once you do initialize, it will download the required rate of reassessed Ikea. And once you have the rate of recess decay and plug ins ready, you're good to go and run detail, form plan. So let's wait until the plug installer it for us. All right. So the terra form has been initialized, and you can see that it has completed the downloading off. All the required pregnancies is our aws plug in. I'm going to clear this part and run the the command to reform plan. Now you should see that we are creating one resource of it is our aws s three bucket and it is going toe. Choose the less private we're going to give the name as my bucket bastard. A form course dash to the state and we have supplied the region and that's pretty much it now, toe. Oh, actually create. Basically. Like I said, plan is just going to tell us what we're going to create. But when you from the commander of from apply that's actually venue create e specific resource? No, let me clear it from here. So instead, a form apply. And once you apply it, you should see that it will ask you for a confirmation that yes, you want to create, so it will only take yes as the accepted value. So let me supply Yes and hit. Enter and you should see that it is creating my AWS s three bucket. And once that gets created, I'll open up the AWS console to verify that our bucket has been created. So it's going to take a bit off time. Okay, Now you can see that it has completed. Creating that resource apply complete one resource has been added. And now, if you Ah, if you're curious, you can go to your, uh, history Bucket folder here and you can see in the terra form Doctor of State. You can see that that it's one resource which has been added, and this is the information or the meta data that that is associated with that particular resource. Now, when you do change us, toe this particular the source in the telephone file. And when you run telephone planned, the Terra form script will actually find the differential between you, the meta data that is in terra formed RT of state and the actual infrastructure itself and does a compare. And if it finds any difference, then it will prompt you saying that. Okay, this is the stuff that you need to create all that that is being updated or that is being destroyed. So that's how it is going to work. So let's go back to our AWS console and ah goto our history section and see if our bucket has been created or not. So if you go double AWS console, I'm going to go to the history here and inside s three. Now I'll have to search for the bucket, which is have so many buckets here. Uh, you can see. What would we name here? So what did we name here? My bucket DF right. So let's look for the my Okay, so now you can see here it has been my bucket e. Of course you go here, my bucket e. Of course, you can see that it is not public because we have set the access control list as private. That's why it's not public. And your bucket is created and ready. Okay, so now you have your bucket ready. Now, let's go ahead and see how you can create a Plourde and upload a test file toe this particular, um, s T bucket. So in this, what I'm going to do is now again, go back to my terra form documentation and I'm going to search for Astri. Uh, well, let's go all the way down, and here we want to upload an object to it. So I'm going to use Aws s three bucket object, and you can see the sort of the argument reference when you school all the way down. I'm just going toe Use this particular example. I'm saying I need a resource, which is a double SST pocket object. And I'm just giving toe, give it a reference name and I'm going to supply the bucket name and we're using the key. We're supplying the key name that we want to use, and we're going to give a part to this particular source file and we can create e tag, which will check for the I mean, e tag will basically the way compute on your on your data off your file, and then it's going to come in for the attack. And whenever you have some changes in that, your tag will be different. And that's how it's going to compare and see whether a new resource has to be applauded are it? Just has to ignore whenever you're running the telephone, So let's go ahead and check it out. So I'm just going to copy this entire block here. I'm going to paste it here Now. What are the things that you need? We need to give it a name, right? So I'm saying my first object in the bucket. So here's an interesting application that we have learned in the previous introduction. So the way you're going to reference I mean, we already have created the bucket here, right? And we don't want toe hardcore our bucket name here instead. What? I'm going to show you It's like we're going to reference this particular pockets name from this particular resource. So I'm going to say dollar open, close flower rackets inside that I'm going to say aws underscore s three underscore bucket dark name. Now, how do I know that it is going to support this name? We can go to the data sources now and we can search for AWS. Ah, search for AWS s three bucket. If open this in new tab, you should see Ah, one of the data that it is going to output. Okay, so it is going toe output the name off the bucket as idea. So I'm wrong here. We don't need to wait. Don't We should not supply name. We should supply the i d here and the object. He I want to give it as like test file, Doc Txt and back to the fight. Now we have to create a file, right? So to create a file. I'm going back to my folder Street bucket, and you can say inside the scores, I am going to create a new just ah, fires inside this, I'll create a new text document, which is going to be sample object text inside that highly guest. This is a test. In your case, it could be aerial object. So now how do I reference to this particular fight? Right. So all we have to do is say we want to go up one folder because we were in the s three bucket folder. So we have come toe one up and we're going to go to the test files. So inside this we have test files and inside test files. We have sample object, doc txt So you can say sample object dot txt. Now we're going toe supply the same thing in sight. So this and now let's run this thing and see if it actually uploads this particular object into history or not. So to do that, I'm just going back to my, uh, we're going back to our terra form, going back to our partial and inside this I'm going to clear off this and say to our farm planned now, If you have done everything right, we should not see a ah s three bucket resource being created. Resurge F C A s three object being uploaded. Now if I ah i d must be teapots. Type Name? Attribute. Okay. What did we do wrong here? So we have to give our dot, Okay? It's not of our So let me go back to this. Oh, actually, this data, right? So it's going to be data about aws astri now if we do telephone plan Oh. Oh, Okay. Okay, Okay. Okay. I know what we're doing wrong here. So it's actually a process three. We didn't specify which s three bucket. Right? So we have to reference our pocket reference name that we have created here, which is my bucket. So we have to do a double s s three bucket dart my bucket dot i d. Now, if I go and run terra form plan, it should work. All right, So it is refreshing the state and it is basically checking. Do we need to create a new bucket or not? And if you see, it's not asking us to create a new bucket. It is just saying that. Okay, we're uploading our first object here, and, uh and there's nothing to change and nothing to destroy. So now we'll clear this will go terra form apply. It's getting going to refresh the state and verify if everything's okay, and then it is going to ask us for a confirmation. OK, so it'll asking for the confirmation. So I'm going to say yes because I want to create that history, object and hit. Enter. And once you do that, you can see that you are resources is applied and you have one addicts. It'll change and zero destroyed. Now, if you go back to your s three, uh, console and do a quick refresh, you should see a new object, which is test file that you have uploaded using the terra form. Now, that's how you're going to upload now. Next thing that we're going to do is like how to modify specific resource now to modify specific resource. Like I said in the in, the when we're creating, it's going to check the attack right now. If we go ahead and say in my test file, if I right, if I say this is a test file now have modified the texts. Right now, the uniform should detect that There is a change in my file, and there's a change that needs to be applied to the infrastructure. Let's see if that picks it up or not. So I didn't change anything in my terra form. It's all the same. All I did was like change the sample object dot txt file. Now I'm going to do a telephone plan again. Now you should see that there is a difference. And it needs to create a new object because the old object is different from the new object . Because the new eat ag value is different from the old object, so you can see that the e tag has been changed, so it will have to update that file, so you have to do their form apply. You can see that there is one thing to change. Instead, off zero to change, want wet. So we are changing just one file their and let's apply once it's applied, just hit yes, and you can see that the resource has been applied and it is if you go here, you should see the last modified date being changed. Ah, last modified was 10 39. Now, if I refresh, you should see 10. 41. So it's the latest file that we have uploaded. Ah, the changed version without changing anything in the terra form file, it automatically picked up the changes in the test file, and it uploaded a new object. Okay, so now we have created RST bucket. We have created our new object. Now let's go ahead and tail down or infrastructure no tail down, meaning like we're going to destroy all the resources that we have created. We should be very careful when you're running this command because this is going to take down everything. So let's clear out from here and let's try to reform, destroy, and you do terra form destroy. It's refreshing this state, and it's going to give you a list off all the resources that it's destroying. So if you see it is destroying to resources, which is your history bucket and your object. Now if you supply yes, it's going to go ahead and take down those things now. Yes. Okay, so let's try complete to resources were destroyed. Now, if you go back to your AWS console. And if you refresh, it should say that there is no bucket. They are not fun because the bucket we have created billeted and here you should see that there is no refresh desk that should go away. Okay, this is an old bucket. There's no my bucket here. Which means that we have Billy successfully deleted the resource, and that's pretty much it. Uh, this is a pretty long lesson, and I really hope you have enjoyed working with the Terra Form to create the AWS resource toe, modify it updated and actually delete the files. So that's pretty much it for this lesson. And I'll see you in the next one. And if you have any questions, you can always being me in the course. And I will be happy toe respond to all your questions. Thank you for watching 15. 3.3 Launch EC2 Instance using Terraform: Hello and welcome back to another lesson in hashtag landing courses. And in tourist lesson. We're going to see how to launch an easy two instance using the Terra Form script. Now in this lesson off to launch a new easy to instance, we have two requirements. Oneness to create an easy to pair keeper and to create a security group. No, these two resources can be created using their A farm or it can also be created with the console. I'm just going to walk you through how this can be created using the terra form. And then I'm going to use the console toe the AWS console to create these requirements. And then we'll see how to launch the easy to instance using the terra form. So let's get started. So the first thing that I'm going to show you, it's like how to create the key pair using the terra form. So to rule that first, let's go to the terra form documentation, which is going to be in the terra form that I a website and toe go to the documentation go to the dark section providers go to the AWS and the one that you are looking for is aws Underscore key. Underscore Pair. Now, if you select this now, we should see that, um you can be for you to create the AWS keeper using the three terra form stripped. You need to create a public key beforehand and you have to supply that to AWS to register your keeper. So to do that, what you need to do is you need tohave. Ah, there are different ways you can create and these formats that are supported our ah, basically open us a such public key format and waste 64 in corded dear format and excessive public e format specified in RFC 4716 Now, one way you can create it's like if you're using windows, you can use party Jen and inside party Jen, What you need to do is you just have to say generate and you have to just rotate your mouth here to create some randomness and that's going to create the public key. I mean, public e and you you just have to click save public e and ah, and you can just give it a extension off dark PPK and copy the text that this here. And ah, used this block off uniform court, which is resource aws keeper. And give the name that you want to give and give it a name. Ah, which you want the aws to recognize and just supply the generator. Uh, public key here. And then all you have to do is basically, um, their form planning apply. And that should be it. And to create this using the console, I'm just going to walk you through that in a minute. And for creating the, uh, security groups. All you can do is go to eight of yes, security group an entire security group. Or you just have to say, uh, no, this is the data source. I'm sorry. So inside Ah, you have to create a resource eight of the security group. You know what? Let's go ahead and do this using the terra form so that you will be having one more example to play around with. So firstly, I'll go to the AWS console and create my keeper. To do that, you have to go to the AWS console Goto aceto section and inside this, you have to go toe the key pair section. If you see inside the network and security. You should see the key pairs. Now select keepers and create Keeper and just give it a name. Let's call it terra form. Uh, terra form, of course. All right, that sounds Ah, pretty good. And, ah, in Satara farm course we can say that. A form course. Start them off. Yeah, we can save it here. Oh, you will need toe have this handy because you need that to basically connect to a easy to instant. So that's why you need this particular key before you launch an easy two instance. So Okay, so now all of our first requirement is done. The second thing that we're going to do is go back to our Terra Form course folder open. Of course, Fuller. And inside that we're going to start off it are easy to ah 10 a farm folder. So we have to go and create a new folder, call it E C. A C two on a farm, and inside this, we're going to create it terra form file, which is going to be main dot DF. All right. Yes. We want to change the extension to Dottie Effigy starter from fight. Now, as usual, I'm going toe open this file inside my sublime and we have toe do some basic stuff, so I'm going to go back toe RST bucket opened this guy up and copy the block off. Court off provider Close. This based because we need the provider here. And the form course, our profile name for the AWS taxes. Okay, So, like I said, we were going to create our security group using our terra form. So let's get started. So first thing that I'll put in here is go back to my, uh, aws documentation for terra form and search for eight of us security groups. Okay, so we are already in here and in this Ah, to let's copy this block. All right, so now if you are completely unfamiliar with security groups in AWS, basically, security groups are like, firewall that you can place in front off your instance, and you can control who can access, like toe. The instance who can have inborn axis and what out born access that particularly see two instance has and all that network traffic gets filtered using this security groups. So it is really essential for any ec2 instance to have ah very good of security group Rules Place so that you don't have any unauthorized access coming to your easy two instances. Okay, so let's go ahead and create one. So let's create the security group name as a terra form form. Easy to ah security group. I just called SG as a security group and I usually place the resource name same as the actual the resource that we're creating. And let's give this description as Terra Form course security group for easy to instance. I'm just making that up. And one thing you're need is basically the VPC idea. No, for this lesson What? I'm going to do this. I'm going to use a default VPC Now the default VPC you can find out by going toe your VPC in aws console and inside that you should see a default vpc So if you go toe your VP sees you should probably see a default Vpc Now this is your the fault vpc and you can copy this vpc i d here and you need to create a variable. So like you have like in the previous lessons we have covered how to use the variables. Now we're actually using that in our scenario. So how to create a variable? You just have to do variable give the variable name as we P c i d. And inside that so type e quarto string and you can give the fault for to your vpc 80. All right, now we need to specify that v p c i d. Here so we can say it is where dart d c i d. Now to use the variable solely of traduced dollar inside double coach after the dollar open calibrates viaduct vpc I d and you should be able to access this particular resource from here. Now you have a ingress and egress. Ingress is basically inbound, and egress is basically out born. Now you can have ah many rules by specifying many ingress rules and you can have many egress rules. Now there are again a different ways to specify rules. Now you can in your security groups, you can have multiple cider blocks and you can have Let's say you can allow rules to a different security groups and s so on and so forth. You can choose from different protocols. Now what we can do is we can say Ah for Port 22 which is our ssh. Uh, we're just going to say, uh, from Porter near Newport 22 was just basically saying like, OK, I just want for 20 to open and protocol ISS we want TCP, right? We want TCP Or if you go here and see what are the available poorer protocols. It's such for protocol. You can see Ah, so you can see vertical. If not my sympathies, you'd be minus one use particle. So you have to use TCP because we want TCP port. Ah, trainee do Because we want a succession to that instance. So we're saying allow for 20 toe open from everywhere Now you can specify your own I p address for this example. I'm just leaving it to all open. It is not a good practice, by the way. You should never use this kind of thing in your production. But for this example, I'm just gonna leave it open because we're gonna tear down that environment anyway, that the end of the lessons. So that's one thing. And in the egress, one other thing is for in your security groups. If you have something open? Ah, inbound. Then for that specific thing, you always have that out. Born but open by default if you have something inborn open. But we just specify, uh, out born rule as well just so that we can play around with this And you can say in the side of blocks that Yes, I want open everything, and I'm just going to get it off this. All right, So now you have, Ah, security group, which is there? A pharmacy to SG should be created. Now, let's go ahead and run this terra form script now to do to run that all. You have to do this. Open your power. Shell and I have a partial open here. Now, inside this, we want to go to our Ford. Right? So inside this, we want to go to our e C to tear a farm. Two year. Let's do there a farm in it because you have. This is our new telephone file. We have to do initialized first. So let's talk terra form in it. Uh, it's taking a bit. All right, so we have our uniform initialized. I'm just going to clear the screen again. we're going to do terra form plan now and see what it comes up with. All right, We don't have any errors. It's saying basically, we are creating a We're adding one resource zero to change the law to destroy. And we have a security group that we're creating. And we're specifying one egress ruling one ingress rule so you can see egress Number one, um, in dress number one and you're adding those resources. So now you can clear again. You can say terra form apply, and it will ask you for the confirmation. And once you're type in, yes, your new resource should be created and we can go back toe the AWS console once it is created to verify if that new security group has been created or not. Now let's go back to our AWS console now Goto our ah security groups, right, fig or the secretary groups search for terra form. All right, so you have security group named at a pharmacy to SG their form course SG for Restitution Center 40 of created and inside the inborn rule. You can see that you're opening a society for 22 in TCP Protocol and from everywhere. And you also have the same out born rule specified here. All right, so the first part off the easy to instance, is completed. Now, let's go ahead and actually launch. Easy to instance Now, to do that, I'm again going back to my, um Terra form documentation. Now I'm going to search for aws Underscore e c to underscore. Ah, actually, yeah. Aws underscore Instance. So if I go here now, I'll be seeing an example for how to launch an easy two instance. Now, if you see Resource Aws instance Vap and you need any am I OK? So there's one more dependency here. We need any of my Soto get the am I We can use the latest whatever the easy toe the next heir my, which aws offers in In your case, if you have a specific am I that you have created, you can copy that Am I I d from images section But in this case, I'm just going toe am eyes You can search in it in a couple of face weaken goto owned by We can actually go to this. Begin search for aws Lennox and be one render as Amazon Web services, and you can see Amazon the next AM I am just going to choose start and to get the to get the am I I d. Let's go ahead and search for the my I d you know what? The easier way to find out. This would be just going to, ah, instances launch Easy to incident. And this is going to show us the Am I i d from here now. I'm just going to choose. Ah, this am I I d Copy it. Come back off. Come on, off this page. Now go to my telephone file again. And inside this I'm just going to specify another where but just variable in my i d am I i d And inside this there's only to specify string for the string. Something's going to leave it Us the vault equal. Do the sprinkler Am my idea. All right, so now we have the am I i d. And then we let's go back to the documentation again and see what else we need. So all right. So we can just copy this block, which is saying a resource aws instance, and we can name that instant something can go here. Copy that. So we're saying aws instance we can call it Terra Form, is it, though? Instance. And we can specify this as dark in my idea. All right. We can choose the instance. Type did a lot Micro. You can specify one over the incidents type you require, uh, and we can say name as these are the tags that were specifying so we can say tags name. It will toe terra from you See two instance All right. And you can also specify many other attributes. Let's go ahead and check it out so we can specify which availability zone this is optional . If you specify a specific availability zone, it's going to create in that if not it, it's going to randomly choose one. If you want placement group, you can choose that default tendency is basically shared if you want. Ah, or did he get it? Holds Jurgen, choose the tenancy. Asked the single tenant. Ah, you can you conspiracy if I number off CPU core counts. Ah, these all and you can specify EBS optimized. Um, you have many other inputs that you can give one other input that we want to give is basically the key name because we have created one key and we're going to use that key name . And also we're going to specify the security group for this. So let's choose the key name option here and in here. Let's go ahead and check out. Specify the key name. If I remember correctly, let's go ahead and go to our see to Let's go to the Keeper and select this. Keepers were just form course. Copy that Basted here. Now let's go back to our terra form documentation. Now, inside this, we're going to say the list off security groups are Sicily did of it. Ah, before the PC, only a list of security group names are these All right, So we can say we want security groups because we're using the default here. And you can specify I am instant profile if you were If you are passing in the I am role and there are many other things that you can specify year like EBS, block devices and so on and so forth. So for now, we're just going to say, Ah, we're choosing all the defaults. So in security groups, it's a list off security groups because you can have multiple security groups assigned to a specific instance. So I'm going toe specified as honorary, and inside this, we're going to specify dollar and we're going to say, uh, you're going to say a lovely A security group, right dot This resource name it is easy to s G. And I think it is I d Let's go back and verify it. How? Ah, the security group is out putting its variable s. So I'm going to duplicate my documentation here, going back to the AWS security group. Now we have to check the data, right? So because data sources, we want to see how the security groups are putting the data. Now you can see Ah, so if you see okay, the idea of the specific group to retrieve. So that's what it is going toe output. So we can just say go here. I mean, go back here and say I d and that should be pretty much it. Now, if you go ahead and run your terra form script now, you should see one resource to add. Let's clear this out and run the terra form on. All right, so there are no error, saying it is basically telling us start it's launching an a C. Two instance with most off the deformed values and the values that we have specified. Let's go ahead and apply it so clear. Terra form apply. All right, so it's asking for a conformation. Just type. Yes. And once you typed, Yes. Oh, okay. So possible mismatch. Security group ID's and names. See aws Instance docks here. Ah, value paramilitary group. The ideas in invalid. All right, Something is wrong here. Let's go back and check what's happening here. So you're saying security groups equal to ah, we need to specify list off security groups that that's what we're saying here, let's go back and check. So secretary groups equal toe specifying list. Uh, let's go back and double check this. We have to go here. Check for security groups. Okay. The associate security groups. All right, we have security groups. We have it open. Close. All right, so maybe this is because it isn't already for particularly group. Let's check for VPC security group Pioli's and let's see how this works. All right, so let's go back indoors. Terra form, form Plan again. Uh, 39. Okay, I'm accidentally deleted this. Oh, I think this is because the land tolerate. So let's save this. Go back here to terra form. Oh, I Mr Double court here. Let's hear this terra form sign again. All right. Fleshing state, therefore apply. Hit. Select. Yes. All right. It is now creating the actually Aws instance. Ah, and once that is created, you should get back the instant society and let's see. All right, so you have won. The source added. Now, if we go back to our aws console, you should see a new instance being launched. They go to instances. All right, you can see that there are pharmacy to instance has been launched and its incidence i e it has the teacher on micro that were specified it choose the random available disown us one b and it has choosing the key name Terra form Dash course. If you would have specified user data, it would have front some bootstraps trips. But we haven't specified and it has applied the pharmacy to security group. And the reason why the previous ah attempt failed is because we we use the block off security groups, which is basically the default one. We need to use VPC security group ideas because we have created a non default security group in it if articulate in a default BBC so that's pretty much it. Ah, you can see that now you have launched an easy two instance your also seen how to use the variables properly and how toe kind off get hold off those off variables in a specific AWS resources. So that's it for this lesson on. And ah, this is a really long listen and I really hope that you enjoyed it. And if you have any questions, you can ping me in the course and I'll be happy to answer. And thank you so much for watching and I will see in the next one. Bye bye. 16. 3.4 Section Conclusion: Hello and welcome back to the conclusion lesson off this section. And in this lesson, I'm just going to give you a quick walk through off what we've done in this particular section. And I'm just going to give you an introduction to what we're going to cover in the next section. So let's get started. So in this section we have seen how to use the bay. I mean, how they create the basic AWS resource is using terra form like creating industry bucket, uploading a file toe s three bucket. And also we have created in easy to instance, and along with that, we also created the security groups. Now this Ah, the whole goal off. This particular section wants to just get you an understanding off how to create AWS resources using terra form and also how toe implement some off the concepts that we have learned in the previous sections. Like using the variables extra. And also we have seen how toe go through the terra form documentation to figure out what are the required properties that you need toe supply to create your resources. Now you will basically apply the same concept to create any type off resource in ah AWS using terra form, and it's pretty much straightforward now that you know how to create. The resource is let's go ahead and learn in the next section the proper ways off using terra form. I mean advanced concepts in which I will teach you how to use models. How toe have, ah good folder structure for your enterprise level infrastructure and different concepts that are really important toe have a very good, manageable terra form. And ah, and I really hope that you enjoyed the section. And I'm really excited for the next section because there's a lot off good stuff that is coming over or in the next section, So I will see in the next one. Thank you so much for watching. And if you have any questions related to this section, you can always comment on the course, and I'm really happy toe. Answer those questions, and also if you feel that there's something missing or there is some really important concept that you would like me to cover, then you can always pick me in the course, and I will be more than happy to add the particular information to the course. And if it is a extra lesson, I'm definitely open toe ad, More lessons to the scores. Because the ultimate goal of this course is to make you a better user after a form. And if you need something, I'm really excited toe help you out and get more content under the course so that it is more helpful. Toe all the other students who are participating here. So that's it for this lesson. And thank you so much for watching. And I will see in the next section Bye bye. 17. 4 1 What is Terraform Modules: hello and welcome back to under the lesson in hashtag landing courses. And in this lesson, let's look at what terra form module ter and why we need the models. So let's get started. So the first thing that comes to my mind when when we say model is basically separation off constants. Right? So when you have a big infrastructure that you want a provision through terra form, you would like toa basically separate it out into smaller segments so that it is easy to manage. And also you can construct ah, reusable, competent so that you don't have toe repeat the same court again and again and instead use , um, a module so that you can reuse that with in your main terra form and reduce the court that you are writing to achieve the same task. So to give you an example, let's say you are big infrastructure has ah, a load balancer that needs to be configured, right? So if you want a load balancer Toby configured four times, right. So if you have a set of work lower, which needs four different lord balances, you don't want to write like the same Lord balance or logic Four different times inside what you're do ist you separate it out as a module and you give its own input variables. And you'd say from outside that Okay, I need this more deal with so and so input and this morning with so into input and you're just used that particular model now I'm just giving a small example. In your case, it might be they set off in frustration. Chur, where you have a load balancer, you have an order scaling group and they cloudwatch alarm. Let's say you separate that all out into a model and you can reuse that whole competent in a other terra form by just calling it and supplying it with the required variables. Then you're have a smaller chord, which is easy to manage. And if you want to change something, you don't have to change many different places. You'll just change at one place, and that would basically change in all the places wherever the particular model is being used. So that is why we need models. And it is really important to understand this concept so that it becomes very easy for you to manage your infrastructure and it is a right way to handle infrastructure. So I will stop this lesson here. And in this in the next lesson, we're going to go ahead and see how to create this more deals and how to import a specific model into another telephone file. So I'll see you there. Thank you for watching. 18. 4 2 Terraform First Module: hello and welcome back to one of the lesson in hashtag landing courses. In the previous lesson, we have briefly discussed what terra form modules are and why it is important for us to use that, therefore, models in this lesson, let's go ahead and actually create our first era for model. And let's go ahead and see how to import, especially model and run out of form script. Now, before we go ahead and create a project, I just want toe give you a quick walk through off like what the documentation looks like, and then we'll go ahead and create our project so you can basically go toe telephone dot io site, and you can go to the dark section and to the left hand side. You should see the models part here, and ah, you can basically go ahead and read more if you would want more information and you can see the sources different sources where you can store your more jewels and then reimport them again in your different uniform projects, you can have registries and so on and so forth. You can read more about it if you if you are really interested in how to do the model center on. So let's go back and create our first model. Now, the object off this module would be basically first off will create a model, and in that model, we're going toe create a easy to instance. Now, in our previous section, we have created an easy to instant using the terra form. Now, in this lesson, what we're going to do is we're going to do the same. Um, creation off, easy to instance, but instead off writing everything in the same main doctor, Theophile we're going to create a model to create that easy to instance, and we're going to import that model in our main dark TF and, uh, recreate this same easy to instance. So to do that, let's go ahead and get started. So the first thing that we have to do is we have to create our Project folder. I'm going to use the same directory where I've been working for the previous lessons. Some create. I'll create a new folder here, and I'll call it easy to modules module Ah, project. Right. So inside this, we have to create a new a terror farm files, which is going to be our main dot TF instead off txt. Okay, so now what I'm going to do is basically, um, to create a model. Right? So the module is another terror from project. It could be within the same project that you're working, or it could be anywhere else to like we have seen in the documentation, you can clearly see that different sources are local parts transform terra form registry, Get her but bucket or http Urals wherever that special more the Alexis. So in our case, what we're going to do is create the module in the local directory and within the same project. So what I'm going to do is I'm going to go ahead and create a new Ford er right inside this . What I'm going to do is e C two underscore more. Let's keep it simple. Now, inside this easy to underscore model, I'm going to create another file, which is going to be easy to underscore. More dool dot TF. Right. Okay, So now our project directory is all set up and ready. I'm going to just go ahead and open this folder inside the, um sublime. Hit it. Oh, I think we already have it open, but let me just be sure about it, okay? Open folder. We don't open this Ford er, open it. Right. So this is the project that we're working on right now, and Ah, the first thing what we have to do is basically go ahead and create our provider. Now, how do we create a provider? We have done so many times the previous lesson. So I'm just going to copy this provider part from our previous project and basting it here . So let's go ahead and initialize are initialize our telephone projects. Um, need this part. So now I'm in the course directory. I'm going to go into the seed EEC too. Model project. Right. So these are the contents that we have. It's clear out of fear and do it on our farm in it. When we do the terra form in it, it actually creates the I mean, don't know. It's all the plug in start are required, and once a plug ins are downloaded and ready to be used, it gives us the success for message so we can just clear out from here and let's go ahead and write our court, which is required in our model. So the goal is toe recreate the C two instance. So I'm going to go back to my easy to terra form project and from maine dot TF. I'm just going to grab everything from this cord, right? I'm just I just left the provider and have copied everything that is their required for the creation. Off are easy to instance, and I'm going to go back to my issue two model project. Right inside This you'll go too easy to underscore module and easy to underscore model Doctor A farm here. I'm just going to paste everything right. So now if you know this already had waas separated our cord from our main rtf and put into a separate module file Right now, the next thing that you're going to do is go to maine dot TF and you have to import this particular model. Now how do you import this model? It's really simple. All you have to do est right more do and you have to give that module a reference name, right? You have to give it a reference name as more do right. And you're calling it ass Ah, and you have to give it a source. No source equal to now as it is in the same folder directly. You can just say dot slash EEC to underscore model. Right. So you're in the same directory and you have included this. Now. Now, if you go ahead and run Terra form plan now, this command is going to fail because now you have added a module and you have not initialized it, right? So whenever you add a specific model toe your terra form project, you should always do it on our farm in it. So to do that, I'm going to run there for a minute. And now it is going to import that particular model. You can see that it is getting the source from start slash easy to module and it has applied toe a particular project. Now, if I clear out from here and do terra form plan now, it's going to tell me that we will be creating a ah to resource is oneness basically the security group and the easy to instance, right, The security group and the easy to instance. Now let's go ahead and run this farm, apply all right. So when I do a telephone apply, it's going to asked me for the confirmation. I just say yes. And once I type in, yes, it's going to create. Ah, All right. So the problem here is basically in the previous example, as we have created this easy to underscore SG security group there for Mr Two SD security group. We cannot recreate the same resource because it is it is already existing there. I haven't deleted it. So what we can do is go back here and, uh, give another name saying s g underscore model. Right? So it makes sense to give it a module. And then what? We're going to do this terror farm plan? Uh, okay, let me go ahead and fixed us. So we have to give the same name here. Right? So we This is our reference name. And this is the resource name, and we're calling this in the easy to section here, so we'll have toe ah, replaced this name here and then save it. All right, So now if I go back and do terra form plan Okay. So we have to re sources that we're creating terra form. Apply and we're going to say yes. Okay, so our security group is now being created, and we can see that we have our new easy to instance also being created in just a bit. So he said to instances being created, this might take a couple of minutes. I'm gonna pass it here and they come back. Want to this ready? And I'll show you are in the AWS council. All right, here we go. So are easy to instance, has must have been created. Now, let me go back to my earliest council, and let's verify if that new easy to instance has been created or not. All right, so you can see that the new easy to instance has been created, which is being launched here. And ah, I think I haven't destroyed my previous instance. I'm just going toe the old one. This is the new one that you have created. Ah, and yeah. So basically, this is how you can use and create a model, and, um, in the next lessons were goingto go ahead and experiment more on, like, how Toe give imports. And how can you have multiple modules? And how can you import the same models over and over again. So that's pretty much it for this lesson. And I am going to see you in the next one. Thank you for watching. 19. 4 3 Terraform Second Module: Hello and welcome back to one of the lesson in hashtag landing courses. And in this lesson, we're going to continue off from our previous lesson where we have created our first terror for module. And we have created an easy two instance using a model. Right. So in this in this lesson, what we're going to do is create ah, modify our existing telephone project and refine it more so that we can supply some input variables to that particular model. And we can also separate out the security group out off that, um that easy to model so that we can have more control over what security groups gets created and how we can pass in that security group variable that was created in a separate model and input it as an input variable toe the PC to model. So let's go ahead and see how it is done. So what I'm going to do is I'm going to open up my project folder and I'm going to duplicate this project for her because I don't want to create in the same one. So I've duplicated it, and I'm calling it as part two, right, So inside this we had, um all this state files which we don't need, you don't need all this right. So now we have a clean ah, copy off our previous project. And what I'm going to do is I'm going to create other model, which is going to be my, um, security group model. Right. So this is our security group Mardell. And inside this we need another terra form file. So we're going to call it s g underscore Mardell dot t f All right. So again, I'm going back to my course trucked off course. Fuller and I am opening my, um, sublime edit. And inside this Now we're working in this, but to project ah, folder. So let me go ahead and clean up some off this model so that we have to separate models and we have to add an import statement for that model in the main Dottie a fight. Right? So the stuff that I want to separate this like, if you go to the easy to dot Martin issue to underscore model rtf, you can see that we have a resource called security group which ah which needs this dependency off vpc I d. Okay, so we can see that v p c i. D. Is an input to this particular resource which is security group. And also it is a input to our Ah Did they give input as V p c i t here? I was trying to see OK, so this guy doesn't need that 50 c i d. All right. So what we can do is we can separate this part out, right? I'm do you cut from here and you can see that. Ah, this has been separated and we'll put that in the security group model and we can save it. Right? So we're not supplying any input. So this particular security group model, but we have to do with output. Ah, variable from this particular model. Right? So the they you will do an output variable is basically you can say ah, like in your previous lessons. If we go and ah, you can just say output, you can call it Ah, security group. I d underscore output and you can say Ah, the value iss. Basically, you have to do dollar open close and you're getting the value from terra form. If you go to your east to model Lincoln. Get the value? Yes, this guy. Right. So this is the well you that we going to export. So basically, what we're doing is we were suffering toe referencing to this Arabia security group and inside that we're giving referencing our module name. And if you're calling the I d from it, let's do it this way so that it is visible everything in the same line. So here what we have achieved so far is we have a security group module which takes which doesn't take any input, but it's going to create the output variable. First, it's going to create a security group, and it's going to create an output variable. Now, we have created the security group in the previous ah example. So I'm just going to change the name so that we can say security group module creation. Right? And I'm going toe rename it here, and we are going to change the name here. So now we have our security group being created as SG module creation, and it is being output a nasty S G i d output. All right, so now what we have to do is go back to our main rtf and basically import the specific model. Now we have to import this model before we import the easy to model. Because what we're trying to do is we're trying to create the security group in a separate module, get the output off dart and supply that are put variable as an input variable to the easy to model so that it knows what security group it has to attach to. Right? So we're going to import more do, and we're going to call it s G underscore module and will give the source, which is source equal do dot, slash SG underscore Mardi. Like. Okay, so now we have imported Ah, the, um the I mean, we have included this as Jim model as a as a dependency in this main dot TF. Now, once we do that, we can go ahead and reference this particular module and read all the output variables from it. All right, so the way we'll read this particular, um, output variable and supplied in tow. This guy is we have to create a variable first inside our model so that it knows that it needs it is expecting an input. So the way you will do it is basically go to your easy to underscore modeled rtf here and you'll create a variable, right, So you'll create a variable saying, SG I d. Okay, let's call it s g underscore Rieti, and you'll just give open and close. That means you don't have any default variables here, But your ah, this particular model expects this as an input. And you can What you can simply do is instead off. Um, using this, we'll just call that dot SG underscored. All right. Right. So now you're saying I'm expecting this input, and I'm supplying that input. So this particular easy to instance And also, let's, um, change the name, uh, and supplied as an in portrait. This is just to do more practice on imports, right? You see, to underscore name. And these are the two variables that will be supplying. Then put us and we'll have to change the name here. Well, say dollar will say easy to wear dot GC to underscore name. All right, so this part is now complete. All you have to do is go to the main Dr Jeff and, uh, supply our input variables to this particular model. So the way you will do it, iss um um the variable names are SG underscore i d So you'll just say SG underscore idee equal to now this is being output it from this model. So you have to do is under inside double quotes dollar open, close and inside This will say more dool dart and you'll reference the model that you are importing it from. So model SJ underscore Model Dart and whatever the output name off that particular variable list. So this is the output name. And, uh, we'll just have to do this so we have more your dot as the module and as the underscore idea output. So that's the I. D. That's being created in the previous step. So and the other one that we have toe include it's the PC to name right? So we'll copy that and paste it here, and we'll give it saying that Ah e c toe instance from marginals. Right. So this will be the name Ah, tag that will give you are easy to instance and let's go ahead and see whether this works or not. So the thing that we have to do is go to our project. Ah, and open up terror farm the, uh, the partial, um, council there and go to the project folder, which is our part to project. You can see that you have to models there. Now you have to do is do terra form in it so that it includes two modules, which is your issue module and easy to model. And it's also going to install the provider plug ins of it is essential for this product. Okay, so the product has been successfully initialized. That's clear here and do a terror farm plan. Now we should against C to resource is being created Oneness, thesis, acuity group and the other is the easy to instance. And, um, you can basically see ah oh, that we're creating to Resource is here. Let's clear here and we do terra form apply and type in. Yes. Okay, so I'm going to pause here because it's going to take a few minutes for it to complete. Oh, so there's something wrong here. So we're saying Ah, easy to instance, Other launching instance Invalid keeper not found easy to instance from model does not exist. Alright, so let's go back and check what? Ah, and are we did here. So did I remove something wrong from here? Oh, I'm sorry. So I have I've changed the wrong variable here. So this is terra form. Courses are key name with just the ah, which is the keeper of that which will use to retrieve the passwords and, um, s ascension to the instance. So we have toe apply it here in the tag variable. Right. So we have to go and do. Oh, we have to call it war start E C to underscore name. Now, if I save it, clear this do terra form plan again. Now you can see that there is only one resource Toby created because we already have created the ah security group in the previous step. So there is only one resource which is spending so it can weaken. Do terra form apply, and you can just do yes here. And you should see that the instance will be created. So I'm going to just pause it here. And once the instances created, I'm just going toe come back and show you in the council. All right, So are easy to instances now. created. Let's go back to our console and do it quickly fresh, and you should be seeing a new instance being launched, which is easy to instance from model. Now we have supplied this as an input your model and we have created a new security group. It is ah which is basically SG underscore model creation. And if you click on this, you can see that all the rules that you have supplied here, our apply to this and that's pretty much it. Now you basically have learned how to create multiple modules and give inputs. So those models and how to output unspecific variable that from a specific model and supplied as an input to other model. Now, this is a really important concept because you can extend this particular concepto manage very large infrastructure where you have so many components and they are all dependent on each other and you don't want to write the same court again and again are hard court the variable so that so that it is very hard for you to manage when you're updating any specific competent off your infrastructure. So I'm going to stop this lesson here. I really hope that you guys learned a lot from this particular lesson. And in the next lesson, what I'm going to do is I'm going to show you how doe reuse this particular model in the same project and create multiple Ah, easy to instance, by calling the same model with different inputs, like giving it different names. Right. So let's go ahead. And, um, close this lesson now, and I'm going to see you in the next one. Thank you so much for watching. 20. 4 4 Terraform Reuse Module: Hello and welcome back to hashtag learning courses. And in this lesson, we're going to see how to reuse the Terra for models. Now, in the previous lesson we have created to models which are security group and easy to as models, and we have imported them in the main doctor fight. Now, what we're going to do is now you're going to create more easy to instances by just using the same model. Right? So we're not going to touch the easy to underscore model, Dr Jeff. We're just going to touch the main Dottie a file and we're going toe create another easy to instance using the same model. So let's go ahead and get started. So the first thing that I want to do is open up. My will be in the same project folder. Um, I'm opening up my terra farm. Ah, partial and my terra form folders. All right, so the first thing that I want to do it's, like, destroyed the instant that I've created previously. So I'm going to do terra form that strike, right? And it will last me for a confirmation in just a bit. All right, so this will be destroying the easy to instance and the security group that it created in the previous lesson. Okay, so one more thing that I want O mention here is ah, state files. Right. So when you are working in modules, you will not have state files for each specific model. Now, if you go into your model folder, you'll see nothing here. There is no Doc. TF backup are There is no doctor of state file. Everything is stored in the main ST fight itself. Right? So all the modules, Ah, information is stored in this main terra form doctor of state file. I can even open up that particular file and show you what exactly is created in that, right? So if we go here and open up, there are farmed RTF state files. Oh, there's nothing left because we have already destroyed what? I think there should be something in the back of files. Yes. So if you go here, you see that there are Ah, this is the route model. And there is nothing in here. All we have done, it's like we have created her, were imported the resources. I think this is the backup. This doesn't give us a good idea. But after this lesson, I will show you how toe actually check their terror from ST filing how the models are separated within the street fight. So let's clear this up and let's get started. So the first thing that we will do is, um, Goto, the project holder itself. Let's close everything OK, And the one which we are interested in this just e main Dottie A file. Now here. What we're going to do is, um we already have the easy to model and the security group. Wandell, we're just going to replicate this particular module and we're saying Okay, we want another copy off this easy to model, right? And, um, we are going to call it well, say easy to instance, one from model, and we'll say it's two instance to from module. Now, this will end up in creating two different, um, easy to instances for us, so we'll call it. Oh, we'll call this one. We'll call this to this is just the reference name to your model import. Right. So once you save this, all we have to do is go to terra form. Ah, good. Partial and run the tear off form in it. The reason why you have to run the terra form in it is again. Like I said in the previous lesson, whenever you add a new model or whenever you re import a specific model, you have tow run native four minutes so that the Terra form figures out that there's something new model attached to this particular main doctor. So want you to a terra form in it. You can see that there is easy to model one to model to being imported from the same source . Right? So you're reusing the same model now two times and it has been initialized. Now we can clear this. We can run terra form plan. Now you should see three Resource is being created. One is the security group and the too easy to instances. Right? So you have to We see two instances One security group. Now you can do Terra Farm apply, and it's going to create these three resources type in. Yes, And once you do this now, it will create the resources as specified. I'm gonna pass this lesson here, and I'm gonna come back once the issue Two instances are created. All right, so after ah, a few minutes. The Easter do instances are now created. Now let's go back to our council and check if they have Ah, completely provisioning. Now I just hit, refresh. And now you can see that easy to instance, one from Mardi ELISA Two instance to from module off are created and they're being initialized, and that's pretty much it. Now you have reused your, um, model and you have supplied different inputs to that, and you have created multiple resources out of the same court Now, like I said in the beginning off the lesson about the state files Now we can go ahead and check our state files. You should see that there is only one particular state file here, and there is no state files associated with any off the models here. And if you look carefully in the module section here, you should see that there is route part and inside route. But ah ah, Okay, So the pot is basically ah route and easy to module one. So inside first model, there is nothing. We don't have any resources in the second. Ah, In the second model, the part is basically under route. You have easy to model one, and you have the easy to instance resource being created. And in the second module, you have again route and easy to model to that you have imported. And it's particularly resource, and then you have the security group model. Then you have all the variables related to that particular is to model here, so that's pretty much it. This is how the state fire looks like when you use the models. And, um, I think you have learned a lot off information from this particular lesson, and I really hope that you can apply these techniques in your real projects and, um, get get the best start off the models in your infrastructure. So that's pretty much it for this lesson, and I will see you in the next lesson. You can ask me any other questions if you have in the course section, and I'll be happy to answer all those Thank you for watching 21. 4 5 Terraform Multiple Environements Problem: hello and welcome back toe hashtag landing courses. And in this lesson, we're going to learn about multiple environments. Problem now? What do I mean by multiple environments? Problem. So in any enterprise level infrastructure, you can see that there are different environments off your infrastructure. Like let's say you have ah development and where when you have your key way or staging environment and then you have a production environment. Now the key factor here of when you have multiple environment is basically toe. Have consistency across different environments, meaning you should have your infrastructure identical across different environments. Now, if if it is not identical, then basically you're not testing against the same infrastructure. For example, let's say you have a load balancer configured using a classic load balancer in your dev environment, and you are using an application load balancer in your staging and prod then of what you are seeing in your death of the results that you're seeing in your dev environment of the performance metrics that you're seeing in death might not match the performance metrics in in the queue environment. I mean, this is just a hypothetical example, but ah, like you can also think about the security groups. Let's say you've created a security group with a port open in your staging, but then you forgot toe open that particular port in your production environment. Then, um, then you have a problem, right? When you test in your staging, it's going toe work. But if you promote it toe production, then it's not going to work because the port is closed. So toe avoid these kind off situations. We have toe have our terra form script to be used across different, very different environments using the same telephone file, meaning you'll write the cord for your infrastructure. Saying that I need the security group. I need her load balance that I need in order. Skilling Group and all the These are all the properties that I want to apply to it. But what you're going to do issue are going to give it environment specific inputs and it is going toe create different resource is based on what environment you are on it, so this is achieved by using the feature off at a farm called workspaces. Now, using workspaces, you can create different work spaces in the same terra form project and you can work on specific workspace at a time, and you should be able to create our modify resources in that particular workspace, and then, once you're satisfied, you can apply to the other workspaces. Now I'll give you an example of how you can use workspaces to solve this multiple environment problem. Now let's say you create three different work spaces for the same terra form file and what you will do. It's like first workspace would be your death, and you create that workspace. You apply the your resources, and then all the sources are provisioned. Now want to verify that everything is fine, Then your, uh, select your staging workspace and you'll apply your resources there. And once everything is done, you'll apply to the prod, and everything is working fine now and then. After day. You want to make a change, and you want to test it in deaf straight so you'll switch back to your development workspace. You'll make your changes and you will apply it and see that Oh yeah, this is working fine. This is the required change that I need, and I need to promote this. Two Q A. All your free do it's like again change back to the Curia workspace or the staging workspace. Run it. They're very fired and then promoted to prod. Now what we have achieved in this process is basically consistency across multiple environment, and there is no doubt that whether we have missed any off these properties and if there's any mismatch across different environments, so workspace is a way to go to solve the multiple environments problem. I'm going to stop this lesson here and in the next lesson, we're going toe talk more about workspaces and we'll see how it works. Businesses creator and how the switch between different work spaces and how the terra form state files are managed for different workspace environments and so on and so forth. So I'm really excited to start, Ah, this workspace concept because I really enjoy it. And it is a really useful um um, piece off information that you can apply in your enterprise level projects are even your personal project, um, toe manager infrastructure in a more consistent way. So that's it for this lesson. I will see in the next four, and thank you so much for watching 22. 4 6 Terraform Workspaces: Hello and welcome back to one of the lesson in hashtag landing courses. In the previous lesson, we have discussed what theme multiple environments problem is, and the way to solve it is using the telephone works basis. Now, in this lesson, we're going to go ahead and check out how do create these workspaces in our projects and also apply these multiple workspaces toe create multiple resources in different environments using the same uniform scripts. So let's go ahead and get started. So the first thing that I want to tell you is basically, we're going to use the same existing easy to project that we have created in the models part. And we're going to create new workspaces for that specific project. And we are going to modify ah, bits and pieces off that project to accommodate the workspaces there. So let's go ahead and get started. So the first thing that I want to do is, um, create a copy off that existing models project. So the existing models project is this easy to models project part two. I'm just gonna copy and create a new part, and I'm gonna rename it as basically is he toe workspace workspaces project and let's go ahead and do some clean up in here. So I want to delete the state files. I don't want this particular file here. Okay, so now this is in a clean state. Now let's open the power so prompt and inside Partial prompt. Let's goto this CD easy to workspace project. OK, now we are here in the next thing that I want to do is open up my project in the sublime text and inside this you can see that you have you have this easy to workspaces project that we have created. So now let's go into the main and clear out this model because I just want to create one easy to instance like So now we have the product structure ready and we are now ready to create the works basis. Now, usually when you're creating a ah big infrastructure project, I would suggest to you toe create the workspace first and then slowly bill your environment . But for in this example, we're going the opposite way because we already have the project and we are creating multiple environments on and then we'll accommodate the court accordingly, so OK, so let's go ahead and create our workspace. So to create a workspace, you need to be in that particular project, Fuller, where you're executing the terra form and you need to execute this particular common, which is called terra form workspace. New because you're creating a new workspace and you have to give it a name. So I'm gonna call my, um, environment staging, and you can see that you have now created environment called staging. And, um, your workspace is now selected as staging. Now, I also want to create other workspace call production. Right. So I'm going to do terra form workspace, um, new production. Right. So you have no staging, and now you have production. So firstly, I want to show you the list off all the environments that are created here. So to do that, you can do terra form workspace list. Now, when you do this list, you can see all the environments that are available here. You have the default environment. That's the default when you create any terra form file and, um, you have created a specific environment called production and you have created a specific workspace called staging and you can see that there is a small ass trick here which tells us that it iss Ah, I just this, um workspace, which is currently selected. And it is being used now to switch between workspaces. All you have to do is run this commander of homework space, Select staging. Now you should see that it switched to the workspace stating, Right? So let's go ahead and work in this particular environment first, and then create a resource and then switch the environment and create other resource. And we'll see that how you can create multiple resources in different environments with the same terra form file. So let's go ahead and switch our, um, clear This, um, partial here. And let's go ahead and write some court, which gives us the capability toe detect which workspace that we're working on right now. So here I'm going to show you a concept off local variables. The locals variable is nothing, but you can have some special variables that are Onley toe this only related to the specific module or specific file. So to declare locals variable you can all do is locals, and you have to open close here and inside that you just declare some variable. So in this case, I'm just going to do ah ah environment. And this will called the value off. What workspace We're currently active on Soto Get which workspace we are currently active on. All we have to do is terra form dot workspace. Now this variable will give back Ah which workspace we're working on and it is being assigned to environment. Now how can we create multiple in multiple resource is with the same um, terra form file is basically you need to configure your project in innovate such that it's all controlled by variables and all the properties are chosen based on a specific value like this environment and then that particular values being assigned as a property to the resources that are being created for that environment. So I'll explain that to you by an example. So let's say now you're creating these easy to model here and let's go ahead and edit the security group model right? And inside the security group model, what we can do is we can take the name here, right, and we can say that we want to give variable Oh SG under school name and and here. What we can do is instead off this hard cored and name. Here, Weaken, give dollars. Bardot SG underscored name. Right. So now what we have to do is we have to supply this name from from an external source, which is where the model is being called. So I'm gonna say SG named equal to is G specific. Ah, security group. Easy to we have to given environment. So how do we call this local environment? All we have to do is we can do dollars, and we can reference it by saying locals dot um environment. So Ah, this is not locals. This is actually local, that environment. And, um, we're going to do the same thing for the easy to instance as well. We're going to say you see toe instance underscore we're gonna call again the local dot environment. All right, so what we're trying to do here is we're creating to re sources, which is our security group and are easy to instance, and both are are different models, and we're saying that we want to create names that are specific to a specific workspace that we're working on right now. So if we are choosing a staging environment than when we execute. This will get the security group a security group, easy to ah, staging, and the two incense would be easy to instance staging. Similarly, when you execute the production, you'll get this values as sGC to production, easy to instance, production. So let's go ahead and run the terra form and see the output and, ah, let's get started. So I've saved this and let me go to the telephone project. Currently, we are in already in the staging environment, the way you can confirm that issued by running the command terra form workspace list, and you can see that you're currently active in the staging environment. That's clear this and do a terra form in it. So now when you do a terror for minute, it initialize is and includes All the models are do you have declared, and once the plug ins are downloaded and ready, you can go ahead and on your telephone plan and apply. So let's clear it from here. It's still terra form planned. You should see that it's creating to resource is, and if I'm not wrong, you can see that you already got the name sGC to underscore staging Tough. Uh, you can see that easy to instant staging Now, this has been computed in the real time. I mean, in the run time when you when you selected the specific workspace. Now we can do telephone apply. And when you're applying, it will actually tell you that you are in the staging environment. And you you want to apply these changes. Yes, I want to apply. This changes. So it typed in? Yes. And now it's going to create this Easter. Two instance not pauses for a second. And once it is ready, I'm gonna come back and show you how it looks in the console colic. So now we how our resource is created. Let's go too easy to console and check if there actually created. So let me refresh this. Ah, council here. You can see that the EEC to instant staging has been created. And when you select that and you can see that the appropriate security group is also now created, which is easy to ah, security grow PC. Is he do staging? All right, so now we have our staging environment set up. Now. We were sure that everything is, um, created according to the plan. Now let's go ahead and push this to production, and the way you will do it is basically going to your Terra Form project folder and you'll select their form workspace. Select production, and you can see that your workspace is now switched to production. You'll do the same thing again, terra form in it. Now it's initializing the models, and you can do terra form um, plan. Now you see, it's creating two fresh new resource is because there's the properties are changed and you're giving different imports here. Now you can see that the names are sGC to production and easy to instance production. Now you can go ahead and do telephone apply, and then you can apply the change. And again, I'm gonna pause this and then come back once it is created. All right, so now these production issue two instances also created. Let's go back to the console and very five, we got the new instance or not. So let me open up the is he doing since console so you can see that easy to instance, production is also created and you can see that appropriate security group ste SI to production is also created. So this is how the workspaces work. And you can basically use the same terra form script to create multiple environments tax so that you have a consistent environment. Ah, I mean, you have a consistent infrastructure across environments created and it is easy for you to maintain and managed them. So that's pretty much it about the workspaces. Now I'm going toe show you how the Terra form state files are maintained in this works basis concept. And in this next in the next lesson, then we'll see many more tips and tricks that I have learned in my experience, which are not available directly documentation. So don't miss those parts. So let's go back and check how the terra form state files look like. Now you can see that, Um I mean, let me goto this part so you can see that Ah, here you have to reform docked DF ST dot de Right. In the previous projects, you have seen that the Terra form state file is directly under the root folder. But here you have the reform dot Kiev ST dot the folder and inside that you can see that there are two different folders which are staging and production right, and each workspace has its own terra form state file. So any resource changes that you create for that specific workspace are tracked in its own specific data from state fights. So that's pretty much it for this lesson. I really hope that you enjoyed this lesson and I'll see you in the next one. Thank you so much for watching. 23. 4 7 EnvironmentSpecific local variables: Hello and welcome back to another lesson in hashtag landing courses. And in this lesson, we're going to look at what eyes environment, specific local variables and how to create them. Now, as far as I know, there is no documentation related to this. I have tried a lot off enough did. I've done a lot of trial and error toe figure this out for myself in my use cases, and I just wanted to share this because this hack will really help you or in, um, creating the environment specific local variables. Now, let me give you in a use case, you where you can use this concept. So let's say you have a, um, have three different work spaces like Staging Dev and Production, and you want to launch three different easy to instances with different Am I ID's now? How do you specify, um, which environment will use a specific A My i d. So that is what we're going to solve here. So let me, um, open up the project and let's get started by solving this problem. So let's go into our project. So I'm going to use the same project that we have used in the previous lesson. We already have staging and production workspaces created for this project. Now, let's go ahead and create the local variables which are specific toe those environments now here will also be using the concept off the function cord. What do you call this function? Okay, so now here we are going to use a concept off using the look up function in your local variables, and I'm going to show you how exactly it is done. So first thing that we're going to do is in our previous project, which was easy to workspaces project. I'm going to my main dot Terra form folder and in here in the local variables, I'm gonna create a variable called a my I d. Now, I'm just going to ah, create these variables, and I'm just going to output them for this for keeping this example. Ah, to the simplest form. Right. So the way I'm going to declare the variable is basically I'm saying, am I I d underscore environment. And inside this, I am going toe, create a map off different variables which are related to different environments. Now, if you remember correctly, there is three environments that are present. I mean, three workspaces that are present, which is default, staging and production. So for default, I'm just going to give a value saying, Ah, let's say my i d is some am I idee underscore default. I'm just making things up here and we have staging right equally do You can write a my Heidi underscore staging. And we have production he wanted to in my i d underscore production. Right. So we have created a map off variables for a my i d underscoring Wightman. Now we're going to create another variable called letter. We call it a my I d. Right. So you're saying we want a my i D Toby resolved, right? So the way we were going toe do it. What? We're saying it. Well, look up in this particular in my i d environment for the value which matches this environment, right, So we have our workspace is created with the Senate with this names staging and production , and we want to use the look of function so that we supply saying that Oh, we want to look up the particular map variable for this particular environment. So the way you'll do is you'll do dollar open close and you have look up function. And inside this look of function, you're going to say local understood local dot My i d underscore our score environment. Right, comma. And what do you want to look up for? You wanna look out for the environment itself, which is going to be local dot environment. So here we have open and close the braces and everything looks correct. And let's go ahead and output this particular variable here. So what we can do is we can say output, um, environment specific output variables. And inside this, we're going to say value equals local 0.0, no, not like this. Open double coat inside that dollar. Local guard. We're going to use a my idea. Now, let me explain this to you again. So what we're doing is there are putting the value off local air. My i d Now in in. In the real life example, you would send this a my i d to a specific ec2. Instance. And, um and depending on which workspace you are the heir. My I d will be fetched either This this artis right here in your example, it would be the really my i d and the city. Instance we will use that plastic. Am I? I d the savior pulling it out. It's like we're referencing it. Toe this local variable and this local variable will resolve to one off these based on the local environment, which is our terra form workspace. So let's go ahead and run this and see what variable will get back here. Now, let me open up my power shell again and we are in the same project, actually. Here, let me clear this and let me do terra form workspace. Select. Um, Let's go the staging first. All right, so it's switched to staging and we're going to run to the farm. Ah, plan. You should see that there iss Nothing. Toby changed because we didn't change any off our infrastructure. There, terra form. Apply now. You should see the output variable that we have printed there once it is done. All right. So you can see that environment specific output valuable here is returning us the am I I d underscore staging now let's safe. We clear this and do terra form workspace select production And let's so tear form apply again. There's no nothing to change here. It should again show us that the environment specific variable here is pointing to the production one. So you can see here am I I d underscore production. Now you can apply this concept are toe many different variables. You can have shared variables shared variable module, and you can import that more deal in different places. And you can you start concept toe basically share variables across different, um, more guilt and across different environments. So I really hope that you enjoyed this lesson and you apply these tips and tricks in your project and let me know if you have any questions so that I can answer them for you. So that's it for this lesson, and I'll see in the next one. Thank you so much for watching 24. 4 8 Env specific Shared Vars Acrossmodules: hello and welcome back to hashtag learning courses. And in this lesson, we're going to see how toe create shared environment variables, which can be used across different, more deals in terra form. So this concept is basically an extension off what we have done in the previous lesson. Now we will create environment specific variables, but we'll also see how we can share these environment specific variables across different models. So let's get started. So again, I'm going to use the same project. So I'm going to open up. Ah, this particular foreigner where we have workspaces project and here I'm going to create a new model. So this new model will be our share. Variable smart you'll and you can use this more jewels import this model in different, um, different other competent subcontinent off the main project, and you can share those variables across. So one off the use cases that I can explain to us. Let's say you have, um, a BBC created O. R. A. Um, trying to think what's the best example? Let's say you have set of resource is created vpc security groups and am I ID's. And, um, you want this information to be available in different, more jewels off your infrastructure. So how do we create this? Like, if we create this in Maine, local variables, then you will have to end up, uh, passing this from main variables. Toe the to the specific models, or you'll have toe. Either Let's say you're you're creating a model which is a part off different projects, right? Not just this project and different projects. And you don't want your main file Toby in putting those variables for you. So in those cases, the shared variables concept will help you a lot. Um, again, this is you won't find this information out there. This is something which I have figured out on my own trying to experiment my in my use cases. And I really think that this will help you guys to kind of organize your project. So let's go ahead and get started. So I'm gonna create a new folder in here and which will be my new model, which I'll call it a shared underscore wars. And inside this, I'm going to create a new telephone file which is going to be shared underscore war Start TF. Right? So, yes, I want to change this. Now, I'm going to go back and open up the, um, open up my project for the here. All right, so now our shared wars, um, module has been created and ready to use. Now, let's go ahead and change your code so that we can create some off the shared bars and use it across different models. So what I'm going to do is ah, let's use this concept off using this local environment and, um, will use the same concept from here. Right. So let's copy this part. Actually, let's let copy this entire part from here and paste it in here. Now, this local environments terra form workspace will be propagated toe all the model. So you don't need to worry about it and hear what I'm going to say is, um, entered off using the am I I d. On a school environment? What I'm gonna call this is he see toe instance on the school name environment, and I'm going to use the same name here and all this the same thing. And here I'm gonna call this nasty environment. No, to make you understand what I'm doing here. ISS basically we are saying Ah Oh, no. We have to kind off and we finish this up so that I can explain what I'm doing here. So what we are doing here is using the ah, no, actually, let me do something else. So let's Dio because we want toe provide an example where we can leveraged this across different models. Right? So what I'm gonna do is environment underscore suffix right? And we can call the same thing here in 11 suffix underscore environment kind of religion and name. Just take this off. Here, take this bucket Here, call this this and we're gonna call it this. Right? So what I'm trying to do is basically created environment suffix which will written back saying, ah, staging and staging and tried. Right. So let's do this. And what we're going to do is s O. This is just like what we have done in the previous example where we have ah, a local variable which is environment suffix. When you call this very well, it is basically doing a look up on the local environment suffix environment map. And here it is looking for ward over the local environment is so the environment, this map to that workspace that you are selected. So if you're on staging, it's going toe. Map it with the staging staging map inside that variable, and it is going to assign into the environment suffix and hear what we're saying. It's like we want to output environments affects. Ah, and the value that we want to give It is basically the local environment traffic. So that's how we were exposing this particular environment specific variable to a different model, Right? So let's see how we can go ahead and leverage this particular are put variable in other models. So I'm going to now go toe the, um, easy to models. I mean, is it a model and changed a bit off court here? So instead off. So instead off importing the EEC to underscore name from here, What we are going to do is basically will important the shed uars module into this particular model. So the way you will do it this using more do and give it a name, we're going to give the reference name the same name as the model itself, and we have to give the source the source is Basically you have that shared wars, Mardell. Like one step about this. Ah, about this folder. So what we have to do is go dot, dot, Slash. And you have to specify the name off the model which is shared. Underscore wars. Right? So now your model has been imported and you want easy to name variable. Toby declared So in the previous examples, I mean, in the first example, we have taken this as an input from the main Dottie F. Now, instead, what we'll do is we'll say readable. Ah, Underscore. Uh, no. You're going to say default equal to dog. Inside this, you have to do a dollar close. We have to reference to more jewels that share underscore wars dot And when my time to score suffix. Right. So what we're saying Yes. We want to go fetch the suffix from Ah, this shared wars and we want to upend toe the name off this incident. So we're calling easy to underscore name underscore Instance. Right instance. And we're changing the basically easy to name here. Tag value. Right. So that is pretty much done. And ah, the other thing that I want to show it's like how we can use the same variable in another model. So let's go to the share security group here and let's call it the SG name. And we're not taking this as an input and we can say default equal before this, we have to import the model. So the value of importance again more do give it the reference name shared underscore bars . Inside this, you are going to specify the source, which is one step about from this folder, and it's under shared wars. And once you are imported, you're going to give this the name s S g underscore. Um I see. Underscore name underscore. And you're including the farce. More deal more detailed. Our shared underscore wires underscore. And what? Not in wire Montaner score suffix. Right. So now you have this name. Now, as these names are changed, the security group will be recreated. But the easy to instance it will just be renamed with our previous resources that were created. So the other change that we have to make is in the main dark TF because here Ah, we don't want to specify this input variable anymore, right? And we don't want to specify this SG name anymore from here. Right. So we took those two things off. And now let's go ahead and run the terra form, uh, in the power shell problem. So let me clear this off. Now, what we need to do is first thing is to run a terra form in it because you have added new models to your project, so you have to do it there for minute. Call it. So there's something wrong that we have done. So it's saying variable SG named Default may not condemn interpolations. All right, So Okay, so what we'll do is it's complaining that we should not give default equal toe something. All right, so we can do one thing. We can directly applied this name here instead of diverse. Right? So we have easy to instance, name shared more deal wars, and we can just get rid off this variable from here. And we can do the same thing for security group modules here so we can take this name and instead, off name here, we'll just take it off and just save it, right? So that should be pretty much it. Now, let's go back to our power shell. Clear this. Run the terra form in it. Okay, now we don't have any errors. We can do telephone plan. Now, we should see that the EEC two instances updated and the and the security group should be recreated. And it should be district. Yes. So that's what we see. So we're destroying the security group and re creating it. And we are changing the easy to instance, if you see we are operating the tag to instance name changing. This is the new name that we have given it, and we're give will be giving it the new security group idea when once the security group ideas created and it will be assigned to this. So what I figured was like this would fail on creating the security group because, um, there should be at least one security group assigned to the east to instance, and we're trying to delete and recreate that security group which would create issues for us. So what we're going to do is, um, instead off deleting and re creating it. Ah, what we can do is ah, out of his show. This example. Right. So So what was the previous name that we were supplying here, right? So let's try to replicate the same thing. So? So we were giving SG underscore. Easy to write. So let's do the same thing here. SGN or score easy toe. And inside this Ah, it's too. That's u S G underscore e c two and begin modify these guys so that it gives us for production. Right? So now if we go toe the, uh you see to model here, I mean security group model and let's get this year and give the name here. So there should be no change because we're using the same exact PVs one. So now if I go back and run this terra form their form planned, there should be only one. Ah, change with just the easy to instance optation off the tag. And I'm still seeing from course history to perform s G underscore. Easy to underscore in wire moment suffix. Right. So environments affects here is giving us staging, so oh, they use upper case lower case, right? So that's why it is creating a problem. So now if I run this again, I should see only one change. All right, there we go. So So the issue here Waas. We didn't want to recreate the security group because it's every easy to instance. Need to have at least one security group in place because when you're operate the name off , the security group tries to destroy that and recreate the security group, which were not be possible because it wouldn't it couldn't delete the security go because it's already assigned to BC two instance, so it has to detach it. But there's no other security groups and it will fail. So what we did was like we we hacked our cord so that our environment suffix would give out the um, we will give out the same name, like as it was there in the previous example. So once we do that, it it's it's working. Aceh expected. Now we can do a terra form apply and and something yes, now are name off. That easy to instance will be updated. Yes, so that has been updated and changed. Now we can cleared from here and we can do terra form workspace, select production and we can do terra form plant. And now again, you have to see just one change here because we're just updating the name off, the easy to instance, and you should see that the instance name exchanged for me. C. Two instance production to BC to name incidents production, and we can do Terra Farm apply and give it a confirmation off. Yes, elect. They also bought The resource is in Cuba, and I mean in staging and production Have bean changed. Let's go back to our easy to console and verify if those changes of are reflected or not. So let's go back here. And if I refresh, you should see that the name should now be updated too easy, too. Name instant production and stating. So this is how you can have shared variables concept separated in a model, and you can reuse that share variables across different models with your project are across different products. So I really hope that you enjoyed this lesson. And if you have any questions or if you think that Ah, I did not explain any specific parts off this lesson. Clearly, you can ping me in the course, and I will be happy to explain the concept to you. Oh, are like clarify your questions offline. So that's it for this lesson, and I will see in the next one. Thank you so much for watching 25. 4 9 section conclusion: Hello and welcome back to one of the lesson in hashtag landing courses. And in this lesson, we're going to do a quick recap off what we have covered in this particular section. So in the section off terra form course, we have covered a lot of ground on advanced topics. We have started with ah, looking at like what more jewels are. And then we have created our first module and we have then created multiple more jewels. And then we had seen how to provide inputs to the models and how toe share the values that are created in one module and exported toe. Ah, the person who is calling I'm in the their form script which is calling it and passing that information along into another model to kind off create the dependencies. And after that, we have covered what works basis are how you can create different environments using the workspace concept. And also we have covered a lot of ground on how you can create environment specific local variables and how you can create a shared variables concept and so on and so forth. I really hope that you enjoyed ah, this particular section because most off this is all, um it's not covered in in the actual there from documentation, and I cannot figure out a lot of these topics by kind of trial and error. Wei and I really enjoy sharing this information with you all because I'm really excited that you'll be using this in your workloads. And, uh, let me know if you have any questions related toe these particular section and I'll be ableto answer them through the course of So that's pretty much it for this particular section in the next, Less in the next section we're going toe Ah ah Create the whole production in production level infrastructure using terra form, I'm going to show you step by step, how to create, like we're going to create the network. We're going to create the to tear our texture, and I will give you more details in the next sections introduction part. So that's it for this lesson. And thank you so much for watching and I will see in the next one. Bye bye. 26. 5 1 ProjectIntro: hello and welcome back to one of the lesson in hashtag landing courses. And this is going to be a really exciting lesson because we're going to discuss about the AWS project that we're going to build using the Terra form. And you're going to apply all the concepts that we have learned so far in the course. And we're going to see how toe create a production grade infrastructure with multiple environments using the terra form. So in this lesson, I'm just going to give you a walk through off, like what are different components that will be creating using terra form and how the sample infrastructure is going to look like and the architecture diagram offered. So first thing that we're going to do is basically we're going to use a default BPC, which will be created in by default in every AWS region. If you have an AWS account, every region has a default vpc and before sub nets created for you. So you don't have to worry about creating the new network set up and so on and so forth. If you re introduce so you can actually go ahead and do it shouldn't be ah really difficult . If you want more information about how you can provision in a production level infrastructure, I have another course. You can go and check out in my courses where you'll find, like setting up production infrastructure in AWS. And I've also put in the a lot of terra form material there in that course as well. So for this project, what we're going to do is we're going to use. Like I said, we're going to use the default VPC and default subjects which are already created and the route tables and everything. So we're not going to do a lot of network set up. The only thing that we're doing in the network part is basically creating the security groups. We're going to create two security groups. One is for the load balancer, and one is for the easy to instance, that the example application will be running. So that's one thing. The second thing is, we're going to create an application load balancer, and we're going to create one target group and a listener associated with it. When, when we go to that sectional all kind off like expand on like what are the subcontinent's are required in that particular model, so you don't need to worry about it. And the third thing that we're going toe create is the launch conflict with user later. So basically, this user data is toe, um, specify what commands it needs to run on the boot time and the launch configures basically a platform where you'll create the configuration and give it to the orders killing group, which will be creating in the next step. In order, Scaling Group will actually use this launch configures template off like what the artist killing group needs to launch and all the properties like which instance with am I and so on and so forth are actually supplied in the launch conflict. And we'll be using that with the Auto Scaling Group. And once we have this entire set up completed in one environment will boot up the production environment. I mean, we're we're going to create two environments. One is staging and one this production. And when we create the staging environment, we're goingto do step by step, step by step, step by step. And at the end, what we're going to do is like just run the same infrastructure for a new production environment and we're going to see how it is managed. So here is the reference architecture that we're going to use for this project. So this is how it's going to look like when everything is created like a sad we're not going to create the default. Vpc I mean the VPC in the network part because the default VPC is already created in every AWS account and in every region, and the default cabinets are also created for us. So for the purpose off this project we're going to use Ah, I mean, I'm going to use the Oregon region. You can your Frito oh, use any region that you would like to use, So that's pretty much about the architecture. So let's get started. So I'm really excited toe complete this AWS project because this will give you a complete exposure off how you can handle a complex infrastructure and how you can model arise your infrastructure into different, more deals in terra form and how you can a manager ah, project easily end in the effective eight and in a maintainable way. So I will see you in the next one. Thank you so much for watching 27. 5 2 ProjectSetup SG Setup: Hello and welcome back to one of the lesson in hashtag learning courses. In this lesson, we're going toe do our first part off the project where we're going to first set up the fuller structure for our project and the base mortals that we needed. And you're going to create our security groups. And also we're going to set up our first workspace. We're just going to be our staging environment. So let's get started. So the first thing that I want to do is go to my course folder and create another project here. Right? So I'm going to name that project as AWS going to call it a double yes course project. Right? And inside this I want a main doctor TF Terra form fight. Now, like we have seen in the previous lessons, this is going to be our main terra form fight. Right? So once this has created, then I want to create a module called ah Shared wars. And this is just like what we have used in the previous section. So I'm going to create shared underscore Let's use Dash's revue stash, or did we use Ah, um under underscore in the workspace project shared underscore war. So we're gonna use the same thing here just to be consistent with what we've done so far. So shared underscore wars and inside the shared underscore wars we're going to create on the telephone file, which is going to be shared. Underscore wars dot Now the shared underscore uars will hold the variables like the regions or submit i ds or the VPC i d and A my i d and so on and so forth. So we'll just create a shared wars here. So the next thing that we want to create is basically a networking model trite. So inside the networking, Marty, let's go ahead and create the security groups that are required for this particular for this particular project. So I'm just going to call it network underscore Mardell. Inside this, we're going to create another terra form file, which I'm going to call it network underscore Margie, right? How the extension should be not DF. And so the next thing that we are going to create here is basically a Ah, Okay, So let's create the other models when we get to that point. So for now, I think we should be good enough because we have the share of ours and we have the network model, and we can actually get started. So I'm just gonna open up this particular folder inside the sublime text. So let me pull this up here. File open, not file. We won't open the project. Ford er, opening this project. Okay, so now, dark, this is open. Now, what we're going to do is inside our main dot Theophile We're going to basically create a provider. So the provider, how do you provide it? Basically, you call it provider, and you open close this place, and you're going to say the, um you have to give the provider name with this AWS, and I'm just going to use the same profiling that I've used so far, so I'm going to give a profile equal toe. It's rotten dash terra form course, And I'm going toe. Specify the region as, um I think it is us west toe a. But let me just double check real quick. The region that we're working is Ohio, so we'll have to quickly recheck, uh, we checked the region. So it's us East. Dash us east to Holly. So that's going to be our region for this particular project. All right, so now that we have supplied the project Ah, I mean, the AWS provider profile and region. Let's go ahead and keen Some shared bar so that we can use for this particular product. So the first thing that we want is ah, the V p c i d. So to do that, what I'm going to do is I'm going to set up the local variables here, right? So like we have seen in the previous example So we're gonna call it locals and we'll have environment variable as Terra formed art work space. Right. So that's what we're going to fetch from the workspaces. And here we're going to say vpc Ah vpc I d underscore environment equal to, uh, this is going to be a map. Right? So inside this map, we're going to have ah default equal toe something staging equal to something and we have production equal to something, right? So let's fill in those values from are easy to console now. Like I said, every default environment will have. Ah, I mean, every default vpc would have been already created in every AWS region only after do it's like goto services and VPC section and under three pieces. You should see your default VPC which is created for you now what I'm going to do, it's like I'm just going toe copy this week P c I d. And I am going toe based it here now for the purpose off this project we're going toe host are staging and production environment in in the same BBC. In your case, it might be different because usually they separated out. But I don't want a war complicate by creating all the network competent here. And it was really not the scope of this particular project. So I'm just going to leave it aside. So we have this local environment and the next thing that we have to do is we have toe, have a look up function declared. So this is going to be the look up. So the look up is goingto be basically under double courts. We have toe open up this and we have to do look up in inside this we have to specify local dot vpc i d underscore environment. And inside this Oh, there shouldn't be any uh, equals So they're so local dot vpc i the environment and we want to find the local that environment and map it to him. So that's one thing. And we want to also ill put this variable as output. We want our output. This has vpc i d right. And we want to give the value equal to ah, double coats. Give this ass three pc local dot vpc idea. All right, so we have our first environment. I mean, first local variable created here. Similarly, we need to create Ah, the sub net submit ID's right. So you want to choose the sub net? Holy. So here we need public sub net. Let's call it the BMC Public sub Net I d. And let's give the same thing here. This is going to be public summit I d. And this is going to be public. Some notoriety. And here we have toe get the public submit. I t. So, basically what I'm going to do is like by default. There are three subjects are created. I'm just gonna choose, like, ah nb as my public submit and the private submarine, so I'm just gonna call copied this. I D, which is to a Toby the public's of net and so copied this guy, this two tier street Here, save it. And I'm gonna call this as private sub Net I d. And I'm going to use the disputable here, here and here. Right. Okay, so we have to copy the sub net to Toby. I d. From here, and I'm going to paste it here year and here all it. So now we have ah BBC i d public submit idea in private subject i t. And the next thing that we would probably need is ah, let me think about it. So we have vpc we have public some night. We have private some night I d And what else do we need for the security group? Ah, I think that's pretty much it. So what we're going to do now is go to our network module, right? And we have to create two security groups oneness for Public Security group and another restive private security groups. So what we're going to do is now, ah, go to our previous project and I'm going to copy paste the security group model that we have created in the previous part, and I am going to copy this here based it, and I'm going to replicate it, right? So we have No, it'll be a security group being created and we have the the name should basically I mean, this is the reference name, so we're going to give it public SG, and we're going to call this five. It s G and, uh, ingress. We're going to say from port, we just accept traffic on port 80. We're gonna try. Ah, except the traffic. Ah, yeah. TCP port. Right. So, TC people 80 and we want toe. This is basically Public Security Group, so it's gonna take in from everywhere, and egress is basically again for 84 80 and TCP toe everywhere. So this is going to be our public security group and waken give the name ass, uh, public s g o. We have toe into our environment. The sharing of are smart, you'll hear first. So the way you'll do its module shared ah, underscore wars. And inside this, you're going to give source equal, too dark, slash, dot, dot, Slash Because you have to go one step about ah and fetch the shared underscore bars from here, and you can actually get the ah, you can actually get the That's also output the oh, in the oh, In the previous step, we forgot to output the public and private SG. Uh, well, use not the STS. I'm in the sub net while you're so we're gonna go give it, um, public sub net. I need. And we can give here that this is going to be a private sub net. I d. Okay. And we want I'll put the environment variable to right so we can call it, uh, environment suffix. And we can call it local dot environment. Right. So we have all these things being output from here. Now, let me go to my ING network module and here I should be able to get model share, wars and environment suffix. Right. So that would be created here. Description is public security group for load balancers. All right, in, uh, we can give the environment suffix again. Here, we can call p this guy, and I'm going to paste it in here. You can take Public Ministry for l B. All right, so the vpc idea. Right? So we have to get the VPC idea again from the shared wars. So again, I'm going to copy this particular part, which is more The Lord share worse. And the BBC I d Let me just quickly check from shared wards of this week. P c i d. So, Yeah, so it's going to fetch it from there, and this should be now created a public issue. So enough for private SG. What we want to do is we want to accept the traffic from just this security group. So egress would be outside to everyone on port 80 port 80 TCP to everyone and egress. Port 80 80 and the, uh, instead off cider blocks. I think this will be security. Uh, groups, security group. Let me quickly double check in the telephone documentation. What the uh what the So being open up the from ill. Let's look at the darks. Go to the providers terribly us and look for the security groups security group and we have toe search for P C. I. D. Name value on this is the data sources we want. So you want this hate earliest security group rule and inside that we want to be resource security group. Yep. So you want copied this security group I D And we want to congrats from there. So here we will supply saying that. Ah dollars. So dollar aws security underscored, group dot This is going to be public s chief dot idea. Now, let me explain you what I did here. So basically, what we're doing is for private SD that which is going to be attached to the load balancer . What we're going to do is we're going toe, create the security. Uh, we want to just allow the traffic, which is coming from the public. Esteve it is going to be our load balancer, and we want toe all Put it for everyone else. So this is just like a security measure. And, um, the name would be again. I'm just copying this part so that you can easily replace this part. So I'm going to call it Private SG. This is going to prive. It s G for E c two and this is going to be the same, uh, resource here. So I think we are pretty much in good shape with the security groups part long. Let's go ahead and execute this right so to do that First meaning to include this module inside our main rtf. To do that, what we have to do is more do, um we want to include network 100 score model, and inside that we're going to give the source equal to dot, slash network underscore more like. So now we have everything being set here. The next thing that we have to do is open up our power shell. Ah, let me open it up. So all it's over here on the scores directory. We need to go to Seedy AWS Fraud. Yes. Project that what we call eight of yes, course project. All right, so I'm gonna clear from here. So the first thing that we want to do it's like she did the terra form workspace. Right? So I'm going to do terra form workspace new. I'm gonna call it staging. Right. And I am going to create their form workspace. Ah, no, I'm just gonna do a telephone in it. It's going to initialize. All the models that are that are included here, and it's going to dull, nor the AWS plug in, which is required for this particular project. Okay, so another data form is initialized. All we have to do is do telephone plan. Now, you should see that the two resource is being created. Ah, Private SG Invalid known key security group. Underscore Idee. All right, so let's go back and fix that particular piece. So this is going to be ah, in the network model. I think we did something wrong here. Security group I d. Right. So lets me go back to the documentation here. A security group I d toe allow our access from on the type cannot be specified. Okay. Source. Security group idea. Right. So when we see if there's an example here So what is this kitty group rule? Oh, we're not getting security group. We didn't security group rule here. No, this is just a security group, so I think we copied from the wrong direction. Wrong place. Okay, this security group, this is the data source. So we have to select this guy and inside this ah, cider rocks prefixed list. ID's should also have protocol security groups. Right. So this should be inside the list. My bad. Sorry, guys. So this should be a a day off security groups that you can allow right? And now let's go back and do the Terra form fine again. Hopefully there shouldn't be any enters. All right, so we're now creating two security groups. And let's go ahead and do terra form. Apply and type in. Yes, all right. So now our security groups are created in our sick staging environment. Let's go back to our AWS console and just verify that if our security groups appear here or not, so I can go to the easy toe service and under the under the network and security issued. See security groups like that. And you should see that we have created a private security groups staging and public Security group stating, and you should see that the public security group has rules 80 inbound and 80 our bond, and we have the private staging private security groups staging with this, just taking the inbound connections from this public security group staging and it's going toe allow all the traffic out born from this particular instance. So I think we have covered a lot of ground in this particular project. Um, we have completed our network model now, as and when we the required more information. We'll be adding to this project in the next lesson. So that's it for this lesson. In the next lesson, we'll go ahead and work on creation off the load balancer and target groups. So I will see you there. Thank you for watching. Now, if you have any questions, you can always send a message to me on the course. And I will be happy to answer all those questions. Now I'll see in the next one. Thanks. 28. 5 3 ALB TG Listener Setup: Hello and welcome back to another lesson in hashtag landing course is now in the previous lesson. We have covered a lot of ground in our AWS project. We have set up our fuller structure. We have created our workspace and also we have created our shared groups model. And we completed the security groups part where we have created two different security groups for public Security group and, um, private security group and one is for you'll be and the other is for the easy to instances . Now, in this model, we are goingto go ahead and create a model for our load balancer and we're going to create all its dependencies. So the list of components briefly are basically the AWS application load balancer followed by AWS Extra DP Listener. And then we're going to create a oh, you're going to create a target along with that. So let's get started. So the first thing that I'm going to do is go ahead and create a model to create a model that's like what we have done in the previous examples. Go ahead and create a new folder within the same ah project folder and I'm going to call it as, um load, balancer. Underscore Model. You can call it whatever you want. Which fits You are Ah, use case. I'm goingto make another telephone file here is gonna call it load balancer. Underscore Model, right? Oh, I missed the extension here. It's going to be dot t f Now I'm going to go back to my sublime a sublime text here, and I'm going to open up this particular fight. So let's go ahead and check out the terra form dot io site toe. Get all the information that we need for building an application load balancer. So here's my A terror farm site. I'm going to go to the document provider AWS. And let's search for the A l B. Right, So it's going to be easy to resource. A l B. Right. So let me open this up in new tab inside that here's an example Off. Right. So let's just copy this spot from here. All right? And let's go ahead and paste it in here. So So this is the eight of this. L B hiss is an application or banter. Aws a l b. Did we open up the same one 18 of Yes, that will be okay. Suppose it's called. It'll be here. Okay, so it says here it's application load balancers. So let's go ahead and headed this particular part. So that data, it fits our needs. Right? So we're gonna call reference this as our sample app underscore L b right and the environment specific name. So even before right starting to include the environment specific names, what we're going to do is include our shared worse model, which we have treated, So I'm going to do more. Do shared underscore wars. Give it in double coat. I'm gonna call it shared underscore wars. And inside this, we're going toe. Give the source equal to again that that slash Because you have to go toe one level up, right? Once you have that, we can give the name as sample up underscore they'll be underscore. Give the environments effects. So it's going to be shared. Underscore war start. Oh, no. This is going to be module dart shared wars dark and why I went underscores suffix. So they re called it and wildman suffix. Yeah, environment suffix. Right. So we're saying internal is false. This just which means It's not an internal load, balancer. It is exposed outside and up. Load balancer type is application load balancer, and we need to specify the security groups here. Right. So to get the security group I D. What we need to do is we have created a security group in the network model, so we have to output that security group. Um, we have to output that of Heidi from the network model, and we have to supply it as an input from our main model. So let's go ahead and edit our network model toe, actually output them. Right. So we are going toe, um, output, the let's all put both private and public because we might need it in the next part. And we're doing our skating group. Right? So let's do output. Ah, public SG underscore, Heidi. Right. And we're going to give it value equal to ah dollar. This is going to be eight of us security. Underscore group dot Um, public SG dot id. Right. So let's copy the same thing from here and paste it here and rename. This s private as G i d. And I'm going to copy this here and paste it here. Right. So we have these two output variables now it's going to call public SG i d. And Private s reality. So in the load balancer model, we basically need the public s tree because it is the external facing. So I'm just gonna call this guy as I mean. Well taken input as price public s g underscore. I d and open close. When you when you supply a blank here, it's going toe. Treat it like an input variable. Let's put it to the top so that it's well formatted. Call it. So we're going to get this as the input. Right? So here, um, the security groups, we need to just give this ass oir dot public SG underscore idea. Right? And the sub knit ID's. That's what we want from the shared group. Right? Fare wars. So shared wars. We want the public submit idea, which is our public sobriety. So we can copy this. We can go back to our model. We can say, Ah, this is basically module dot shared underscore bars, Dr. Public Separate Idea. So we got the sub net i d. From here and we got the security groups idee here, and we want to enable the deletion production. This is like to prevent from accidental termination. It's going toe. Delete any application, Orban answer. You have to go back and disable this production and then go and daily just to be sure before you're deleting anything. Now, for the sake off this example, we're not doing the access lock. So I'm just deleting that part. And I am going toe have a environment specified here as attack. Um, and we can call this nasty, whatever the environment suffix that we have, right? So it would be either staging or it would be a production environment. All right, so I think we have Ah, a good, um I mean, good starting point as our application load balancer. So the next thing that we need for this application load balancer, let's go ahead and run this before we go on and confirm like everything is working. Fine. So the next thing that we have to do is go to the main dot TF and here. What we have to do is include the module. Uh, what's that? Lord Valentyn load well and, sir, underscore model and source. He called to start slash Load, balancer. Underscore Model. All right, so we have this part ready. Ah, and we need to supply input. Right? So the input that it is expecting ISS the public S G i d. So go back to Maine Public. Esche Idee. You'll be getting it from the, uh so here you have. Ah, the Mahdi old dot network Underscore module dart public SG underscore. Right. So you got the public s reality from this network module. Supplied it as an input in this. Ah load Balancer. Martin takes it as an input here and everything is set here. So let's go ahead and execute our turf form. Cord. Clear. This first thing that we have to do is initialized or project. OK, Something is wrong here. So it's saying unknown root level key public sthe OK, so I think. Yeah, so we didn't specify that it's a variable, so we need to specified variable and clear terra form in it. All right, so our model is now initialized clear from here. Do it tell from, uh, workspace Select staging. I think it's were already in stating right. So let's do a telephone plan. Okay, Lord Balancer module overly Alfa. Numerous example app underscore. A l B sample happens call only all from in the name right. I think it's not, uh, liking the underscores. Let's give the hyphens and see if that accept it. All right, there we go. It's actually, um, accepting that hyphens instead off underscores eso We have a low default and come off, the important we have supplied. And now let's go ahead and apply these changes. So we going to do to form apply, and we're going to say yes and confirm it. Holic. So at least two sub nets in two different availability zones must be specified. Telephone. That's not automatic legal back. All right, so I think we've got a problem here. At least two sub nets in two different availability zones once we submit. Okay, so Mm. All right. So let's use the another subject, which is one. See Right. So we'll use one see, as our, um, sub net to right. So let's go to our network model and not network. My deal. I mean, the shared wash and Publix. Let's call this public seven. It I d one. And let's also create the Heidi two. We need to supply it here as well. One to. And we need to Ah, public sub net I d to make this as one one i d. One. And we need another public, some notoriety, which is going to be a public something tidy too, uh, to public some great idea too. Right? And we can fetched thes from the, uh, three pc model. Go to your sub net. Now. We've already used one A as our ah, I mean, to a as our public security group one on. And we've used to be for our private ah, security group. So let's use to see for our ah public sub net. Do right. So let's go ahead and give the public submit value s this guy and maybe place this here. All right, so now we have these things created. Now, the next thing that we have to do is, uh but did we use public submit itis anywhere in our next Mardell public? Submit I d. Because she be had a All right, So this is a vpc level things, so we don't need to worry about it so we can go to our shared wash. I mean, the load balancer. And here Ah, in the sub nets, we can give one more summit here and have probably submit one. And we'll have a only submit to All right, so now if you go ahead and run our farm plan again, enter parsing load balancer A 12 1 seed of five. So 12 I wanted to fight off. Missed this. That will coat there. Now you should see the advance of being created Clear from apply some play? Yes. Oh, it's so it's taking a couple of minutes to create it. Meanwhile, let's go to our console back and see if something is getting provisions. So if I go to my, uh, see too service and go to the load balancers, I should see something coming up. All right, so my sample app will be staging is being provisioned now. That's why it's taking Ah, a minute toe actually create the load balancer because it is still in provisional state. So now that this is being created, let's go ahead and start writing up the other dependencies that we have, Ah, that we need to create for ah project work properly. So the next thing that we need is basically the listeners. Now, if you see here, we don't have any listener. Right? So we have to create a listener for this particular application load, balancer. So let's go to our telephone documentation, and you can see that there is something called oblivious. Underscore LB, underscore Listener. Let's open up that documentation and see how to create a specific listener. Right, So So we have some example here. Um all right. So let's just grab one off the examples here and modify it to fit to our needs. All right, so I'm going to copy it, and I'm gonna call it. Ah, I'm gonna call it TDP listener eight. Right, accent, because we were listening on Port 80. So the load balancer Aaron here would be a lovely asunder core lb dart. Uh, this name, right? This is an email, Far Lord balance of reference. And the Aaron and the port would be STD p iss on 80 and the protocol would be scdp. And, uh, we're just going toe keeping one of the security SSL policy is just leave it there. We don't need a certificate, Aaron, because we're not doing extra DPS. If you're doing it through GPS you can go to certificate manager, create a, uh, ACM cert for your specific domain name. And once you have that sort ready, you can key in your Aaron into this particular block here. If you're doing extra DPS now, we're not doing https Soviet. Just doing that part and the next what we're doing, it's like we have a default action. Oh, which we need to supply Target group. Oh, actually, my back. So first we need to create the target group. Then we have to create the listener. This is completely my bad. Don't get confused. This is not that off a big deal. All we have to do is now commend this out. So I'm gonna comment, comment all of this out, and we can go ahead and create our target route first. Now, before that, let's go and see if it's completed. You can see that the socials are successfully created here. And now let's go ahead and check out the target group. Ah Oh, Target two documentation in telephone. So there we go. So here's the target group. All we need ISS to specify this particular guy Copy this example based in our model right and I'm going to call it STP. Sample up. That should be target Target two. All right. And I'm gonna call the same thing here, but I'm gonna call it sample app Bash. That's 30 p dash target group. And we needed a port 80 and it's GDP, and we need the VPC, right? So where do we get the VPC already from? We have it from one you'll dot shed worse shared. Underscore wars dot the PC idea. Right? So we have that. And let's go ahead and run this and see if we got our sample target. Who created or not? Meanwhile, you can also go ahead and check the other properties that you can specify. I mean, the health check stuff like this. Ah, or we can just leave it as default. The before health check is anyways, the root level. So I'm just gonna leave it as is. If you want to specify anything specific to your target group, you can go to the Terra form documentation and figure it out from here. All right, so for this example, I'm just gonna leave legacies, and I'm going to go to the power shell, clear it from here, do it at a farm. In it again. Clear it. Reform plan. Now I should see that you are creating a, um, target group. And it is being attached to our of application load balancer that fear. Davey, attach it? Yeah, we are attaching. Ah, no, we're not attaching it to any load balance here. We're going to attach it through the http listener, Right? So we can just do terra form apply, and I'm gonna supply. Yes, here, all it. So the target group is now created. Let's go back to our AWS console and see if that target Group s created. So if you see any C two under load balancing, you should see target groups, and you should see our new target group has been created. And you can see that there's nothing registered to this target. And the default health checks are fruit level, and we have some basic monitoring being provided here. All right, so the next thing that we want to do is go toe this farm and a NCAA meant this listener that we wanted toe, Actually, I should have used the We have to a form here as she carb. Oh, Maybe you can just leave it like this anyway. So inside the, um, inside our floor balance of mortal, we created our lister model. I mean, listener actually be, um, listener Haiti in were attacked. Streeto are simple. Sample up here in and we're using bunch of default. And here default action is basically were far wording the all the request to this particular security, this particular target group. Now, the baby reference to this is we just call this guy from here and call this guy not Aaron. Right. So once this is done while we have to do is go toe are former again clear from here to reform plan, I should see that a new load balancers listener is being added to this particular load balancer. And we can just do terra form. Apply here in supply. Yes. Okay, so there's some problem with this, So Yeah, So we're just doing http listener, so we don't need to specify the SSL policy because it's not. That's true. TPS my bad. I've taken it out. Clear it reform plan again. And let's do the terra form play again. Okay, so now the, um listener has been created. Let's go back to our AWS console and see Ah and verify forestry PS. It's ridiculous. Investment created. So yes. So my sample app will be staging in this, um, sample up will be staging. And listener, it's actually be 80. And we have the target group as sample habits. You tip it. Okay, so the one mistake that I think we've made iss not giving the name of it the environment specifics. So let's go back and fix it because it is really important for us to manage the naming convention here so that we not messing up the, uh, the maintenance off this particular product. So I'm gonna supply it fit, dollar open, close and more dual dark shared underscore bars on dot environment suffix. Right. So we're gonna head the name here. I think when we did the name off a target group, it's going to recreate the target group and and call it So I think we can go and do it on a phone plan again from apply. So we're seeing that there's one being changed, one being added and one being destroyed because we have to update if you destroy and recreate the target group and we have to operate our load. Balancer, Scdp listener with the new target group that we're creating. So I'm just gonna do terra form, apply and supply. Yes, um, it already leading a target room because he's currently being used by the listener. So how late the baby you need to fix this problem is were the first remove the listener, right? So we can do that by committing this out. Because this is a dependency on this. It cannot delete it because it's already being used here. So it has to deliver this and recreate that. So now if we go in front form plan, it's going to know delete to resource is and had one new resource. Now, what we can do is now un commend this again and after farm plan, and I should see the new listener being created. And you can do terra form. Apply the reason we have taken the pain to go ahead and fix the name here. Because it is really important to maintain the naming convention right when we're doing it in the beginning phase itself. Because later on, if you go ahead and change the name off something to make it all consistent. When your production lords are running, it will be really difficult for you to oh, change them because you'll be disturbing the current production environment and it's really messaging. I've bean there in that situation, and I will never, ever repeat the same mistake again off like bad naming convention and then regretting in the later point. So always make sure that you have your naming convention right in the first place. So now let's go back to the AWS console and look at our target roof. We have now staging specified here. Sample up its GDP target troop staging. And, um, we have our Lord. Bands are created and ready. So we have all the confidence that are required in the Lord balancing model, and that's pretty much it for this lesson. I I understand that this is really long. Listen what it is really what it to go through the entire part off this, and I'll highly recommend that you create these resources along with me to be able to practice. So if you have any questions, you can pick me in the course, and I'll be happy to answer. So that's it for this lesson, and I will see in the next one. Thank you for watching 29. 5 4 launch configuration: Hello and welcome back to one of the lesson in hashtag landing courses. And ah, in the previous lesson, we have completed all the application load balance or set up by creating the L B. We have created the target group and we have also created the listener for extra DP in our staging environment. Now, in this lesson, we will create the launch configuration which will be attaching Toe artist Killing group in the next lesson. So let's get started. So the first thing that we have to do is go ahead and open up our project folder. And inside this we want to create another model which is going to be a order scaling model . Right? So I'm going to create a new folder and I'm going to call it auto scaling. Underscore more deals. All right, so inside this model, we have to create a new terra form file, which is going to be also auto scaling. Underscore module dot DF Now, once this is created, I'm going to open up the sublime text. So this was our project file gonna close all these models because we don't need a tow moment. I'm opening the order scaling model. And the first thing that we want to create is basically a launch configuration, which we want to use it in our order scaling group. So let's dive into our uniform documentation and search for the eight a launch configuration. All right, so we want toe chooses this issue to resource issue under a C to resource is where you have to select the AWS on the school lunch on the score configuration. And here, uh, you convey, basically, see, third, there is an example. All right, so let's copy this example here, and let's taste it here. All right, so let's change some off the names here. First. Thing is, we need to include the module, which is our, uh, which is our shared underscore bars, right? And supply the source. So that fetches it. It's one level up shade underscore wars like this part is done. We want to configure my ab sample. Half underscore Elsie and systems for launch conflict and the name that we want to give iss sample app The underscore Elsie underscore from the shared wars. Let's fetch the share more. Dool dart shared underscore war start environment underscore suffix All right, so we got Start now. We need the am I I d. Right. So we can configure thes two inputs in our shared wars and in the shared wars we want toe add one more variable, which is going to be environment specific. Right? So let's call this in. My i d underscore environment in a copy it here. All right, So am I. I d We're going to fetch it from our credibly sec to ah section. So we're going to go to the AM I thirsty majors? Yeah. So, under images, there's a Mayes and owned by public Kamajors. It's a prior it. No blick Amazon. It's hard to find from here The easiest way that I will. I usually find it us. Go to launch instance and I want toe select this. Hey, am I? I said this in my atrium. Know this We we want this might let me just this guy and let me paste the m o here. Now, in our case, the am I the base a my ideas. Same for production and staging. So we're gonna leave it like that, but for the instance, type All right, so we can choose the instants type is, uh, instance type you can choose score environment, too Dark micro t two dot micro and for production. Let's use t two dot medium So now we have got our instance type and are am I i d and ah, let's go ahead and input those variables in tow. This particular the majority here. So we're gonna say, Oh, before that we have to go to our shared wars and I'll put these very what's right. So I'm gonna go toe output variables and copy them two copies. And here I'm going to say in my i d local dot here my i d and same this is going to be instance that's going to be instance type. So I'm a quick check if you've got that right. So instants type should be just this instant stipend and there should be display. I am why I d should be just in my i d. This all it's over. A fixed those small issues there. Let's go back to order scaling module. Call it. So now we have are the launch configuration basic parameters. But I also want to give it Ah, the security group. The what do you say the security group, the, uh, the CBS volume and so on. And so far. So let's see if we have any more example here. And also, we want to specify the, um, user data here. So So this horse launch config this. Is there anything here? Any of us. So we have the image i d we have the name prefix Instance. I am role. I'm not giving any of the old here, but we need to create the key name, right? So to supply the key name first, we need to create it beforehand. So you have to go to our AWS issue to console in our high region. And I am going to create a keeper here beforehand so that it is handy. I'm not going to use terra form for this, uh, key pairs. Okay, The key Peirce's here. We want to create a new keeper. So eight of yes, project Terra form keep. All right. So I'm gonna create this, and I'm gonna save it in our that saved in our of course, in our course for order here. All right. And we have Donald at that, and we just need to give it to keep their name. Uh, that's the one thing. Let's also create hit of yes, project a terror farm. Keep a staging right and save it here. Let's did it. The old one. Yes. I didn't do the naming. Right. So I'm going to create a new cape Air eight of Yes, Project TF. Keep it production. All right. And I'm gonna save it here, showing Fuller. I want to delete the the one which doesnt have probably. All right, so we have docked. So once that is completed, what we're going to do is we have to create the shared wars for that. So I'm going to copy one of these blocks and create the keep that name right. Okay. So you know what of these are really not shared variables because it you don't usually use . Am I an instance type and keep your name in the, uh, in the what you call it in across the model. So I'm just gonna cut this out from here, and I'm going to declare them directly within the within the hardest getting model. So let's create a locals here. Alright. And environment. Equal toe. Ah, daughter. $2 close to farmed are towards space. And here we can't kind of have these variables set. And the key. Better name we have to just create here. All right, so keep your name. Oh, no, This is underscore N Y Rent. And we have We have the keep in names as staging on and production. All right, so this part is no set. The one thing that we have to change here iss we have toe get the environment suffix that we can get from, um, either shared wars or you can even do local dot environment. Right. And, uh, here the image I write the image i d should be local dot my i d and your variables The instance types should be local dot uh, instance type And also, you want to specify the key pair. So let's go back to the Terra form documentation. So we need the key name. Right? So we'll give the key name equals dollar local dot key name. Keep that name, actually, keep in, so keep it name, and we also want to supply the user data. Right, so we can supply the user data. Ah, let's see how this is being so quiet here. so user on the school data. All right, so the user data, we want to create a file in our project directory, and we want to basically refer, um, opened the file in the terra form barracks. So I'm going to open up the, uh what is killing module? Go back once level up, we can create Ah, new folder here, call it user data and are we can call it maybe assets, because it's one of the asset. And so this asset we can create a Ah, you'll text file, you can call it user data. Txt. And inside that, I'm gonna have a bunch of comments. All right, so those commands are basically me pulled us up. I've already written a few commands which we're going to use us, the user data. So it's going to be just these commands which will have the default Petri site for the Times. Only likes a my page being served at Port 80. So we're just gonna use this as our use of data. Now, the user data is basically it iss. It is the initial bootstrap scripts that you can run whenever you are launching a new instance. So that you don't have to go in and configure it manually. So my user data is basically set here, and the next thing that I'm going to do is go back toward our farm file here. And, um, the way you it called this is basically ah, you're gonna say dollar open close inside this, you're gonna save file and, ah, files, you have to open up and you have to give it a final name on the file. Name is, um, basically the user data part. Right. So the user data part is actually a relevant part here. So we're gonna go one back level up, and we're going to go to the assets and we have toe give it user data dot txt. Right. So once we do this, our user data is Nokia dead. And I think you've got pretty much everything that we need it for. The launch configuration. Um, I think one other thing that is missing is the security group. Right. So you have to give the security group so security groups ah, and secular groups would be a day off items here so inside that we just need to give the security group so you have to take a security group as an input no more. So you have to give a variable private Ah, private security group, our school Rieti. And this will be output it from our network model. And we have to import it through the main model into this particular hardest killing Mordor . So here what we have to do iss Just refer to it as and give it watch dog. Uh, what's it called? Private S t score 80. Right. So now the year having aws launched conflict sample up so everything is set here. One thing that is left is basically including this hardest getting model in our route model and supplying it with input off the private security group I d. So we have to do auto scaling underscore model. And inside this, we're going to give source equal toe start slash Porto scaling underscore more jewels, and we have to give the private security i d equal toe again. We have to get this as an output from the network. I want you dot private security group fighting. Right. So once this is stunt, the next step is to go to our partial prompt clear in the waiter a form in it. Now, if you have any others, it's going toe pointed out here. So far, so good. No errors. So let's clear this part that do enter a farm plan and let's see what we come back with. All right, So there is one error, actually, so it's complaining about file opening. Dot, dot, slash assets user data dot txt. The system cannot find the specified, but so we went back One part one file when directory up and it would give it the right name . Actually, user data right user data dot txt and assets. This looks right foot to me. All right. I think it might be complaining about the ah slashes here. Maybe. Let's try this and let's try to run Telephone plan character escape 38. It's tradable slashes. Uh, so silken figure out this So asset is S E t s. Yes, that user data dot txt user data dot txt That's it. Slash We're getting once level up and referencing it. That's the asset. Oh, maybe we just need to give assets Stashes of data dot Txt. Let's try it out. Give it this. All right, there we go. So I think what it is doing is, um, taking the conservation from where it is actually running this script so it is related to the root. Oh, are the main telephone file. So we just have to give assets slash user later. Rt extended. It was taking it. So let's go back and run Terra form plan again. We should see that one resource is being created, which is our launch configuration Canoe Terra form apply. Oh, let's quickly make sure that we're giving the name with staging. Yes, so I can see that the name has staging as thesis affix. So I'm good with it. So let's create it and enter Yes and yeah, So the launch configuration has now been created. And now we can go back to our, um he Cito console and go to the launch configuration section and you should see a new launch configuration which was created by the terra form so you can see that sample app Elsie underscore stating has been created. Let's quickly verify for user data was executed properly. Yes, So the user data has mean read properly from the text file, and everything is created properly, So that's pretty much it for this lesson of you have completed our launch conflict creation and I will see in the next one. So in the next one, we're going to create the artist killing group. Ah, and let's see how it goes. So that's it for this L C in the next one. Bye bye. 30. 5 5 Autoscaling Group: Hello and welcome back to one of the lesson in hash tag landing courses. And in this lesson, we're goingto go ahead and create the orders killing group, which is the last piece off our infrastructure. And we're going to use the launch confusion that we have created in the previous lesson. And, um, start booting up the PC two instances at the end of this lesson. So let's get started. So the first thing that I'm going to do is open up my sublime text and, uh, goto the terra form dot io site and search for the order scaling documentation. So I don't want the data sources. I want something in the, uh, e c to resource A section, right? Ah, yeah, And a receipt to resource is you should see the aws underscore or the scaling underscore group. So we're just going to use this and here we can copy one off the examples. So, looking for what example would be good with the simplest version because we don't want toe go ahead and create all the policies and so on and so forth. All we want is a basic Ah, we want a basic resource off artist getting group. All right, so I think this particular example would be helpful for us. So let's paste it in our auto scaling model. Right? So once we're here, we don't want to call it Barbie. You want to call it? Ah, sample app. Underscore a SG and the name that we want to give this a sample. Hap underscore a SG underscore. Let's give it, uh so module dart shared underscore war start, um, environment underscore suffix. Right. So that makes sense. Going to give maximum size two men size one. And ah, I think I think we can make this as the local variables, right? So instead off using maximum and the What's the desired I think we need the desired size as well. Let's go back to this documentation and search for desired capacity, right? It's called desired capacity. So we have to do Oh, you gotta need desired capacity. So instead of hard coding these let's also take this as the environment specific variables because, um, it's always better to have in 11 specific variables for, ah, for stuff like that so that you can have more control over which environment has how many instances, right? So you don't want to hard code them. So begin. Replicate one off these and call it is This is Fresh Man desired Min and Max. Okay, let's call this SG desired and going to give this name this and you want to call going to give, uh, decided one certain one production we want to. And for this this is SG men, right? Issue men? Uh, yes, Jim men. And we want to copy the same values for the minimum. Right. And for Max, you can call this SG Max, and we can call this max issue max. And here let's copy the palace from here instead. Off one. Let's do maximum tool and Max room for for product. So we'll have ah one and one as minimum on desired for the staging environment and for production, we want to instances as minimum and for as the maximum for the auto scaling group. All right, so I think we have the variable set up properly. Now. All we have to do is assign it to them. Here, we're gonna call our dollar open close and inside this we're gonna call local dot SG, understand? Tasty men is that meant Yeah. Min Max and decide. And we're gonna copy the same thing. Oh, this is the max, right? So we have to give Max men, and this is going to be the is she desired parts of the large configuration name. We have to fetch it from the previous step. The previous stepped along plans configuration was sample and score. Elsie, sample up. So we will give the same thing here. Launch configuration that sample app dot name, and we need the VPC zone identity fire right zone. Island fire is basically the which order scaling group of which submit zone that you want to use, So oh, so zone identifier iss. Basically, we want to supply the for Blake SG now. Public submit idea. Now we need the private submitted because we're launching the easy to instance here. Right? So we can get it off this and we have to give a module dot Shared underscore wars dot Private sub net. The baby that's verify from shared wars. If we're in putting the right one, we have private summit. I'll write. So I think we got that one right in the tags here. We can give the name tag and the value tired. We can have as sample and underscore. We can have dollar. Um, module dart shared for shared underscore war. Start in wild rents, effects right and propagated. Launch? Yes. And we can also have n wife meant you can have again the same value from here. So in a copy it from here gonna baste it here. And we don't need all of these interpolations and all. So we're gonna save it here. All right, so So we have the auto scaling group. We have the launch configuration, we have the identity zone. I didn't fire where we want to launch DC two instance, and we have the min and Max set. Oh, and we have referenced our launch configuration that we have created in the previous step. So I think we're pretty much set here. Let's go by head and execute it in our partial, prompt and see if we are able to launch the new easy to instance or not. So ah, let's go to our partial. Clear it Here, Do it in a form plan. Let's hope for no winners. All right? So it is creating our or the scaling group and let's try toe do this writer farm apply. Remember, we're just creating this order Skilling group with, like, the defaults and like the basic properties being set here Now, in your case, you might me to ADM or stuff like default cool on period or termination policies are you can add the lifecycle hooks and you can have order scaling policies. Um, scaling alarm, skating, notification center on and so forth. What was this project? We're not going to add any off that. You can check all off the that information in the, uh in the data from documentation, so you don't have to worry about it. So I'm just going to supply Yes, here. And once I do this, we should see that the new auto scaling group is being created. The reason why it takes Ah, um it's delayed here is basically it tries to launch the instance first, and once it is launched, then it's going to come back with saying the success message. So I'm just gonna pass it here and come back once the instances up and ready. All right, so now artist skating group has been created. Let's go back to our AWS console and see how it looks like and check. We'll check it out if our ah SG has launched a new issue two instance or not. So I'm gonna go back to our AWS Easy to control. I'm goingto go to the art of Skating group Now I should see a new waters killing group being created here, and we can already see that there is one instance desired. Ah, and Min and Max being set to our our properties that we have set here. And you can see in the instances section that it has launched a new easy to instance in to be bitches are private zone that we have chosen. And if I goto this easy to instance now you should see that it is being booted up and off. One replace that we have to check is going to target group and see if this easy to instance has Bean assigned to this target group or not? No, it won't be assigned to this target group because we haven't specified attaching it to this target group. So that's one issue here. So let's go back and fix that thing. So all you have to do is go back to our scaling group here and we need to supply the target group. So let's go back to our documentation search for Target Group A rinse. Right. So we need to supply this target group, er and and we have toe and I give it here. And we need to fetch this from the ah from the from the load balancing section. So I'm just going to use this as an input variable. So variable de g underscore Aaron. Right? And we're going to input that here as dollar open toe darty g underscore Aaron, once that is done now you have to go to your load balancer, and you have to output that variable from this target group. So the way you can do it, ISS create a output variable Here, calling naming TG underscore, Aaron. And here you can see the value will be this particular thing. Target group Aaron, they should be in there double courts, so double coats is done. Now, once we output this, we have to input this into the ah or the Skilling module. Your so t g underscore. Yaron merely confirm if that's the right valuable. So go here. T J underscore Aaron City underscore Erin equals again. Dollar module dot network underscore module dot DJ underscore here. Right, So one start is done. Ah, we have to see that if that runs properly on our So let's clear this. Do a telephone plan. Mm. Dd underscore is not a lead. All right, so let's go back to our lord ransom arguments. Look at what are output. So we have our all put off didn't give it in the double coats. That's why complain about it. So Right, so we've saved this. Now let's go back in. Oh, still it is complaining tg air. And it is not a valid walked off, more deal network model. Oh, no. I made a mistake here. It's not a network model. It is a auto, uh, load. Balancer underscore. Margie. Right now, if we go back and do a telephone plan, the target group Aaron should be a list. All right, so we made one more mistake that's cleared here. So this is expecting to be as a list inside the what is killing. So all we have to do is sup late as an Audi saved it. Let's go back and try one more time to a farm on. All right, there we go. So now it's being modified, and it is attaching it as a target group to the artist killing group. So let's do it on our farm. Apply in supply? Yes, as conformation. Now, once we do this. All right, So one fundamental mistake that we have done here so far is we need tohave the availability zones matching with where we've I mean, the art of scaling group available the zone and the load balancers available. The zone should be matching even though they are in different subjects, it doesn't matter, but zones are actually important and it needs to be matched. So what we can do is like, we can go back to our network model and fix them and make sure that ah, everything is a line, and then we can start using this. So all the after do is instead off. Using this, um uh to be zone, we have to just use one off the to A or to see zone so that it starts using this. So let's go back and fix it. It's very easy. All we have to do is go to our go to our terra form here, and you can see that the zone identifier will be after do it's used the public sub net one . No, we don't have any public or private created in our network set up because we're just using whatever the defaults which are available. Usually you create public private Ah and, um public private and DMC within the same two. Available the zones and you basically have different subjects created in the same zone so that it's all a the all The traffic is flowing in the same zone rather than it is about them going cross on and creating problems. So all we have to do to fix this is changed. TV PC Zone. I didn't fire toe public submit one, and we just have to relaunch the instance or that it starts seeing the traffic, and that's pretty much it. So let's go ahead and clear this. Run their telephone plan. It's not a valley resource from public subject. Want I said not valued one shareware public submit. I anyone All right, so it's probably some net. I need one. Let's go ahead and none this. It's going to update it I want to say that a farm apply. I do. Yes. Okay, so that's being applied. Now, another thing that we have to do is to launch a new issue. Two instance. So all we have to do is change the men and desire to zero so that it terminates. And then we'll will relaunch the instance. Form applies. So we're like terminating the existing one and will re launch a new instance now for play? Yes. Okay, so now it's Bean turned to Zito. If I go back to my console here and check in the artist killing group, we should see that the C two instances being terminated here go here. You should see the instance is being terminated. Not sure whether to instance came in from Oh, maybe it has come from our previous execution. So let it. Let's just do a full refresh in C If you have any instances left. Okay, So what are getting tormented? So let's go ahead and, uh, change our values back toe one and the execute terra form so that new instance starts coming up, making new terra form apply and, yes, information. Let's just give it a few minutes and ah, let's go, toe. Ah, instances, stab. And I see that the new instance has come up into a And now let's go to our target group and see, for instance, is registered here. All right, so we can see that in targets. Okay, so this saves it is unhealthy. Ah, so I'm not sure why this target group is still unhealthy here. So one thing what we can do is, like, go ahead and debug what's going on in the instance itself. So if we do that, we have to go to the instance. All right, Now we have to see whether we have able to get it 200 response back from the easy to instant or not. But we have locked our security group so that it's not allowed for, um, access from outside. So first we have to go and fix the security group de Buck, and then we can again close it back, using the Terra form by running it. So I'm just temporarily opening the http port to everything just to debug. And now I can go back to my instance, select the public. Uh, I p and run it, Huh? So I do see that my page default page has been loaded, but somehow it's not being registered as the, um, healthy target. So let's inspect this guy and go to the network tab to see what response we're getting. If I do a refresh. Ah, so for some reason, this is returning a 403 This is a default page. I'm not sure why it is straightening 403 That's why it is not being registered as a healthy target. So also, I see something here from the old balancer, which is, I mean, from the instance which is giving it toe wondered back. So maybe we can use this. Asked the health check instead off just a default. So let's take this and let's fix it in the, um that you start as a health check in the target group, right? So what we can do is we can go back toe our uniform, and we have to go to the Lord balance or module. And here in the target ah, target group. There should be something called health underscored check. I think our health underscored checked. Let's quickly verify it. In the target group, it's called Health underscore. Check. Yeah, that's right. So health underscore Check is basically this. And let's go ahead and do it on our farm plan. Ah, health check. Should be a list. Why would health check be a list here? Ah, health check. This is a target group sample target group. Why would help Check blocks are documented. Oh, health check. It's a block. Okay. Health check and target type. Okay, So health check blocks, so health check is a block, and we need to give all these information in to that. Right. So we need to give Ah, the we need to give health check is basically a block, so it doesn't have equals here. And instead, we need to give it the, um, part variable equals, um, can actually give this the spot. Close it here. All right, so this will be my part, and I can say inter well, equal toe. I want to check every five seconds and, uh oh, Time out. Time out. Time out. Equal toe. Let's call. Let's give four seconds time more time. What should always be less than the interval? We have the healthy underscore threshold equal to let a to in unhealthy t underscores threshold according toe before. And let's make this 10 so that it doesn't go too quickly. All right, so now let's try to run our terra form fam. All right, so it is now reverting back our security group, and it is adding these ah, properties toe the target. So let's do it from apply and let's see what happens now. Yes. So our changes have been applied. Now, let's go back to our target group and ah, do it quickly. Fresh here and see for health check. Got updated. Okay, so I got up there to Jeff here, which should written back, uh, the 200 back to this. We have to wait under like, fuel. A few runs off this? Yes. So that it reports back 200. All right, so after a couple of refreshes, you can see that the target has now being marked as healthy because we have 200 coming back from this particular part. So that's pretty much it. So now we have ah launched an easy two instance using the order scaling group, and we have registered the particular easy to instance to a target group, and we have debunked are easy to instance by opening up that security group, um, for for temporary debug purpose. And then we figured out the issue. We fixed it. And once we're on the same terra form again, it actually, um what are all of my security group changes and got me a clean state. All right, so one last thing that we have to verify s by going into our load balancers and, um, by browsing the load balancer Deena's and check if our app is being responded on this particular Dennis. So I've copied the URL. The browser. Alright. So yes. So we do get back the response from our load balancer, you are so this Ah tells us that our project is now complete. So that's pretty much it for this. Ah project. We have garden all our competence created. We have got the art of scaling. We've got the load balancer, Target group and the oh and the in. The entire project is now complete. So the last thing that's left in this particular project is now spinning up the production environment using the same script. Now, remember, you've got so many problems when you were creating staging in wiring because that was the first time that you were setting it up. So if you were to send it up all again manually, without the sterile farm script now you might encounter many other problems with many other manual errors. Now that we have everything scripted in terra form and it it's like, um, created using the works basis, you can just create the production workspace. And as we have already keyed in all the production variables, it is as simple as creating just a new workspace and spinning up the entire environment. And I'll show you in the next lesson how you can easily spin up this copy off this environment in within few minutes. So I'll see you there. Thank you for watching. 31. 5 6 Production workspace: Hello and welcome back to hashtag landing courses. Now, this is going to be our final lesson off this particular section. So let's get started. So in the previous section, we have completed our AWS project by creating our artist killing group and the, um, and putting up the instances and fixing various issues that we had with the availability zone issue and then the health check issue and so on and so forth. And finally be very fight it by browsing through the load balancer you are So now we have completed all these steps in our previous lessons in our staging environment. Now is the time that we have to launch this for a production system. And to do that for a production system, all we have to do is basically creating a new workspace for prod and run our terra form script and see that the magic happens that you have replicated this entire environment with just one single command. So let's go ahead and get started and run that particular thing. So total, that first thing that I have to do is go to my Terra Farm folder, the power shell prompt here and we're clear on from a previous thing. Now, after the later form workspace new and call it production Lepic quickly verify in the variables whether I call the uppercase P or lower case P. Um, best way to check is to go to the shared virus and see that. Okay, it's a lower case P right, So it's new production and then select, hit, enter. And once it is created, you can see that the workspace is now switched to production. You can verify that by running terra form workspace list, and you should see that you're currently running the production environment. All right, so now the next thing that we have to do is run terra form in it. This is going to include all the models that we have created so far, so there was no problem. It created it included all the models. I'm clearing this next thing that I'm going to run this terra form plan now you should see that all the resources that we have created previously step by step in staging environment that now are created in one step. You can see that there are, like, 70 sources that are being created when it's the order skating group. We have the launch config. We have the sample up l b and we have the listener than we have the target group. Then we have the private security group and the public security group. So let's go ahead and run. Apply this. Changes to reform. Apply. And yes, I'm enough. Pressed a wrong key here. So I ask you this. Do it Terra form. Apply in type and yes, All right. So now our resources are being created. Really? Just give it a couple of minutes. All right? So after a few minutes, the ah, all the resources were successfully created. Now let's go back to our AWS console and verify all our resources are properly creator or not. So the first thing that I'm going to do it's like go back to my AWS console. Goto, the easy to in first thing that we have two very far is if we had our security groups created properly. So inside security groups. Now you should see that privatised reproduction in public, etc. Production has been created. And after that we have to go to our load balancer and see if we have a new Lord banter created for production or not. So yes, I do see your new lord Bands are being created and under listeners we should have extra TP listeners and the listener shirt. Forward it to a production target group. And if I go to target groups, I should see a new target due for production. And we should see all our health checks that we have configured in staging Environment should be applied to the production as well. And the next thing that I'm going toe verify it's going to the auto Scaling group and see if the instance is now launched or not. Yes, so you should see two instances being launched and the maximum should before. If I go to the incidents a stab, you should see two instances are created. Now, the one last thing that we have to check is going to the target groups and see if the targets are registered. Um, so the ah, I mean, if the instances are redistricted, the target group or not. So if I go to the target, you should see that two instances are registered and their mark healthy, and the one last thing that we have to check is going to the load balancer and browsing the load Balancer, You are ill and see if we got getting If you're getting back at a sponsor knock. So I'm gonna open up a new tab and use this. Now you can see that sample app production is also working properly. And this is how you create your terra form project toe. Maintain your infrastructure so that you have one specific terra form script and you run it across multiple environments. Now that's pretty much it. Now we have completed our project, and I really hope that you guys enjoyed building this particular project. I know this was a lot of hands on and I really increase you all toe. Um, follow along my, uh, lesson and, uh, create the resources along with me so that you So you get a lot of practice doing this type of stuff and it will really help you in your career. And also it will help you toe manager infrastructure in a better way. So that's pretty much it from this lessons perspective. One last thing that I wanted to mention was that I'm going to upload this entire project into the course resources so you can download this entire set up and you can change your valuables. Oh, and, uh, you can basically reuse my template to create an infrastructure in your environment. So that's pretty much it for my side. And if you have any more questions, you can always ask in the course. And I'm happy to answer everything. So that's it for now. And I'll see you later. Thank you. 32. 6 1 Course Conclustion: Hello and welcome back to the conclusion part off terra form course. And I really hope that you enjoy it. Ah, and learned a lot in this particular course. And if you have any specific questions, you can always ask them in the course and I'll be more than happy to answer them. And for the next steps, I would suggest you toe check out my other courses. They are like, I mean, if you if you are really beginner in AWS, I have a course for absolute AWS beginner scores. And if you are a little bit off grants user off AWS than I have a course where I have taught, like how to set up all the component in the three tier architecture er and also some off the terra form bits and pieces there. If you want to learn specific topics like s ST Cloud friend, I have a course for that. And also, you can check out my a deadly assassin and scores if you are interested in that particular piece off AWS. So, um, final thoughts. If you have any questions, hit me up on the course and I will be answering them and I really hope that you continue your journey in learning the cloud technologies. And that's it from my side. Thank you so much for watching Bye bye.