Time
2 hours 48 minutes
Difficulty
Intermediate
CEU/CPE
3

Video Transcription

00:00
Okay. Welcome to Module 44.1. This is the time we're going to start getting your hands dirty with terra form and taking our understanding of this technology to the next level.
00:13
Just a last minute, quick preflight check from the prior module. You should have an AZAR account test account set up a TTE this point. If it's really plain Jane default, it's gonna look a lot like I have here on the screen when you first log in.
00:32
You should also
00:34
have the, um, intelligent I D editor up and running and installed on your own workstation. Additionally, you want to make sure you have installed the Terra form plug in for Intel, Ajay, That provides some nice functionality that will be getting into
00:52
in this. Ah, this particular module, in fact.
00:55
And it will be very helpful as we move forward. And then, of course, finally, you want to make sure you have the terra form command line interface
01:07
version 1.28 or newer
01:12
so soon you have all those and then, of course, the very, very last step being to clone the course materials from get hub. And if you didn't don't didn't get to that didn't do that. Check out the very tail off. Um,
01:29
the last module three, where we were going through that process and
01:33
pulling them down from get hub. So it shows up right here in our on our I d editor. I'm gonna be hopping back and forth between the intelligence A I D. E and the web browser. So we can
01:48
a CZ We look at different things here. So, um, first a little bit about as her. I said, You don't have to be an expert at it. And by no means do you, um, one concept that is a bit unique to wizards called resource groups in eight of us G C. P.
02:07
You usually will take your resource is such as virtual machines,
02:10
storage containers, kubernetes clusters, these kinds of things and you organize them using tags and other things those concepts do exist in as their auras. Well, but all resource is regardless of the kind, are going to be put within a resource group. That's kind of your container.
02:30
So everything always sits within it. One resource group and only one resource group.
02:35
You can then create tags on top of that. But the base organizer for Mazar Materials is in a resource group. I bring this up because in our first set up here, we are going to create the most simple terra form file,
02:53
and that terra form file is going to be creating
02:54
and as a resource group. Okay, I'm gonna move this into presentation mode to make it a little easier for you to look at the i d. While we're opening up the code,
03:06
first thing we're gonna do is in the Basics folder. We're gonna open up the main terra form script, which you can see here on the screen.
03:15
Top of mind is comments. So in your terra form files, you're going to be creating comments. Things can be done using several different formats. Single line comments are with the hashtags as the leader or with a double forward slash much like you do in a lot of common
03:32
source code development languages.
03:35
Job A C C plus plus, the other style is the multi line comments of the forward slash star. This is if you have ah lot to say in all, and you want to capture it all in one single block.
03:49
So that's something that is, regardless of what? What you're doing, what you're making. If you're making in terra form file,
03:55
that is how you do comments. The next item you will quickly notice is provider. So here we have. We're using a provider called Azure R M. So I think it's very important that you understand providers because it's really a basis for a lot of the, um
04:15
the way that the Terra form works holistically as as a product. So you can see here we have additional resource is and I have a link to the actual terra forms master page of all the different providers. So providers include a Tzar Google Amazon web service is these major cloud
04:35
providers All have providers
04:38
and the whole point of a provider within terra form is too abstract. The specific nuances of communicating with the A P I level from you when you're writing the terra form script. So when you're interacting with azar, you're not using the azar proprietary Sze
04:55
As a resource manager, you're not using the Terra form or excuse me, The AWS is cloud formation proprietary format
05:00
that you also find that there are some providers for a lot of things other than actual cloud providers. For example, there's a my sequel provider can be very helpful if you create an instance of a my sequel server. Say you do it on AWS. But then you want to make sure your scripts also initiate databases
05:19
within that, my sequel instance.
05:23
And maybe they're doing things like setting permissions, creating database users and doing some other initialization sze as one example again, there are a ton of providers that you can see in this list, and it is consistently growing. So I definitely recommend you take a good look at providers
05:41
and take a reference of this
05:43
so that when you're going about doing your development, you have a general feel of the different technologies. And if you're using those technologies, you can take a look at the provider in terra form and and get an understanding of what's the value this is gonna bring it. What kind of things can this
05:59
specific technology provider helped bring to the table? See, or terra form scripts are more efficient, effective in comprehensive,
06:06
so flipping back to our terra form file itself, we talked about the provider first section. In this case, we're using the observe provider. Secondly, you'll quickly noticed there's a kn attributes in this block. This is the general syntax for terra form. It's called the Hash E Corp configuration language.
06:25
Is this in tax? It's kind of like Jason. It's kind of a mark up. Not so much
06:30
like an XML, though It's kind of like code. It's its own thing, but it's pretty easy to read and understand and look at it, and one of the attributes you'll notice in this provider block his version. So when you're using these different providers,
06:46
there's always new versions. Revisions, fixes being released by the open source community that is creating these providers. And typically you're gonna want your your scripts to lock version into a specific version of a provider, or at least within a range. So in this case, I have specified
07:05
that any version one dot X's long as the major releases one
07:11
dot something that version of the provider is acceptable in it will work, and that's just a general. Best practice for Terra Form is as lock it to the major version. I could have been very specific and added the version to be 1.20 and so forth to really lock things down
07:30
so you can give kind of, ah range of acceptable versions.
07:34
Or you can really lock it down to a specific version. If if you're concerned that they provider you're using is undergoing fluctuations and really isn't able to be backwards compatible is new versions of the provider comma out in a released
07:49
tour eloquently beneath that we are creating a resource. This particular resource, you could tell by the name of the resource is there are m This resource type is coming from the terrarium
08:03
provider. Specifically, it's a resource group is the resource that we're defining. I'm giving it a name which we'll talk about those in a second called RG,
08:13
and then you'll notice it has some attributes first and foremost Attribute is name, and so this is going to be the name of the resource group that gets created when this terra form script runs and then secondly, you'll notice there's a location. So there's the various different regions that is, er has west, us West, us to east us.
08:33
There's a whole bunch of them.
08:35
This isn't a course on as ER, but they have regions around the globe, so you will typically have reasons for selecting one region over the other, whether it's cost where its availability sometimes. And in this the same case with Google, it's the same with Amazon and pretty much every major cloud provider.
08:54
There are certain capabilities and resource types
08:58
that are only available in certain regions for one reason or another.
09:03
Okay, so I want to spend a second now that we've talked about the provider and the resource construct just kind of navigating the IittIe because you're going to say, Well, boy, there are a ton of different resource types that Thea's there are M provider realizes and helps us implement.
09:22
Um and it's the same case for AWS provider all these other ones. It's really similar. So what I could do, though, because we're using an I D on. This is why
09:31
we're really pushing to do this, is is I can start just typing code here, right and leverage the auto complete capabilities. So I just start typing on a new line, are yes and then goes Boom. Okay, now it's already establishing a block for me, and then the next. Because I've imported these, there are M
09:48
provider. It's giving me a full list of all the different providers
09:52
now. It's not giving me all the details of what these providers mean, but we'll get into navigating the specific resource types that providers provide in a minute. But the important thing here is is I can navigate and kind of get a feel and say, Well, you know, I I think I need
10:11
I know I need to make some sort of a virtual network.
10:13
So let's see. Okay, we have virtual machine. A. Here's a virtual network. I could do gateways Aiken do peering. I could do a one and I have a few options, and this helps it a little easier for me, cause then once I select, I want to make a virtual network. In this example, it's automatically populating all these different attributes because depending on the resource type that I'm crying to create,
10:33
the provider
10:35
definition itself has certain attributes that need to be defined that are required. There are also going to be optional attributes, so I'm gonna hit control plus the space bar, and it's going to give me this. This context menu as well, which is listing out ah, variety of other optional attributes
10:54
as well as is some other other languages and tactical options
10:58
that I can use toe work with when writing my terror form scripts. So that is an idea. If you're not familiar with working with integrated development environments is a huge reason, and that that it's a value and why I wanted to really make sure we're using the intelligent idea highly. Recommend it when you are doing your development
11:16
so that it helps. It'd make it easier for you to write your code and to explore
11:20
the different providers that that auto complete is just so valuable. And finally, the intelligence is one of the more mature when it comes to auto complete for Terra form scripts, in particular in the Hash Corp configuration language, which is the reason that we're using that.
11:37
I know visual studio code also provides a plug in,
11:41
and and I would suspect that other major ideas, like Eclipse, provide ah plugging as well for myself. I've only worked with visual studio code and then, of course, within tell Ajay. So I'm gonna delete this little area and clean up
11:58
bringing us back to the original file that we had

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