Okay.
And the last lesson you saw, how to use counts.
Now let me show you another really vault sweep.
We can use it.
What I'm going to do is create a no new folder.
I'm going to call this count dash 80 B.C shortfall advance.
And what we're also going to do is use a Molcho soon so we can create a new file.
And this is going to be main dots here.
What we can do if you complete challenge free with the modules we want to do is copy the DBI module.
And once you've copied it, let's paste it inside, count ADC.
So give we'll start with our provider.
To eight of us.
And let we set my region equal to you.
Dash w dash.
Two snakes will set up a module name.
We'll call it DBI.
And the source is can we top slash TV?
Now let me show you a really cool way.
We're going to set up accounts.
We might want to set up multiple instances and we may want to give them a different name.
So rather than copying the different blocks and pasting in three different times, it makes our code
messy.
So what if we could take advantage of using counts and modules?
Now we're told we're recording this in terraformed zero point thirty.
We're going to bring out a version of count four modules.
But at the time, we're recording zero point 12.
It doesn't exist.
So this is a clever work around and something you may see used in industry, because what you can do
terrible is currently instances.
And then take the values, whether it be an IP address or the resource name, and then hand that over
to another tool like Ansible to then go ahead and configure.
So we're going to do this is if we go back over to our code, we open up DB Doxy.
What delpit?
This creates a variable and I'm gonna call this server on the school names and it's going to be a type.
Equal to list and the list height is gonna be of type string.
Serve in a Modu Obliterate server under school names equal to.
And it's a list.
So what we can do is pass on the names.
Let's say we want Freeserve is creating.
And we're going to call this in, because a DVD, let's say, the three different types, you got Maria
DCB my school.
And let's say we have another one, which is M.S. Escudo.
So your free services.
And the analyst, because it can store multiple elements.
We can use another built-In terror from function called length, which will get us the number of elements
inside this list.
So down here on the instance type, we can set counts equal to and it's gonna be equal to the length
of vol dot server.
And the school names.
So that's going to go ahead and return three.
But we've got a problem here with name because we don't want them all to have the same name.
So we can use another clever trick we can do var dot server on the school names.
And if you're familiar with arrays and programming, you know how we can set a position.
And it's often referred to as the index and say with terraform we use square angle brackets, count
dot index.
So what this represents here is serve on the school names.
The brackets is where we've been good at passing the index.
So our count works for.
We said but linked to it is going to be four elements.
So it's going to work its way through the list and pass in its name.
Each server, then you might be wondering how we going to get the IP addresses.
And again, in this example, we'll say we're using private eyepiece.
And TerraForm has a very clever answer for this.
We'll put another dot in an inside.
Is going to go store because in effect, we're going to create three instances of this theby resource.
And unofficially, in TerraForm, the number will go in here.
So how will it strikes the first option?
It'll be one, then two.
Then Frie works that way.
It works that way.
So what we're doing here.
Eight of us.
Dot dbe.
Then all of the different options from here.
Then all of the different instances we create.
In this case, it's going to be free.
But again, this makes scalable.
So if we have 50 no permits or we can scale up.
What we can also do is write this in a list format.
So looks a bit neater when we get the outputs.
And then over here, we're gonna set up another output.
They'll say it's private, underscore eyepiece, and the value is going to be equal to module dot dbe
dot.
And let's confirm the name DOT.
Private IP.
So now let's go ahead and run it, this guy's view.
Let's go to Terminal C, D, two counts and we'll pass in a full auto complete set ADC.
Let's run.
Terrible minutes.
And again, we can see it's picked up all to.
Excellent.
Now let's run Terfel plan.
Awesome, so, again, we can see we got three instances.
It's going to create and weave the name here.
We can see MSDS QOL patterns can be quite hard to see in the terminal.
So why don't we just go ahead and run?
Terrible reply.
And into yes.
Also, we also have a list of private iPods now over in the top U.S. console.
If I refresh.
You can see I have Maria DBI, my school and MSFC well, so it's quite complex example of how we use
counts.
But it is quite clever way how we can use it.
And one you might see used often in industry, because with those IP addresses, we may then have the
over to all.
And then go ahead and configure.
What is required is a really powerful example.
And again, you have access to all the code with this course.
So if you want to use it or need to use it.
Feel free to go ahead and do so.
Now, what we can do to clean up is run, terraformed, destroy.
Mylanta.
Yes, that wraps up his lesson.
I look forward to seeing you in the next will.