We will use the first host we are going to launch as a bastion host that will allow us to connect to other servers that are only accessible from within the private side of our VPC network.
We will be creating a security group to allow SSH traffic to this instance. We will use the aws ec2 create-security-group command to create a security group for our bastion host, as shown in the following command. A security group is an abstraction that AWS provides in order to group related firewall rules together and apply them to groups of hosts:
$ BASTION_SG_ID=$(aws ec2 create-security-group \ --group-name ssh-bastion \ --description "SSH Bastion Hosts" \ --vpc-id $VPC_ID \ --query GroupId --output text)
Once we have created a security group, we can attach a rule to it to allow SSH ingress on port 22, as shown in the following command. This...