6.2 Module Registry

Video Activity
Join over 3 million cybersecurity professionals advancing their career
Sign up with
Required fields are marked with an *

Already have an account? Sign In »

2 hours 48 minutes
Video Transcription
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.
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.
So if you look here a TTE the get website, you'll see we have
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
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.
Um, it's being produced by as there are m. So
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,
So we like that and we can look at the documentation and understand
all the different inputs outputs, dependencies, that this model has.
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,
so I want to drop down to the command prompt Here,
located in the 03 Modules directory, I'm gonna run terra form and mitt.
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.
Or I could just even look at other people's terra form code.
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
seeing what are some of the other people did using and
how they assembled these kind of things.
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,
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
for this particular model of the network, giving it a location giving it a resource group
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.
And you'll also see specifying the operating system to be in a boon to server.
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
through the use of this module
up here
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
all the N s names need to be unique.
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.
But another important thing here is the keepers.
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
I d. Every single time.
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.
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.
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
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
here, there are a few actual warnings about some deprecate ID stuff, and they're coming from the
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,
is where this particular model is stored on Get hub. Believe it or not,
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
looking down a terra form plan. We can see it's creating sub nets. It's creating a hole,
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.
So this is where the
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.
You can see we have some security rules so There's really a lot that these models were using
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.
It will just be a second looking at what gets done
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.
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