Time
2 hours 48 minutes
Difficulty
Intermediate
CEU/CPE
3

Video Transcription

00:01
Now that we've taken a tour of the Terra form file itself, let's take a brief stop and look at the Terra Form command line interface.
00:13
I have seed into the directory that has this terra form file the dot T F file. You can see 01 basic is the folder 01 Basics is the folder where the file is that we've had opened.
00:29
Then what I want to do here is I'm gonna run terra form dash help. Uh, and this is giving me a breakdown of all the different sub terra form commands I don't intend on covering each and everyone. But take a look at him. We will cover several of these. Um,
00:48
and there's a lot of other things that we're not gonna cover
00:52
as you get more advanced and start getting more comfortable with the fundamentals and you want to expand. There's a lot of helpful little utilities in debugging and an understanding when you create more complicated terra form files that I wanted to highlight. One thing we are definitely gonna have to do here
01:10
is, um,
01:11
first step is isn't in it and performing the initialization, so a CZ part of this is You can see, according to the documents, you know, new existing terra form working directory. So I just seated in this directory. I haven't done any initialization just yet. And what I want to do is I'm gonna have to initialize
01:32
and we can see here. There are a lot of different
01:34
additional arguments that could be provided for the unit command. I highlight this not to dive into the details of all different arguments for innit? But again, toe highlight. We have terra form dash help, which gives us a breakdown of all the basic terra form commands. And then, for each one of those, there is a more detailed
01:52
breakdown of the commands
01:55
of different additional arguments that can be sent to the different commands. We're gonna clear the screen here. Okay, So now we're going to run the actual terra form, innit process. And as we can see here, it's actually downloading the provider plug ins. So in this case, the only plug in
02:14
the only provider that we're using is is is there are m and
02:16
we can see it downloaded version 1.34 and again because we specified we needed a one dot x version, the latest and greatest. That's what it's pulling. If I had said I want 1.2 and specified that up in the actual Terra form file, it would only bring in version 1.2 and it would keep that constraint there.
02:35
Um,
02:37
once we have initialized it, we could now run the Terra form script. But before we do that, I wantto take a minute to preview and ask terra form, knowing this script that we've created on and knowing what I want you two to build over a Nazar which in this case is just a simple resource group.
02:55
Tell me the plan
02:58
of action that you have
03:00
And so I'm gonna run terra form plan.
03:01
First thing we see here is there's an air
03:07
and the reason I'm getting this air is because it's trying that the desert client provider is trying to connect Thio azar. But
03:17
it doesn't really have an identity. It doesn't know who am I talking to? Who am I working asked. So what I can do now is is in this shell. I'm going to go and use the ese command line utility to do a log in.
03:38
And so what that has done is launched a browser window for me, through which I select my log in, and now it recognizes who I am. And this is part of the ese command line. So we have now authenticated with Azar
03:54
as a particular user. In this case, I am authenticating myself as this same user
04:00
that you see logged into my trial account. So when you log in to Azar using the ese log in, you're gonna want to log in using the same account of in the case you have multiple Microsoft accounts using the same account that has the azar subscription that you are using for these activities.
04:20
So once we've logged in,
04:23
we are in a better spot, and we're going to run the plan task again.
04:31
So what it's doing is it's reaching out and, um, understanding. Okay, what is the state of things? As faras Terra form understands it, what are the states of the things in the cloud provider and based on what it understands the state to be, which currently is nothing, it really knows nothing about what's in.
04:49
That is their subscription that I just logged into
04:53
what it figures is well, I'm My plan is to create a new resource group. The idea's gonna known after we run it the location in the name of that resource group. Those things air defined. And that's exactly what we defined in the pair Terra form file up here.
05:08
Andi, that's that's it for the plan, right? Is this is a very simple terra form file,
05:13
but that's the plan. So I say Okay, I like that plan. I'm gonna run terra form, apply. And what we're doing is we are applying the actual terra form script, so it's gonna prop me. Here's it's reiterating again. Here's my plan. Here's what I'm gonna do. I'm gonna create this resource group.
05:31
Do you want me to do that? My answer is yes.
05:33
Please go ahead and create that resource group and there we go. So it completed it and then it's giving. This here is the ice I d of the resource group itself on the temporary that Azera subscription I have and for
05:51
our own purposes, I'm gonna navigate back to the user portal just so we can see this whether our very own eyes
05:58
click on the resource groups lists and we'll see. Sure enough, there is a resource group. TF basics resource group has been created. Indeed it is. In the West US To location, of course, is with my free trial subscription.
06:12
So now we have created looked at the most simple terra form file and run that terra form file. And it's created a resource group in the Ezer Cloud for us.
06:27
Before we finish off this module, we want to do one final thing. And, um, that is we're gonna change the name of the resource group and figure out how does Terra form react?
06:42
Um, to doing that. So up here in our Terra form file, we call that basics resource group. Let's call it basics to and then say that what I'm gonna do this time instead of just going directly to the apply face, I'm gonna run plan again, and I'm gonna
06:59
This is this is my opportunity to ask care reform. Okay. Now that I've updated this resource file, you know what you know about the resource group that we created
07:06
a little bit earlier? Let me know. What do you What is your plan of attack here? What do you ah, intend on doing. And so what it's saying here's is that this resource group that we called our G it's gonna need to be replaced because I'm changing the name. And the way is there works. You really can't perform a rename operation on a resource group.
07:27
You just create a new resource group with a new name and you get rid of the old
07:30
resource group with the old name. And so that's what they mean by forces replacement. So I'm gonna go ahead and terra form apply. And now we've gone ahead and we've changed the name of the resource group. We checked out the plan. Let's have terra form, take the actions that are necessary.
07:48
And when this is all said and done,
07:50
we're expecting that we're going to get to a point where the resource Group TF basics to exists and TF basics does not exist, so we can even see as terra forms performing these actions and putting it out to the console, getting some updates. First step, it's destroying
08:11
the resource group.
08:13
This may take a little bit of time,
08:16
Um and then obviously, then the next step is gonna be creating the basics to resource group.
08:24
Okay, So fast forward. About a minute or so and the process completed, it destroyed the old resource group and it created a new resource group called Basics to I'm going to run the Terra form show Command just to get some more details on that. And and sure enough, there it is, the basics to
08:43
comparably
08:45
If I navigate back to the portal and I hit the refresh there, we can see there's no longer a group with just basic stash RG. There is the basics to RG so that wraps it up for this very first hands on lesson in module 4.1.
09:03
Hopefully, you've got a good
09:05
feeling for how do we What are the steps of creating the most simplistic terra form file? What? The major components, the providers in the resource Is those air big? You also have a feel now for the terra form cli specifically the innit? The plan
09:24
in the apply,
09:24
um
09:26
terra form commands these air very, very important show is something that we're looking at here. You may not run that much aside when you're kind of debugging and getting to know the system. So I look forward to joining you in the next module very soon

Up Next

Fundamentals of Terraform

In this Terraform training course, students will learn the basics of the tool through hands-on labs, become comfortable with its core language features, learn how Terraform fits into the cloud tooling landscape.

Instructed By

Instructor Profile Image
James Leone
Cloud, IoT & DevSecOps at Abbott
Instructor