Whitelist multiple public IPs across security groups in AWS

amazon-web-servicessecurity-groups

We have a bunch of 50-odd external (non-AWS) servers that we need to whitelist across many (~50) security groups (vpc). Apart from the constraint on the number of rules, adding and removing entries to/from all the groups one by one is a pain.

I tried adding all the external IPs to a separate SG and whitelisting that SG in other SGs but apparently that works only for internal (AWS) instances1.

[1] Can't give access to all servers belonging to a security group in AWS

Is there any other way to achieve this?

Best Answer

When you say you "whitelisting that SG in other SGs" what exactly do you mean?

I would simply create a single security group with these rules and assign that security group to all instances. An instance can have multiple security group, and rules are additive in a permissive sense. ie default deny, unless any rule in any security group allows access. You will have to create new instances to change the security groups associated with an EC2 instance, but once it's associated with the groups any changes made are done in real time.

You could also do it with network ACLs, which work at a subnet level. NACLs are like a firewall, they run at the subnet level, though each NACL can apply to multiple subnets. They can add more "deny" rules that apply to all instances in the subnet but can't open up ports that security groups have closed. Remember they're stateless so you need to add incoming and outgoing rules.

Note that the question/answer you linked to is a very specific situation which doesn't apply to you, regarding using private or public IPs. Security groups apply to private EC2 IPs or public IPs. For example I have security groups set up that allow access only by my CDN provider and my home IP address, which are definitely public IPs.