6.0 Introduction to Terraform Modules

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

Already have an account? Sign In »

Time
2 hours 48 minutes
Difficulty
Intermediate
CEU/CPE
3
Video Transcription
00:00
Okay. How to go. I hope you did well in the lab. Going to spend the next few minutes walking through the solution I put together. There is no single right answer to creating the tell of terra form scripts. Um,
00:13
but I wanted to give you some insight and how I went about doing this just so you can maybe follow that path. Maybe you even have a better path than I have taken here.
00:25
First thing I did for this was go to the Terra Form registry. I knew we wanted to deploy on desert Container, so I just did a search for his er container. And I found this module here called the A C I model
00:39
toe took a look at it. It is made by a zero r m is not a validated module, but still, I was pretty happy and comfortable enough to want to use it. You see some examples of the usage, the input parameters and so forth described here
00:55
D N s label image, name and os type. These air required values. So it could be Lennox and windows. Are they
01:00
a lot of values for the O s type A little more digging. What? The outputs of this so outputs the fully qualified domain name off the container group that was, uh,
01:11
gets created as a result of using this particular resource
01:15
on and then I had navigated over to the resource is
01:19
because this module is actually creating two different resource is one is creating an is er resource group, and then it's creating a container group within that resource group. So it's taking care of some lifting for me, and I was able to take advantage of that. Once I figured out the module I wanted to use from the Terra Form registry, I went ahead and created
01:38
myself a subdirectory called Lab.
01:42
Within that directory created a main dot t f file outputs dot t f file and, uh, variables that TF file.
01:49
We're looking at the main dot T F file here.
01:53
I knew that the D. N s label for the container was gonna need to be unique because it is D N s. So I took advantage of the random I d resource, which we've used before.
02:05
And I also, um,
02:07
applied that as part of the value for the D. N s name label here, you can see the actual label itself is composed of two things we're bringing together into a consolidated string. The value of the D. N s prefix variable as well as the random I D
02:23
oh West type is being brought in from a variable image name based on the value of a variable resource group name again the value of a variable and finally pulling forward on the location. We'll proceed to open up the variables that TF file that I created for this lab.
02:42
Hopefully, you created the variables that t F two separate and isolate. It's really just a good practice.
02:47
Pat yourself on the back with a little extra credit. If you created a description attribute in a type that true for all of the variables, it's not required, but it is definitely a recommended practice and highly encouraged.
03:02
And then finally, for my terra form script, I've created an output, which is the fully qualified domain name off the Container Group once it gets deployed, because we're gonna open that in the in the Web browser. So I've gone ahead and executed the Terra form apply here,
03:21
Um, and you can see that there, there's an output
03:23
produced, which is Thea host. Name off, the that we're gonna access. This is where the particular container has been deployed. So cross your fingers
03:37
and here we go. And so it's it's up and running. And if I want to look a little bit behind the scenes, I can open up the Azar portal and I'll see. Here's the resource Group that was created a cli of resource group. And sure enough, there's the container instances resource within it and Aiken
03:53
drill down a little deeper, as I see necessary. If I wanted
03:57
examine anything, such as What? What are the particular containers? And sure enough, there's the Hello world image in all these
04:04
these other details.
04:06
So hopefully you have something similar. Hopefully, you were able to figure it out. I look forward to continuing to explore terra form on dhe. Move forward in the subsequent modules. Thank you
Up Next