Being able to filter and manage the traffic
that can reach your EC2 instance
is critical for improving the security
of your cloud environment.
This is where services like security groups come in.
A security group acts as a virtual firewall
for your EC2 instances
to control incoming and outgoing traffic.
Inbound rules control the incoming traffic
and outbound rules control the outgoing traffic.
You can specify one or more security groups
when you launch an instance.
This might be useful if you're testing out different rules
but be careful to not overcomplicate things.
If an instance has multiple security groups assigned to it,
it has the sum of all the rules in the various groups.
In this ACG fundamental,
we're going to create a security group,
add rules to it, assign it to an instance
and finally, remove it entirely.
Let's dive in.
Make sure you are signed into your AWS console,
and then I'm gonna select EC2.
On the left side under network and security,
let's select the security groups,
then I'm gonna go ahead and hit the orange button,
create security group.
I'm gonna call this SSH-devs.
And this description will be Allows ssh for devs.
And I'm gonna leave the VPC
to the one that's already selected for us.
I'm not gonna add any rules at the moment,
we're gonna do that later on.
Then I'm gonna hit create security group, all right?
And it says here security group SSH-devs
was created successfully.
Fantastic.
Let's head back to security groups,
and just so we can see a list of all of the groups
that we've created.
We see that SSH-devs has been created.
Let's go ahead and add a rule to it.
I'm gonna click on it,
and we see inbound rules and outbound rules.
So on the inbound rules,
I'm gonna go ahead and click on edit inbound rules,
then I'm gonna click add.
For type, I'm gonna select SSH,
and then for the source, I'm going to select anywhere.
Now this isn't best practice for any machines
or any services that you might have in production,
but since this is something we're just testing, it's fine.
Now we're gonna hit save rule.
Fantastic.
We've now added that rule into inbound,
and we can now assign this security group to an instance.
So let's head over to EC2 instances
under instances on the left side,
and let's select one of these.
Let's click on this second one we have here.
And under actions,
I'm gonna select on security
and then hit change security groups.
Fantastic.
I'm actually gonna remove the one that it has,
and then I'm gonna find my SSH-devs one.
Great.
Then I'm gonna hit save.
Whoops!
SSH-devs then we're gonna hit add security group
and then we're gonna hit save,
I forgot to hit add security group.
Alrighty.
If we click on this instance once more, we head to security.
We're gonna see that under security groups
that SSH-devs has been assigned.
And finally,
I'm gonna show you how to remove a security group
that you've created.
Let's head to security groups on the left side,
and let's make sure the SSH-devs is selected.
And under actions, we're gonna hit delete security group.
And we see here, we have an issue,
it's not allowing us to remove this security group
because it's attached to an instance,
it is associated to an instance.
So what we've got to do is click on that instance,
and then we're gonna highlight that.
We're gonna go to security once more,
change security group,
and then we're actually gonna remove that.
And then we'll add another one,
we'll add the launch-wizard one back there,
hit save.
Fantastic.
Let's head back into security groups,
let's select that SSH-devs.
And now, delete security group, delete.
And all set.
That's it for this demo.
We've accessed the AWS console
and we were able to create a security group.
We added rules to the group, assigned it to an instance,
and finally, we deleted the security group.
I'll make sure to link some more resources in the show notes
for you to read a little bit more about AWS security groups.
Alrighty, that's it for this episode of ACG fundamentals,
go on and create some security groups
for your AWS environment,
and let me know how it goes in the comments.
Keep being awesome Cloud Gurus,
I'll see you in the next one.
(upbeat music)