Session-1 : AWS, Terraform AWS Demo - Create VPC & Subnet

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hi welcome to terraform tutorial series in this video i'm going to talk about what is terraform and i'm going to show you a couple of examples using terraform terraform is a weapon source tool using which we can automate the provisioning of resources work cloud for example we have different cloud providers like Amazon Web Services the bluemix assure Google cloud this particular tool supports multiple providers and using this tool we can automate the provisioning of resources for instance you wanna launch if it instances they want to configure nad gateways or Internet gateways subnets or IM roles users so instead of doing all these activities manually we can completely automate that process using terraform let's get started so before getting into the examples we need amazon web services account we need install terraform on the system on the laptop and we need to provide programmatic access to terraform i already have an account with me i let me get into i am let me create a user adduser you so I am creating this user to provide access to terraform so under select Erebus access type we need to select programmatic access which is going to give us access key ID and secret key we are going to configure this access key ID and secret access key to the to the laptop where we are going to run terraform set permissions so I am giving admin access to this user the first one here I'll review this and create the user so after creating the user we get access key and secret key so we need to configure this access key and secret key to the laptop where we execute terraform let's open the terminal and configure this access key and secret key via a double use command line tool so try AWS configure it will ask you for the access key get the access key here it lasts for the secret key grab secret key from here klasky for the region I am working on us West to region I'm typing the same here the output format I am keeping it as none by default it takes Jason as an output format here to run this year double UCLA we must have installed this a double UCLA for more details check AWS documentation open this link and you can see the process of installing UW's command-line interface tools so just go through this and get it done the next step is download and configure terraform tool you let's check for turf um download go to downloads so we can see terraform distribution for different operating systems here you can see it for Mac Linux and Solaris windows and other operating systems here so please download the binary distribution based on your platform in my case I am using Mac OS I downloaded this particular zip file this is a JIP file it is not executable file this ship contains dot exe so download it unzip the file once you unzip in case of Mac move that file under user local bin and this file will be in path automatically and we can use this command for running our telephone programs it is not a executable file it's a it's a kind of script so we're it just unzip it take that file move it under this bin directory in case of Mac Book and in case of other platforms check the documentation so once it is done we should be able to use this telephone command let me check the version of terraform yeah they're getting some information about the version of the terraform so it says the terraform is properly configured on this machine the next step is we need to choose some editor for writing terraform code so in my case I'm using atom in your case you can choose any editor it can be a very simple notepad or any advanced editors you like let's create a separate directory where we are going to do terraform examples let's sit into that so let me open this directory in the atom as I said earlier also terraform supports multiple providers when we work with terraform we have to define what is a provider in our case we are going to use terraform on Amazon Web Services let's create a file for that so we can choose any arbitrary file names but the extensions must be dot here so I'm giving the name as provider it can be any other name of your choice provider edible yes this is the syntax of terraform to define the provided details let me show the documentation I always recommend referring to the documentation while working on any kind of task let's go to Google let's search for telephone provider let's directly get into this universe provider there see the usage so provider is the key word here and the name of the provider is a double yes we also can pass access key and secret key why are this so in our case right we have said this access key and sacred key where command-line interface terraform is going to use the same access key and secret key for interacting with our AWS account let's copy-paste the same code but in our case we can ignore this access and secret keys because it's already configured and we need to specify the region obviously terraform is going to provision the resources in this region i want to choose less ways to so this is the syntax of terraform for defining the providers so the provider we can think of this one as a keyword name of the provider and these are the attributes of this particular resource next I want to define couple of resources like this I want to create a PC using telephone so for that the syntax is to use resource so I need to supply two informations here one is the type of resource the type of resource is VPC and this is going to be the logical name of the VPC in the next example I will explain you where we use this logical name let's call this one as I'm calling this one as Java home terraform VPC so under this VPC under this resource we need to define certain attributes like this so let's go and check these details in the documentation let's search for terraform VPC in the documentation they have given some example usage here let's copy-paste it okay I'm slightly renaming it let's call this one as main dummy one so in real time keep the names little closer to your requirements so we need to specify the size of block one ninety one sixty dot 0 dot 0 slash 16 and instance 10 and say don't go for dedicated we should go for default you so while creating VPC we also can set tax this is the syntax to set tag so the tackies name values remain let's say one is I want to set location as a tag it can be done like this right so we defined the provider which is a double yes we also define which region we wanna provision the resources and we created a resource called as AWS we have to see and the logical name is main shortly I will explain where we use the logical names The Cider block instance tendency and tags okay the next one I want to create a subnet under this VPC so for that we need to define one more resource so please remember this here VPC is a resource and we are going to define one more resource which is a subnet and subnet is also an resource here resource type of resource which is going to be a double subnet so we need to give a logical name again let's call this one as the subnet 1 and its values let's get details of a w subnet from the documentation now this is the example usage of subnet let's let's copy this as it is right so when we create a subnet obviously we have to create the subnet inside every PC such that we need to specify the VPC ID and we have to specify the side of block along with that we also can define tags so we can defend tags for pretty much any resource in either place let's name this one as subnet 1 here and side a block let's match the side a block of the V PC / 1 and 24 so this is a V PC inside this V PC we are trying to create a subnet and this syntax in terraform right we call this one as interpolation using interpolation we can get some dynamic values in this example I want to get the V PC ID of this resource so that we are doing with help of interpolation and this is a syntax for interpolation in the codes in the double quotes dollar and open closed curly braces so using this interpolation we can access the values of other resources and we also can access the variables that we talk in next video so I want to get the ID of this V PC so in inside this interpolation the syntax is like this the type of resource it's logical name and dot ID so this particular interpolation gets the vp cid of this resource and again i am repeating this syntax for you so always it is resource type it's logical name and from this from this resource i want to get the ID which is going to return the vp cid for us so this is where logical names are very helpful that's the reason the syntax is always contains logical names for each and every resource we define in the terraform and so how do I know the attribute name is ID or how do I know to get VPC ID from this resource its attribute is ID so these things we can always check in the documentation we need to go and check the documentation of a wsv pc for terraform and there i will show the exported certain attributes and out of those attributes ID is one let's go and check the PC this is the example usage and the all attributes right it's given here it's explained here so along with that the following attributes are exported so these are the attributes references where that particular resource exports certain attributes out of those attributes one is ID this ID returns the ID of the VPC so that is what we are using in this particular code so type logical name and it's attribute which is exported that is ID in this case so when we run this code it's going to provision two things it's going to provision VPC and it's going to provision subnet this subnet is going to be part of this V PC there let's go and execute this code and check the results so again we should get back to the terminal so this is where our file is stored the command to execute terraform is terraform apply so when we run terraform apply terraform picks all terraform files in this directory and it starts executing those files see in our case we have only one file which is dot TF which is provided dot TF and it's going to load only that particular file okay so before running any telephone commands very initialize terraform this is one time activity so why we should initialize terraform is so terraform supports multiple providers as we discussed when we initialize terraform based on the provider it's going to download the plugins for us so we need to run terraform in it yeah so terraform successfully initialized that with the plugins here so it initialized you have this plugin okay so after this let's rerun the previous command which is terraform apply so before applying let me show what we have in the air SS management console let's get back to meet we see so currently we have two the PCs which was manually created by me after executing this code we should see couple of resources created by Dara form you and now it's creating a subnet okay let's go and check the economy where ya see this one so this is the VP she created by terraform now name we gave it as Maine and he gave location as Bangalow so we see those tax created as well so go to subnets and for this VPC check whether it has created any subnet there yeah so there is a subnet with subnet one with with name subnet one and yeah the subnet is also created in this case that's all in this demo we'll see you again in the next demo thank you
Info
Channel: Java Home Cloud
Views: 80,534
Rating: undefined out of 5
Keywords: terraform, vpc, subnet, AWS, tutorial, terraform tutorial, aws terraform tutorial, java home, javahome, java home cloud, creating vpc using terraform, setting up terraform
Id: IxA1IPypzHs
Channel Id: undefined
Length: 18min 12sec (1092 seconds)
Published: Tue Feb 06 2018
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.