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 *

Already have an account? Sign In »

2 hours 48 minutes
Video Transcription
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,
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.
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
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
D N s label image, name and os type. These air required values. So it could be Lennox and windows. Are they
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,
gets created as a result of using this particular resource
on and then I had navigated over to the resource is
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
myself a subdirectory called Lab.
Within that directory created a main dot t f file outputs dot t f file and, uh, variables that TF file.
We're looking at the main dot T F file here.
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.
And I also, um,
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
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.
Hopefully, you created the variables that t F two separate and isolate. It's really just a good practice.
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.
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,
Um, and you can see that there, there's an output
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
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
drill down a little deeper, as I see necessary. If I wanted
examine anything, such as What? What are the particular containers? And sure enough, there's the Hello world image in all these
these other details.
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