Hi and welcome to this video.
In terror from zero point twelve, they introduced a new concept called Dynamic Blocks.
Movie loves to do is take a list and go through every single element and turn that into terrible code.
That just makes a lot more sense when you see an example.
And the best example I found for this and the most applicable one is actually security groups.
So now, while it's still fresh, you mind?
I think this is the perfect place to have a look at dynamic blocks when you're working at an industry.
This is something you might also see as well as a very common place to use them.
And while this great is as you'll see shortly, we can take a list.
You can have multiple rules.
So where you saw Ingress Block will be added one rule.
Imagine you've been let's create 50 poults on a security guard now rather than using ingress, egress
block method.
What we can do is use dynamic blocks and we create a list of the points you want opening and it will
take care of it for us.
And again, this makes a lot more sense in the demo.
So let's jump straight into that.
Now I'm going to right.
Click and create a new folder and I'm gonna call this dynamic.
I'm going to copy Main T.F. from a security group folder and pace started.
So we need to add two variables.
I'm Nicole, first one, Ingress Rules.
Mean, this is the type equal to list.
And it's like, no.
The value.
Because this is ports we get to open up.
Let's put it to 80 and fulfill her.
I'm going to copy this again.
Paste it and we tickle is egrets.
But this time lets out a few more.
So let's say we're going to emails.
Essence epee open we can to emasculates baseball.
Three, four.
06 is going to connect to a DNS service and won't put 50 frie on you.
And you run the ports.
You want to do it.
Let's just put 88 in there as well.
Good measure.
And again, instead of cruising in response for this, we can use a dynamic block.
So we scroll down now to a security group that minimizes what we do is you put the word dynamic in front
of it, put ingress inside quotes, and then we need to set and it's a writer.
And on the call it pulls.
And what this is going to represent is each element in our list.
So it's very simple point eighty of what she goes through once.
And then the second time it's going to represent or three.
So now we use A for each loop.
We set this four on the school, each equal to Volle total.
Ingress rules.
Again, to check spelling on that ingress rules.
Next, we use something called consent and we read the first Category C and we read the second one on
the side of blocks.
And we said from Holtze to Port Dalts Valley.
I we do the same over to port.
So port dot buddy.
And this is quite confusing at first.
Let's quickly recap what we've done.
We've created a dynamic block for each loop.
It's gonna go through every elements in our list.
And as to the it is 18 Okri.
As it goes through, once the value Setsu is going to be caught, so pulse when it starts, is going
to be set to 80.
And what it does is it says pulque, dot values.
So we said the first one, 80.
So it creates the first ingress block.
Then it does it again because there's two elements inside.
So now report is set to fulfill.
And then it's going to create in a rigorous block.
And it's going to set portal value to fulfill.
So as you can see, it's a really false way of setting up security groups.
If we have multiple rules and we only needs Edita in one place, it's all in the variables.
What I'm going to do now is copy this book.
And replace the egress block, so vehicle this egress, this egress rules.
Now let's go ahead and set this up.
So you guys, if you go to Terminal C, D into dynamic, let's run Terfel minutes.
Excellent.
Now let's run a terrible reply.
We see I'm getting an error here because of misspelt engross rules allowed to include things this because
this can see sometimes even we as instructors can make mistakes and it's good troubleshooting so we
can see that the variable had an eye in its beginning.
Let's go ahead and run.
Serafim, apply again.
Excellent Pollocks.
Much better.
Did you get from a security group?
We can see here.
But the engrosses got two rules, OKL, Hurry and 80.
And if we scroll up, we should see.
Yes, it looks right now as we scroll up, you can see the rules set up to the egress, creating the
egress blocks for us.
There we go.
And again, this is so much easier than trying to do it by keeping pace in that block is preference.
I think the code looks a lot neater.
It's a little bit hard to wrap your head around the first time, but once you understand how it works,
it's going to make your code a lot neater.
How she caught themselves.
So you shouldn't use dynamic blocks quite sparingly.
And this, from my experience, oddly, is the best way to use it.
And that is for security groups to prove it works this into.
Yes.
And go ahead and deploy it.
Excellent.
That was been created.
Let's go ahead and check it out.
The council goes there instances.
Let's check this one out.
And that's due to rules.
Gets in bound rules.
We can see HDTV and HD, PBS, if the outbound rules.
Got Overholt.
We set up.
Excellent.
Now, let's go ahead and set it down so so in terrible destroy.
And so, yes.
And there we go.
That wraps up this video, so as you can see, that's the power dynamic blocks and that is why they
are so powerful and can prove to be really useful.
So that concludes the lesson.
I look forward to seeing you in the next full.