Assuming that the EC2 tools have been installed like described in a previous post, opening and closing ports is done with the ec2-authorize and ec2-revoke commands respectively. These commands work on security groups rather than on instances. Recall that a set of instances belong to a security group.
Opening port 80 on EC2 instances in the ‘default’ security group.
ec2-authorize default -p 80
Close port 80 on EC2 instances in the ‘default’ security group
ec2-revoke default -p 80
See also the Amazon command reference for the EC2 API.