The security group role

We have a few different aims with this role. The first is simple enough: create a security group which opens port 80 and 443 to the world, or in IP terms. The second aim is to create a rule that allows SSH access, but only to us, and the third is to make sure that only our EC2 instances can connect to RDS and EFS.

The first aim is easy as is a known quantity, the others not so much. Our IP could often change so we don't want to hardcode it. Also, we haven't launched any EC2 instances, so we don't know their IP addresses.

Let's bootstrap the role and create the first set of rules:

$ ansible-galaxy init roles/securitygroups

We are going to be using the ec2_group module to create our first group in ...

Get Learn Ansible now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.