Time
2 hours 48 minutes
Difficulty
Intermediate
CEU/CPE
3

Video Transcription

00:00
Let's open up the main terra form file, located directly underneath the 03 modules. Here's the Resource Group are referencing to the custom resource group module that we were reviewing just a moment ago.
00:13
And then you can see there's reference to two additional modules in this terra form file. And if you look at the source path unlike before, it's not a relative directory path. It's this kind of absolute path, and that brings us to the concept of the terra form module registry and community pop modules.
00:32
So if you look here a TTE the get website, you'll see we have
00:36
a link to additional Resource is going to take a moment to navigate over to the terra form registry, which is where you can find all sorts of community modules Summer verified. They have these little stars of here. Some are not. So you're gonna want to take that into account when you're evaluating a module on determining what Mongols do I want to work with
00:56
because
00:57
they may not all be from, ah source that is as legitimate. Or you may want to investigate some of the details of the module a little bit before using it. In this particular example, we're using the compute module, which you can see here it is in his er verified module.
01:15
Um, it's being produced by as there are m. So
01:18
I like that. I like to feel a little bit of ah legitimacy around this one. And in the documentation it describes, what are the different required inputs when you're creating and using this particular module for the compute? There's also a module that we're going to be leveraging as well called the Viet module again, this has been a verified module,
01:38
So we like that and we can look at the documentation and understand
01:42
all the different inputs outputs, dependencies, that this model has.
01:46
If I flip back over to our source code where we're using this module, you notice that it's all yellow. The idea is not too happy about things right here. And basically what it's saying is, I don't know about this model. I don't know how to find it. I don't have this information loaded in my directory,
02:02
so I want to drop down to the command prompt Here,
02:07
located in the 03 Modules directory, I'm gonna run terra form and mitt.
02:13
What this will do is what it's done. Always in the past is download. This particular providers, like is There are M, but you also know it is here it is downloading a copy of the different modules into a certain sub directory, and I could definitely navigate there and look at the code of that model. In fact, it is a If I wanted to do it and in depth audit, I could do that.
02:31
Or I could just even look at other people's terra form code.
02:36
You could definitely learn to develop your coding skills and understand how different people are kind of pushing the boundaries of terra form. Take a look at those some maybe good practices. Some, maybe not. But it is definitely a great way to learn how to improve the quality of writing of your terra form code. By
02:53
seeing what are some of the other people did using and
02:55
how they assembled these kind of things.
02:59
You'll notice that the I D. Stopped being yellow in this area of the network module. That's because when I ran, the Indebted downloaded those modules. The I D picked it up,
03:09
and now it has a good bearing on what are the different inputs of this type of a module? Which ones are required? Which one or not? We can see they're showing up here in the auto sensing. In this particular case, I'm really just filling out the very bare minimum values
03:25
for this particular model of the network, giving it a location giving it a resource group
03:30
and the values of the location. The resource group. I'm actually referencing the outputs from the resource group module that we created custom, and we're reviewing a bit earlier, Right research group, location and name similar approach being done down on the computer model.
03:46
And you'll also see specifying the operating system to be in a boon to server.
03:52
Ah, and I'm even specifying that this server runs on a sub net. And rather than hard coating that in basically saying, you know, the virtual network that this other module created, where you're going to be using that just used the very first virtual sub net located in the V Net that was defined
04:11
through the use of this module
04:12
up here
04:14
and one last element about this main terra form script that you probably noticed is Ah, resource called random I d. So this is not ah, resource provided by the user r M It's not cloud specific resource in this circumstance. When we create a server, we want to assign it a D. N s name, and
04:32
all the N s names need to be unique.
04:34
So to ensure this, what we're going to be doing is leveraging this random i d. Resource. You could definitely read more about this. Stop is leased a random number generator. I'm giving it some particular specifications of length to be eight for the generated by random i D.
04:54
But another important thing here is the keepers.
04:56
So this random i d is on Lee generated or regenerated and re evaluated. If the the name, the value of the group i d for the resource changes, that's way when I'm running it again and again and again, it's not going to be generating a brand new random
05:15
I d. Every single time.
05:17
That would be good, because let's say I want to deploy this as is, and then I want to come back and I want to say allow sshh traffic to be false, and then I will do the plan in the apply.
05:30
But when I'm running it, we don't want the d. N s for the server to change. The only change that I want to take place is allowing the SS H traffic and you're not allowing as shh traffic in that circumstance.
05:46
What's up? Back over to the command. Prompt and run a terra form plan and see what Terra Form thinks needs to happen in order to
05:55
do what we've specified here, which is creating a resource group were specifying that activity by applying a model. We're using another community model and saying created virtual network. And then finally with the module, we are saying creating a server which will be a simple of room to server. And as we can see
06:15
here, there are a few actual warnings about some deprecate ID stuff, and they're coming from the
06:18
the modules that I'm using and it doesn't look like it's critical, but it But it is a warning will continue to use this module, but something to keep in mind as we're tapping into community modules. There's nothing that we can do directly Thio to fix that unless we wanna make a contribution to the open source community,
06:38
which
06:39
is where this particular model is stored on Get hub. Believe it or not,
06:45
Um,
06:46
in fact, just a just a quick tangent you can see here is the actual location in Get Hub. So if I did want to make a contribution to add via get help, I certainly could. In this case, I'm not too worried about it. It's just a warning about a deprecate ID property
07:01
looking down a terra form plan. We can see it's creating sub nets. It's creating a hole,
07:06
a whole lot of things in terra form for me, even though my actual terra form file is pretty simple, really, we have three different modules being referenced, and then we're using the random I. D. Resource teen calculator Random value. That's going to be the D. N s name. The public being s name for this, a boon to server.
07:27
So this is where the
07:28
the using of patterns of a module these models here, this compute module has defined creating network security groups. In addition to just creating a server, it's assigning it to the virtual network.
07:43
You can see we have some security rules so There's really a lot that these models were using
07:47
are are doing for us. But it's abstracting us from needing to deal with so many details and fact. What I'd like to do right now is go ahead and launch and apply this so that this server and the resource groups and the networks are all gonna be created.
08:05
It will just be a second looking at what gets done
08:09
for us automatically by using these models on, then that will just really underscore how much heavy lifting and the particular pattern that they're using in the module to implement creating a virtual network and creating a particular server.
08:28
So I'm gonna go ahead and apply this. It will take a little bit of time someone a fast forward in time on the video.

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