What Is a Cloud Security Group? Distinguish Workload Rules from Subnet ACLs
A cloud security group is a logical filter applied to a workload, such as a virtual machine or network interface, to define which network connections are allowed. AWS has a feature actually named Security Group; Azure provides Network Security Groups (NSGs). Google Cloud does not use the same named object: it applies VPC firewall rules to target VMs. These products pursue similar goals, but their attachment points, rule processing, and defaults differ, so their configurations are not interchangeable.
A cloud security group is a logical filter applied to a workload, such as a virtual machine or network interface, to define which network connections are allowed. AWS has a feature actually named Security Group; Azure provides Network Security Groups (NSGs). Google Cloud does not use the same named object: it applies VPC firewall rules to target VMs. These products pursue similar goals, but their attachment points, rule processing, and defaults differ, so their configurations are not interchangeable.
What does a security group control?
Routing determines whether packets have a path to their destination. A security group or similar rule filter determines which connections are permitted along that path. Rules typically specify traffic direction, protocol, port, and source or destination. For example, a web server can accept HTTPS from users, while a database can accept database-port connections only from application servers.
This filter does not replace routing, public IP configuration, or authentication and authorization in the service itself. An allow rule cannot make a connection work if there is no route. Conversely, a public address and route do not make a connection work if an applicable rule blocks it. Network packet filtering and a user’s sign-in or permissions are separate security layers.
How do AWS, Azure, and Google Cloud implement this?
All three control network flows, but their objects and rule models differ.
| Implementation | How rules apply | What to watch |
|---|---|---|
| AWS Security Group | Attach it to resources such as EC2 that use a network interface. When several groups are attached, their allow rules are aggregated. It is stateful and uses allow rules only. | A new group has no inbound rules, but starts with a rule allowing all outbound traffic. Review that rule if egress should be restricted. |
| Azure Network Security Group | Associate it with a virtual-network subnet, a VM network interface, or both. Rules are evaluated by direction, starting with the lowest priority number, and stop at the first match. It is stateful. | If both subnet and interface NSGs are attached, traffic must pass both. Review their rules and defaults together. |
| Google Cloud VPC firewall rules | Rules are configured for a VPC network and enforced on target VM interfaces. Targets can be all VMs or VMs selected by network tag or service account. The rules are stateful. | This is not an object named “security group.” Check scope and default behavior for the network, target resource, and rule. |
Stateful means the filter tracks a permitted connection and lets its response packets pass without a separate allow rule in the opposite direction. It does not mean that arbitrary new connections are allowed both ways. AWS and Azure can also differ in how rule changes affect existing connections, so check provider guidance before changing rules used by long-lived connections.
How is a security group different from a network ACL?
AWS Security Groups and network ACLs both filter connections, but operate at different boundaries. A security group is a stateful filter associated with an instance or network interface and supports allow rules only. A network ACL is associated with a subnet, supports both allow and deny rules, and is stateless. With a stateless filter, rules must account for both request and response directions.
An ACL can therefore serve as an additional subnet guardrail or explicitly deny selected traffic, but it is not the same feature as a security group. When both layers are used, routing, the ACL, and the security group must all permit the connection. Although Azure NSG includes the word “network,” its rule processing and state behavior are not the same as an AWS network ACL.
Example: allow only the connections needed from web to database
The following is an illustrative assumption. Suppose an application has web, application, and database tiers. The web tier serves HTTPS to users; the application tier accepts only required application ports from the web tier; and the database accepts database connections initiated only by the application tier.
In AWS, an inbound rule for the web servers can name the load balancer’s security group as its source, and a database rule can reference the application servers’ group. This lets the rule follow group membership when server addresses change. In Azure, if both subnet and NIC NSGs are attached, either one can block the connection. In Google Cloud, a VPC firewall rule can target VMs by network tag or service account and also constrain source and port. These examples implement a similar security goal; their configuration syntax and semantics are not interchangeable.
For example, opening the database port while defining the application tier’s source too broadly may allow more systems to reach the database than intended. Or the filter rules may be correct while routing for the response path or another firewall blocks the connection. Check the route and the rules at every relevant hop.
What should you check when adopting a group or diagnosing a problem?
First identify the security group, NSG, or VPC firewall rules actually associated with the target resource. Creating a policy or attaching one to a different resource does not make it apply to this workload. Then narrow source and destination ranges, direction, protocol, and ports to what is needed, and confirm the product’s default action for traffic that matches no rule.
When a connection fails, isolate the cause instead of changing several layers at once:
Confirm that a service is listening on the destination address and port.
Check that subnet routes, gateways, peering, and the return path lead to the destination.
For AWS, review how rules from every attached security group are aggregated. For Azure, inspect effective subnet and NIC NSG rules and their priorities. For Google Cloud, check the VPC, target VM, direction, priority, and tag or service account.
Inspect the next filters, such as subnet ACLs, firewall appliances, and the operating system firewall.
If provider flow diagnostics or firewall logs are available, identify the denied rule and traffic direction. Make a narrow change and verify it with a new connection.
Opening management ports such as SSH or RDP to the entire internet (0.0.0.0/0 or ::/0) lets anyone try to connect on those ports. Prefer a trusted source range, VPN, bastion, or time-limited access for remote administration. If a rule is necessary, restrict its source and duration. After changing rules, review connection logs and keep a recovery path that can restore the previous configuration.
Cloud security groups are a basic way to narrow workload access, but cloud providers do not implement them identically. Confirm the attachment point, stateful behavior, priority or rule aggregation model, and defaults first. Then allow only necessary flows and validate routing and other filters as well to reduce unintended exposure and outages.
Sources
[AWS: Control traffic to your resources using security groups](https://docs.aws.amazon.com/vpc/latest/userguide/vpc-security-groups.html)
[AWS: Security group rules](https://docs.aws.amazon.com/vpc/latest/userguide/security-group-rules.html)
[AWS: VPC infrastructure security and comparison of security groups and network ACLs](https://docs.aws.amazon.com/vpc/latest/userguide/infrastructure-security.html)
[Microsoft Learn: Azure network security groups overview](https://learn.microsoft.com/en-us/azure/virtual-network/network-security-groups-overview)
[Microsoft Learn: How NSGs filter network traffic in Azure](https://learn.microsoft.com/en-us/azure/virtual-network/network-security-group-how-it-works)
[Google Cloud: VPC firewall rules](https://docs.cloud.google.com/firewall/docs/firewalls)