AWS - Terraform deep dive - #1

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[Music] this is a court so you have to we have to moisten specify the provider that's mandatory for us provided information is must so once it is done so how we initialize and of course we used to say that communication so which is download some again for this particular provider for this particular order right so you can have four mean it is magic treasure - it's one that I think it's going to download all the plugins based on the problem here and this is the resource type we are trying to launch ec2 instance these things we should get from tariff of documentation say even I should refer these things from the documentation and this is a logical name or some that's some our own friendly name actually we'll see where this friendly names are useful for us but for now right Amazon machine image ID this is the one and instance type this is the one so as we discussed early also it this is specific to region so if you are trying to launch Amazon the next this ID is different for different regions so I have picked up this ID from this region since your work so should pick up these things from the different region you can do it from get back or come on Bob so terraform applied for even I want to add tags for this aim tank I want to add one more think batch so this is when we created time access scheme under man thanks remember that and show detail so while launching any sands you choose this that's magnetic and the region it's already selected in the browser type and if I don't select any of these things it gets if it evolved it to see all the stuff storage that's right when I said tag key and the value correct same thing I mean please name value styrofoam and please badge value s7 care for my plane so this command what is commander so right now they have only one so I am omitting it so this this particular command right it reads all PDF files I'm repeating that again for you it's not care about them they're not reference it only cares about the extension of it loads all dot p.m. files and it will start crossing those files file so you can see this one it's giving some information there it's saying this is a my and for the tags right plus instance type is this and remaining things I didn't provide subnet ID I am NOT giving signals I'm not specify public IP in private IP not specifying all the line you su see this one double a complete supply complete resources iodine is one modified is 0 and s friends you go and check your account in this region there should be one instance where to us and say this name tag I gave thereupon six it's named and stare upon ad is the instance ID the SANS state and so on if you go and check tags see both of them patch is there M is also here yes so this telephone code has created a seamless transfer it's all be configured let's say like they can but I am doing right now because so probably you might be the some other user to use this is newer development sufficient right happy you know decision if they are the same fears I'm corporal Mac system and secret few others but okay we have a some other rats in the secret we want with it also on same mission also a mutual how it works you can answer in one second this is my laptop why I'm going to give it to you everybody has their own laptops right and everybody can this same access he set secret here also I get scared one terraformer drink I will here same access keys and sacredness for everybody that is dangerous action sharing access key secret hit multiple in place this but what I can do is I can set up some work stations on the easy to itself I'll ask all of you to work on easy to Allah saying at all so no one will see what is the access key secret and even there are other options you'll see that okay so this is your ec2 instance launched right so if you want to get more details about this for example you want to see more attributes about this resource right bone-shaped documentation let me show how to check the top perform ec2 instance open this edge so forgot about these things now attributes I'll see the properties in suppose a mind which is managing availability zone is optional placement group is optional tenancy is optional right so you can supply all this values actually you can supply all these values to the terraform and you can create yes I want to launch ec2 instance with existing key then shop all s team a team a minute so so this is existing the way I can check this the account he makes so these are available P place so hurry demo I have been using so I can just specify that I now if I apply that changes c-can I had a key for the existing is it incense so have a nice tan is easy to while launching let's say I said I don't need a key now I want that a sinking is it possible it's not possible so now if I apply it what's going to happen here see I launched in stands without a key now I am trying to I'm telling my telephone for this instance [Music] it's can step it's going to terminate the word one and it's going to create it but again I will explain more on this don't assume every time it terminates and modify know there are sudden cases there it terminates existing instance I am going to launch the new stands for sudden cases it will update the same instance but keep a right so if you want to ascetic leeway there is no option to do that for the existing instances the only option is create a similar one and select a cake after it at the world series it's destroying it so why because it can't attach a search key for the existing instance is going to destroy first then it's going to relaunch a new one okay so let it work so let's see how to create a new key so by launching busy I want a nuclear that keep it let's see how to create instance with new thing there let's see destruction completed and started with crazy and the screen you must see anyone who just comes up there that's it and see item is the key which is associated so this example shows how to attach existing key so what if you want to create a new key shall we go and do that so this is fine but I want to create a new key and I want to attach this new key to my instance the process is this so first we need to generate public and private keys public and so this can be done from SSH clients since have a hoodie we can't do it from footy also or even have a give bash you can do it from in patch my case I can do it from and by terminal I think by orison my operating system is built on top of line x1 it's a backwards but it's built on top of line X so whatever we see in bandits most of the sub exists in this fact so this SSH client is also in bed you must have that kill bash or some other tool which supports that SSH okay such Cajun this is a command the filename is this I want to create a key fail with a file name TM IP this particular command then there's two things for you publicly and first so enter passphrase you don't enter anything if you enter something it lost that password when you do this when he uses SSS I don't want that to be in the interactive mode okay you see this one the identification has been saved to this which is your private key and the public he has been saved TF - demo dot firm that is a public you can see this here public private I need to configure this public key reason - I can use this private key and access from my specialist that is how it works even when a launching stands for console so when you say Lance right in the last page its option to select create new eBay so when it's a new key pair they're going to give a name keep it name and then you say launch what happens in the back box then this public and private keys finally the private key is downloaded by us so your Amazon drive-in configures that publicly in the instance same thing that group resource the obvious keep it I'll go through documentation so there is a business called as keeper this is this is the name this particular resource right is taking the name of the key and publicly of that particular key I want to link this publicly with my instance so I need to leave this guy into this stance now so I will replace this this is not correct I should not put this text directly into this is that file I need to move this into some file and import from that file let's come back to ec2 instance now there's a way to search here you see he named this is the chemo this is agreement so which one I should get this one I need to refer the other resource here correct understanding a lot if something is confusing this is this resource is representing a key which has publicly I want to confident is publicly for my easy truth once it is configure that I can log into this machine using my private key which is on my local mission so here it's expecting a key name but I need to specify the key name of this I need an effort that name here for that they have a syntax like this dollar open close curly brace will pause this one as interpolation the telephone interpolation so using this is kind of the expression using this expression I can refer that if you saw other resources like this say I want to refer the name of this key bed the syntax is like this resource type dot it's logical name dot it's antigen so I need the key name right so what I need to check right in the documentation of this read the documentation of this it exposes some attributes one of the attribute is going to be the name of the key that activate I need to mention here and see this one the following attributes are exported I'm talking about female so when you use this one these are the properties it acts it expects and once this is done these are the attributes which are exported meaning I can import these names in a different resource there so what what I need that he naming of this yeah right so one resource needs to be fine the public key public information in the easy do I want to specify the key if it isn't it if you say existing key I mean I have to mention the name of Finance on an existing people sign if we have been named from the other resource for written of the value from other resource file there is a syntax we call this one as interpolation so inside double quotes Turner open those tiny places inside that the resource type missus name and in that resource female that he saw scheming so this is not a valid public key because a copy paste from the internet I need to replace this one with mine so whatever publicly be generated know so cat God so I need to keep this public key in that string public industry obviously right I can't keep someone else public here right if I do that they can access information so I should leave my public let me use it execute the code the guys attention SS it's a sensation for lambda o'clock please try it out because the basics of Linux and SSH is very important I'll explain that very strong I'll explain but again same resource I am trying to use some changes now the changes are again keyname way to clean em change what it's going to terminate big-time metal created so what it does in easy to tell you see the user there is not SSH folder and the talk sss folder there is authorized keys for the file - of HP's in that file - place this is easy because yes yes done so because they are changing publicly it is destroying it and it's regretting that it is transverse letter ask as much doubts as possible in the beginning itself get get more clarity before we reach advanced concepts so let this happen but I don't want this I want I don't want to put this big string in that article time I want to get this data from your file this there is already there in the five life I want to get this data from file for that also we have some functions ten of them has some functions there is a function called as file just see how to use it by using this file I can get that content from the file in soft occupation that here I can refer the content from the file and explain that files function second serious this is a built-in function there are some built-in functions we can use them part of a code so this is the interpolation file path of the file so I can replace this guy with that interpretation so where's my file not in the same directory there is a public key that's created let's see there is TF there Mata this is the recommended way of doing it but don't directly put it in the value to import this one from your files one moment before doing this change to resources added what is that to resources one is easy to other one is P probably so can I log into this machine now yes they can refresh that I think TF demo this one does it has public IP yes it has from shall we try to SSH into this SSH - hi they said private key yes sir the extension is not dot pen it is just a file name we see - user at like yep this is your PEM file that is your private key yes we're able to were able to log in there all right this is the example to create instance with Neil publicly and the previous example shows how to launch its answer existing so now I'm slightly changing the code this one say I want to see what is output of this before execution should I explain more on these functions are not ok you understood this one at least so they are trying to reference an accurate foot of a different resource the syntax is common dollar open/close foetidus he bad syntax has fixed the other close open close candidates inside that type of the resource dot logical name torque is acting good so please remember them dollar closed open curly brace the source type dot logical name dot attribute please make no no so I want to access an attribute of the resource the syntax is this so open I mean the interpolation that means dollar open close penetrates inside that first part is resource type dot it's logical name dot it's active this is intense so in this case right the resource type is this serious one weird of this key pair is the resource type resource type and it's logical name TM underscore demo dot TF underscore demo dot inside so then we check the documentation it's exporting what are known attributes they're one attribute is female and it has to be inside puts so that's a that's a use case for logical name we are going to actually see if I have two details for example one is TM demo the other one is perineum or and the nautical name is going to be D of them but the resource type is going to be same thing yes I want to use one more key pair for just an instance I am going to copy paste it maybe I am going to call this one as Java home demo and Java memo like this and its key for example so how to refer this particular demo he may stand steps I suspect that these interviews and the school just appear small little name dot Java man is go demo less Saturday which is this is a team that is a format this is one one interpolation the second one is file is a function it takes the file path it has the content of that file Simon this is your interpolation that's a name so we call it as terraform interpolation so inside that we are calling a function what's a function file what argument we takes path of the file what it rhythms contain them so I am taking the public key content I am assigning that to my attribute folders so can I go up like this I can but there are some errors with this little three errors so before throwing and I want to check what this particular interpolation Britain's understanding a point aside it's a mistake here I don't want to run and wait for that system to throw an exception so before that I want to see what this particular value is going to return for us that facility is also there for us the option is you see doing scans transform see we got into the console so from this console you can go and check your interpolation orders I want to see what is output of this so copy the complete stuff I'm tested and see that what is written in the public key so troubleshooting all those things can be done with an error form and I want to see what this is written in from I think that what that regions of TF demo correct so keep note of this error form comes form so when you work with interpolations you can see what value that interpolation next time use again I don't think so I should talk to each and everything but I'm trying to do that so all of us know user data so how to configure user data with telephone before getting into that let me talk little more on yeah I am saying it on the local mission you want that as a reference is it said everything may not be safe because I will give the video you can follow the video before that in size do terraform apply again I didn't change anything I provisioned it and again I do terraform apply without doing any modifications if I try to apply again and again what terraform is going to do is it going to create a new resources see this it didn't add any resources even it didn't change any resources or you didn't destroy any resources so tariffs or means I departed meaning so you should try to apply again and again it won't give any side effects that in modify anything and Iran terraform apply again it's not changing anything there why it's not changing anything there it is somewhere maintaining the information of what all the resources is scared so in our case it created two resources one is this publicly Adonis instance so there are form stores that information the local so when you go and say applying its check for these instances in that if these resources exist you won't deviate them again so you can see this one so many say terraform applied it is trying to refresh this is ID it is settings for publicly with this ID it doesn't don't really again it's sitting for instance with this ID this instance with this idea exists don't really so please make that point there are form is idempotent so running terraform applied multiple times will not cause any side effects idempotent ID EMP or TMD there are four is idempotent so that is running tarawa apply multiple times one cause in segments it so find out if you change the word economy it will change your resources that you can study without without changing if you try to read it again there's no issues now let's see how to configure a web server using music so I want to use same instance there is a column a property called as user data I can't mention user data scripts in line here like this see beginning of the user data any copies as syntax there so in this I can mention all my case all my what is that commands I can say that's a shebang line right which tells your voice he saw a shell commands so interpret those things using shell and you say yeah install a sticky keyd - why then we say em again service start another one say conflict stability um and they want to create a dummy or a dummy file we also can do that will help deployed by telephone that this is user data the beginning of the scripts the ending of the scripts but again you can have underlying substrate is it a good practice to keep it here is what a good practice to be was a solution putting their fiber using that file function install httpd what is it find them your choice they said code nothing is fine IDM install City PD F Y so this check on fake I think it's fine yeah I need to put the redirection slash next so install underscore a City PD dot Sh so this is one so this function we had was a function that rules this is going to be you try this let's try this so Tara form of life so again when you change user data which will remit why because user data works only at launch time somehow so when you put a user data that that script is executed only once in its lifetime that is at the time of launching it so now previously my instance doesn't have user data now I am giving you today what that mean is existing one and it's going to create a new one with this user see even before my terraform tells these are on destroying this I want to see what is going to actually visit a man called s terraform plan so you want apply the changes it's tell which you are playing what exactly is going to do so these commands are really helpful when you work in the real time just let's say you're on a command if they're short something and you are in trouble so being in trouble one check this command saying therefore plan this command tells you what kind of changes of component - when you say keropok effect this will give you a plan what exactly is going to do it's not going to do it now that's refreshing all the resources and accordingly to tell you what it's going to do when you say terraformable so user data can see this text what it is what it says this forces new resource okay it says new resource is required since new resource is required what happens to the old one there is an internal so terraform plan please not all the time instead now I am finding that I know it's going to terminate and [Music] take a segment so using telephone using telephone execute a script using telephone you secured a script I easy to instance say this added one is one refresh it I think this is the one which is freshly grated one get this IP C to D by hit this it should respond with saying deployed by telephone that's what we kept in next on is number okay if you're not able to access where to check that the connectivity issues very gently Sakana and I mean probably it is blocked by our security group so we need to contact that's a critical first accepts all in state thing is counting there's a connection Alice wait for some more time yeah but come again I didn't get the package take it for dauntless I know this will come motivated everything is fine but I gave before here for desktop but anyways there's a default response coming from my operation it can correct this obviously you guys know how it works that's about user data so anything anything apart from this you need right you have to go checked the documentation and next there are four wave terraform means this code is fine but the problem is can be reuses let's say one who played in stanza with different aiming without changing this code is there available to reuse it now if you can do that it's not maintainable right so today I have 20 lines tomorrow and maybe having hundreds of lines if the problem here is directly I am mentioning a mais sense types he names or those things here now it is best idea it's good idea to caramelize them so declare these things in their variables and effort those things into this values such that right tomorrow I want to create I want to be clear very wrong bed with different ma on different instance type so I can't just change the variable soft changing the code so maybe that's why I'm trading 10 instances now then this is unless we say Amen what say and I want to set up ten instances in every chance there is a mi casa 10 different places tomorrow I want to change my email or I want to change my instance type then I need to find out all the places and revisit but this is not the right frame we need to use variables let's stop variable variable name its value and again interpolation comes into picture dollar open/close colobus now it is bad dot variable series so it's beginning with math meaning we are referring to variable if it is beginning with resource static to resource likewise for this T to micro also I need to declare one more over there so instance type she names your choice variable names your choice but when you refer provide the same so then ignoring to maintain same names it can be anything repeating that it can be any name when you refer it uses no so one instance type here so you can copy-paste it so in case of a my back dot instance type keyword yes so we're telling our interpolation name is I wanted a variable whose name is constant we see two and second point is is everything and keeping in one single file that's a kind of thought so then in the beginning everything you do simple easily when your project grows with parts of resources and it becomes clumsy so don't keep everything in a single file better rate your project into multiple files see already we did some breakup so this installed httpd i kept in a different time so likewise variables keep it in a separate file providers Safed instances suffered v v pc is separate file as a simple notification of this sub layer so it's a good practice to break your core into different folders and different files should I do it so now I want to take these variables and keep it in a separate location why because if you have under files tomorrow and you want to change some variable you don't identify the variable which file is variable is present the best practice is keep it in a separate file like this last dot p.m. area remember extension must be dot here it's a vast dot DF and take all these variables from here move it to here is this fine for you ignore the remaining files here I will talk about them later even ignore this directory there's a plugin very few only commenting on is in sense install on your public and private keys don't keep privately in the code that should be somewhere else one was this this towel contains only variables tomorrow there is a change for the variable you know which file to open right amount he'll change any question only so here I kept that it was hard-coded every I think that one variable then I go and apply now before applying I want to see what kind of changes apply is going to do I don't think it's going to it's checking that this key pair if it is there if you want it it's checking there it stands if everything is there is not going to get it did I change anything in user data what if I kept I do anything I don't want to do it again for time being let's keep it as some change here there is a change it's a mechanism to identify the change according to the change it says I have to create a new instance there are no changes in the user date enough that no changes in first actually subject okay say what carefulness it lowers all PL files from the directory that's what I said when you run in terror from apply right it will load this one which is ending with 40 F it will also learn this one which is ending with Tatia that's what I said file names your choice but the extensions must be taught be able so when you run the terraform applies it will search for all Terra firme files in the directory note them and accordingly fun figure you so there is no need to say keep a should comfort that on instance I don't think so that such order is required in there with automatically Casa model probably notes all your variables class then data sources then resources everything is loaded first so once it gets all the information then it starts publishing different sources you can think of like that there is no specific order to follow wherever you want keep it can I put variables into my consensus file yes when it loads everything the background it will make it segregating all the variables in the memory all the resources are not most of them then it starts updating those math order is not a matter [Music] that's the life if I have applied we already know there's not a specific everything there is no option saying terraform of life only for one but P variables now coming back to the variables say suppose different types of enemies one is string a text this is a text it also supports a list it also supports and map suppose different types of this is I want to use and map so mapping sense said today if I change the region is it going to work yes I change this one to use best one rebirth what's the problem there yeah my idea isn't it so can I make it work just by changing region can I do coding to make it work we can do that one so what we can do is we can give a map of MX region is a key yeah my ideas are serious one more change this also got put it don't put it here and names our choice snow tax is this their dollar opening close man dot so my point here is if I change the region that's my code word know why it fails because of this but even if I change my region I want to make this work I can go and we're going to have values key is going to be the region and value is going to be associated a my say when I supply the King it is going to written back wheel so even if I directly change this region that it's going to work on but now it doesn't work let me go and check the documentation for terror for map this is so I can say us and let's say us is not saying that complete 15 religions there if you want to support the King region's you must put Kim Kim Olympics so far this best to force image ID this is I mean for us best East one which is that East one this is one this is a likewise sorry the vessel with us just to missed one but she can create a big map of it now the challenge is I should take this value from my instance see this mine stands can I do this now when I do this it is going to return me complete map but I don't want to get my concrete back I want to get only one thing clean them so there is again function call - look up so this is the function specify the map and specify which anything wanted terraforming look up see this this is a function Matt the key lesson key is not present you can use some default values you are telling that if you key not present don't throw an exception go with default option let's use this code so come back to this should be lookup first entry is to have like bad dot payment was second it region function it's going to look up an entry from this map whose is that means so can I check what is going to return before execution so yeah we can use that console and should be inside oats why it's listening to ninety to ninety if I use this one if I change this one to resist one then we accept and we come I mean I did some changes what's what Ellie it was this one and this one so when you change your region you want to take the code this is a perfect so variable variable name typed default equals open closed curly brace he not any course value is inverse but now I suppose only two minutes [Music] the last one is list they done with string to increase the best set which is sin is good this is the matter how many entries are there two entries us best took us east one so what is this value which are it picks I want to choose a reason a front angle and Ramos's don't set the default value and go and run the code so when you go and run the code it will ask you for this region enter it it's that and it exits the two doors here I am declaring a variable but I'm not assigning the value for C this terraform of length n to the bones which is bear head of this region enter the value accordingly it's worth but in automation which not hip type the values in that conserved everything should be automatically from the fetch it sort of taking till what shall we have taken a cigarette because automation which not be interactive in say automation has to happen automatically it's not be any exact Ahmad let's go for ten minutes break much any minutes fifteen minutes break [Music] so be even I want more this provide apart into separate Pyland can be anything but extension specifically stances right and this has a provider information and this one has the variables which is used by this particular project where they're trying to give us clear separation there next one I want to pay it tell me easy two instances how misleading senses there so what's the best elegant way of doing it so an option for prepares their necks the other option is count they say variable called as count because again don't fall for it here they have to put this Valentina yeah so before doing it see this my mind could this is not properly format see one variable has simple symbol here other variable has the constable here it's not looking nice the poorest kind of scatter I want to align it properly they said command for that are 70 format this is going to lead Lea format at all see that note see Robin wins avoids the alignment is all the variables have a same same align provinces the command is keropok FM C previously it was like this scattered at different places after running this format it's aligning you code into a proper very good format so don't declare yes three times don't keep it here next it has to be in the variable dollar where what say count-o u stands calm so make sure same thing so this is kind of a low point it's going to do if you have duplicate the code it's not made edible it's never duplicated so we should keep it simple short and maiden shall I condone this it's going to create three instances now when it comes to tagging right for instance one I want to say 170 any one instance - I want to say that up to three and so given that can be done [Music] count dot index 1 and so on if you want it and so on for that we are using this interpolation in that I'm deferring this count and the index for bassresource index is 0 second resource 1 2 and so on but I don't want to begin from 1 sorry 0 I want to begin from 1 so for first resource index is 0 that's 1 which is 1 second 1 1 plus 1 which is 2 and so on don't do this move which is called as a loop in there to add want to change its going to add two instances and it is going to change one resource what is the change here weakest tag name say this go to the earth for instance zero it is going to be telephone one that's a tagging it for instance one kind of form to reach stands three okay this is about your group's check that part so I either count and dynamically I am generating the pencils come again happy times to have speakers like a let's say you want to give and for in that array you want to pick tats we can do the rows one needed to them we didn't give given as three then how does it know it has to create three instances we came see this is a variable right I gave three right so telling three having comical no is say obviously tenor I didn't mention it here I am referring a variable correct in that variable was a value 3 so it is going to create three instances ones and coming to your point you want to pick up the tags from that list but these chances declare a variable variable let me call it as tax for instance tax I'm declaring a variable of type list so I can get the value from this list by passing index so if you will come from development background list is collection of values how to get a value from the list by passing a index but list index is always 0 if Eagles with 0 0 1 2 till length minus 1 so I want to take values from here and substitute those values in mind and stats that's your partner can become Python java.net most of the grated cheese yeah you can't promise you'll see that Python there is slice and start from 0 and then reverse side - -5 - 4 - no energy check that there is a function again element now look up the useful map sorry I want to pick up a element from the list index this is see what is this one there this right the first argument I am Telling is the list from this list I want to take first element I should past zero but taking second element I should pass one third element too but it has to be dynamic correct I can say this also but it's going to pick the first element wrong I don't want so there is an option for us to say count dot index first time count dot index is zero its first element second time one second element third time counter to Nexus to fix that's what shuttles are subway the counter that's one contains a zero he wants in the next so don't expect that complete the programming kind of control so Java does mean Python we can have full control but they might be some limitations shall we apply and see it's going to pick the elements from that or this is not the answer I want to remove this it will say terror for my friend terraform one Cassius see Tara formation there are from three they have come to search wanted properly so don't worry about the death of the concept will very important depth of the concept I'm talking is leave it is a tea bag if you want business I never I can close this we are session but my intention is not just to tell accommodate intention is must get better okay so I'm saying that homicide important so how telecom knows want resources it traded this company right this campaign the resources is not common with some other some other values if that resource access is not tearing it up the resource doesn't exist is going to tell that three suspects so how this pans out terror knows it created some resources where the information is kept the information is kept in tariff on scale factor this is a fine terraform dots TF scale this is automatically clear I didn't create these two files there one is just dot EF state now on is Packer that's a previous state this is the latest state and this is the realistic let's open this file and see what its adjacent it has something like version error for version some number modules and see resources there that's the resource type logical name type of that resource depends on ants the ID can see reciting so how we uniquely identifying music in senses by the name mom can you duplicate therefore my introduce yourself that is identified fiber Heidi so when you said there are four apply me if you pick all the resources in the local state while it's going check whether the report state is matching the state if it is matching it doesn't take if it is not matching what he does know it's going to update it oh it's going to thing see all the values are capturing even it has a mi ID plus this is nice hand side scatters we stand style everything is my dented it's a change in stance type my god so you compare that code will be safer so there is a change in stance there is a change can be updated subject I mean before sleep - on its hands on that and then the one one and it's very much TF state this is a fine bear there are for maintenance the state of resources provision by your terrible it's a file where if we're careful maintains the state of resources is commissioned by telephones there's a file which is storing the state of the resources your remote state is complete with a local fight pretty smashing don't be publishing it is not matching either update it if it demands a new resource telemetry tell me if I delete state file what happens is it going to recreate I'm Savin the input if I delete both the files right when you go and say apply to see all the resources uniquely and it's a former if you check for those resources in that state file if nothing is present what it understands casteau yes it's going to go to create those resources again for you remember so we should not touch this telecom stapler don't manipulate these findings that should be validated only by your telephone we should not manipulate telecom state files it's not so please remember don't ever touch these guys I will be back I don't think so you have to manually doesn't have variables they're all the variables substituted no no we can manually go a little that's a bolita terraform state files which should not actually power now you must have TF files without this intensity that's fine your point is if you did it your files can you read me a tape answer is simply not if you tell it this one that's gone no that's what I am saying no matter what is of the case if you delete your source code then nothing you can't do anything in that state so then you have a source code then it's compared with state then according it is executed if you delete your main source file itself what is going to nothing okay no I want to make a particular resources I have under resources and I want to delete a specific resource a comment put it in the moment it's going to yes I want to take out this resource comment it and gone up like so previously this resource was there now I devoted a massage for so what happens for it is going to remove this key back so obviously Fatima's a keep a we could not work so if you want to remove a specific resource comment that resource and Ranchero let me do one them for demo purpose let me create one more let's say I have three Islam which is created by mine there are ma which is gated by telephone to resources of type key babe and suddenly three resources of type in stands because Congress leader now I want to terminate I want to remove this resource from my account there is no direct command for removing a specific resource the only option is comment it and go and do an error for apply whatever you commented that resource is deleted from here from this loop so you can terminate lasting sense if required but making contacts to write so you generate zero one two is missing so it's going to terminate it but you will not get that full control from there it's not an actual code right so this is the time when you won't get that control in the dev but there are ways for that right one more code under try to delete it create a separate folder with the bird with those values and try to run and delete offices so how to delete complete infrastructure all resources get up on let's try this is going to clean up everything front so when you add a comment that is going to remove on it that resourceful there are fungus file so generally we maintain these things in Washington it given if someone billing is you can get it from the voltage which not maintained music for our local file systems say Cashman kept in the washing company to track it to tip bucket yes really last one before there is a resource that is manual equipment let's say we create nine resources effect at a point and one resource is manually painted this is the current status select system some disaster happened to configure AMA I want to be placated everything in different region so what I do and change but region in that tariff or variable I will go and say apply when I go and say I blind is it going to create and resources imagine my resources why or where that one because it does not take it by telephone doesn't have that information in it this state file so because of that that one is not faith how to bring that we saw simply telecom scope these are our nailed and scenarios say initially commissioned everything manually but after some time management decided we should curve it error form we started is in CARICOM for the new resources but the problem is the existing resources are not in the control of terraform i want to bring them into Telefunken such that in disaster case when you read up this code in a different region because if here everything not what is a portion of resources created by your data for this option corners there are four important we can import a resource which is manually created or which is created outside the reformed into the scope of tariff on them account let me leave it as one fine for demonstrating this particular example see this is created by your telephone what about this manual so I want to break this also into my telecom control such that if I create my resources in different regions we have to create this one plus this one so there is the option called as the import you can import a resource which is not very affected or form we together that's man that's a may be hated by Python manual or some other mean but I want that this was to be one of my terraforming port so when you say tariffs on import before importing it you must declare that resource resource this stands some logical name so one any mini name is fine yaimai I should know what is the am I using for instance but believe it is same so I need to specify the stance type papaface work the instance type is t2 micro and PM is one second this is us so whatever resource eiated outside the neva I want again that resource under the control of first declare that resource declare that resource here the second step is important I need to get that remote original details into my local state right important command is this terraform we poor what's the resource type what's the logical name you are using here one what's the ID ID of that instance that is I I am Telling my terraformed import UW's visiting stands whose ID is this into this resource which is declared in my telephone I'm not sure about the syntax I can get it from the documentation research you can see everything in the documentation first declare it then do this one so terraform import resource type logical name and i think ID in order to specify explicitly careful so now that resource which is created outside the cottage details into our telephone straight line but make sure everything is working fine sometimes it also the graves it stopped to check that the reformed flag that should give you the details the one which we imported is mofat are should we know anything is refreshing this this ok so one to add let me see what is that one to add pink use that data okay maybe have some user data that I need to refer refer that with one really but it still it sure is a fine with recreation for it has some user later that's the reason I'm not mentioning user data here so if you see this one I'm not specifying the user data which is matching with my instance is about what is the case it should yeah but where are we know how do you port that we so stated outside it so when you change your radiant it's going to create this also char you which was banned militated and this is
Info
Channel: Java Home Cloud
Views: 43,247
Rating: undefined out of 5
Keywords: terraform, terraform functions, java home, java home technologies, deep dive, terraform tutorial for beginners, terraform tutorial, terraform aws tutorial, terraform tutorial aws, terraform by java home, terraform aws, terraform deep dive, terraform loops, terraform variables, terraform vpc, terraform subnets, terraform route tables
Id: IT-Tpunrf7A
Channel Id: undefined
Length: 108min 12sec (6492 seconds)
Published: Sat Nov 04 2017
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.