| Did this page help you? Yes No Tell us about it... |
A security group acts as a firewall that controls the traffic allowed into an instance. When you launch an instance in an Amazon Virtual Private Cloud, you can assign the instance to up to five VPC security groups. The groups act at the instance level, not the subnet level. Therefore, each instance in a subnet in your Amazon VPC could belong to a different set of security groups. If you don't specify a particular group at launch time, the instance automatically belongs to the VPC's default security group. For each group, you add rules that govern the allowed inbound traffic to instances in the group, and a separate set of rules that govern the allowed outbound traffic.
The security groups you've created for Amazon EC2 (i.e., EC2 security groups) are not available to use in your VPC. You must create a separate set of security groups to use in your Amazon VPC (i.e., VPC security groups). The rules you create for a VPC security group can't reference a EC2 security group in your account, and vice versa. Also, VPC security groups have additional capabilities not available to EC2 security groups. For more information on Amazon VPC security groups, go to Security in Your VPC.
This section walks you through the process of assigning a security group to your existing load balancer in Amazon VPC using either the AWS Management Console, Query API or the command line interfaces.
To assign a security group to your load balancer
In the AWS Management Console, click the Amazon EC2 tab.
Click Load Balancers in the Navigation pane.
On the Load Balancers page, select the load balancer that you created for your VPC.
The bottom pane displays the details of your load balancer.
Click the Security tab.
In the Security Groups pane, select the security group.
A list of assigned security groups for your load balancer is displayed below the Security Groups pane.

To assign a security group to an existing load balancer
Call ApplySecurityGroupsToLoadBalancer with the following parameters:
SecurityGroups =
sg-53fae93f
LoadBalancerName = MyVPCLoadBalancer
The operation returns the security group ID of the assigned security group.
For detailed descriptions of the Elastic Load Balancing API actions, see Elastic Load Balancing API Reference.
To assign a security group to your existing load balancer in Amazon VPC
Enter the command elb-apply-security-groups-to-lb as in the following example.
PROMPT>elb-apply-security-groups-to-lb MyVPCLoadBalancer --groups sg-53fae93f
The operation returns the security group ID of the assigned security group.
For detailed descriptions of the Elastic Load Balancing commands, see the Elastic Load Balancing Quick Reference Card.