A VPC is your private network on the cloud. You can configure access control rules to ensure the security of instances, such as ECSs, databases, and cloud containers, running in a VPC.
Figure 1 shows how security groups and network ACLs are used. Security groups A and B protect the network security of ECSs. Network ACLs A and B add an additional layer of security for subnets 1 and 2.
Figure 1 Security groups and network ACLs

Table 1 provides differences between access control options. You can select one or more as needed.
Item | Security Group | Network ACL |
|---|---|---|
Protection Scope | Protects instances in a security group, such as ECSs, databases, and cloud containers. | Protects subnets and all the instances in the subnets. |
Mandatory or Optional | Mandatory. Instances must be added to at least one security group. | Optional. You can determine whether to associate a subnet with a network ACL based on service requirements. |
Stateful or Not | Stateful. The response traffic of inbound and outbound requests is allowed to leave and enter an instance. | Stateful. The response traffic of inbound and outbound requests is allowed to leave and enter a subnet. |
Action | Supports both Allow and Deny rules.
| Supports both Allow and Deny rules.
|
Rule Packets | Supports packet filtering based on 3-tuple (protocol, port, and source/destination address). | Supports packet filtering based on 5-tuple (protocol, source port, destination port, source address, and destination address). |
Matching Rule | If an instance is associated with multiple security groups that have multiple rules: | A subnet can have only one network ACL associated. If there are multiple rules in a network ACL, rules are matched based on their priorities. A smaller value indicates a higher priority. |
Usage |
| Selecting a network ACL is not allowed when you create a subnet. You must create a network ACL, add inbound and outbound rules, associate subnets with the network ACL, and enable the network ACL. The network ACL then protects the associated subnets and instances in the subnets. |