Re: [boto-users] How do I get the type of security group?

106 views
Skip to first unread message
Message has been deleted

Jason Chan

unread,
May 18, 2013, 4:49:39 PM5/18/13
to boto-...@googlegroups.com
There is a 'vpc_id' attribute on security group records. It's empty if the SG is in EC2, and reflects the VPC ID if the SG is in VPC.


On Wed, May 15, 2013 at 12:45 PM, Altonymous <ch...@altonymous.com> wrote:
There are EC2 & VPC security groups.  get_all_security_groups() returns both.  I'm trying to only get EC2 or VPC groups.  Either that or be able to check a property on the group after the fact to determine which type it is.

--
You received this message because you are subscribed to the Google Groups "boto-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to boto-users+...@googlegroups.com.
To post to this group, send email to boto-...@googlegroups.com.
Visit this group at http://groups.google.com/group/boto-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Jason Chan

unread,
May 18, 2013, 4:54:25 PM5/18/13
to boto-...@googlegroups.com
Sorry, should have included an example:

>>> import boto
>>> e = boto.connect_ec2()
>>> all = e.get_all_security_groups()
>>> for group in all:
...     if group.vpc_id:
...         print "in a vpc"
...     else:
...         print "in ec2"

get_all_security_groups() also allows an optional filter. Perhaps that could be used to implement this restriction more proactively.
Reply all
Reply to author
Forward
0 new messages