boto/boto — Issue #561: Security group issues in VPC
Author: rayrayson
Created: 2012-02-06 19:32:11+00:00
State: open

Boto version: 2.2.1.
Problem: Reference Amazon VPC security groups by name is not allowed.

If I use operate on a VPC security group, I get exceptions. The same code works fine for non-VPC security groups:

Testcase - non-VPC security group:

>>> import boto
>>> conn = boto.connect_ec2()
>>> sg = conn.create_security_group('name','description')
>>> sg.delete()
True

With VPC security group:

>>> sg = conn.create_security_group('name','vpc-sg-description', 'vpc-f5cd149d')
>>> sg.delete()

Traceback (most recent call last):
File "", line 1, in
File "/usr/lib/python2.6/site-packages/boto-2.2.1_dev-py2.6.egg/boto/ec2/securitygroup.py",
line 85, in delete
return self.connection.delete_security_group(self.name)
File "/usr/lib/python2.6/site-packages/boto-2.2.1_dev-py2.6.egg/boto/ec2/connection.py",
line 1917, in delete_security_group
return self.get_status('DeleteSecurityGroup', params, verb='POST')
File "/usr/lib/python2.6/site-packages/boto-2.2.1_dev-py2.6.egg/boto/connection.py",
line 935, in get_status
raise self.ResponseError(response.status, response.reason, body)
boto.exception.EC2ResponseError: EC2ResponseError: 400 Bad Request

InvalidParameterValueInvalid
value 'name' for groupName. You may not reference Amazon VPC security
groups by name. Please use the corresponding id for this
operation.0706c41c-eb77-44dd-81dd-6b736de6c0ef

However, deleting with group_id works:

>>> conn.delete_security_group(group_id=sg.id)
True

Same issue with other methods - eg. authorize():

>>> sg = conn.create_security_group('name2','vpc-sg-description')
>>> sg.authorize('tcp', 23, 23)
True

Operating on a VPC security group:

>>> sg = conn.create_security_group('name','vpc-sg-description', 'vpc-f5cd149d')
>>> sg.authorize('tcp', 23, 23)
Traceback (most recent call last):
File "", line 1, in
File "/usr/lib/python2.6/site-packages/boto-2.2.1_dev-py2.6.egg/boto/ec2/securitygroup.py", line 167, in authorize
cidr_ip)
File "/usr/lib/python2.6/site-packages/boto-2.2.1_dev-py2.6.egg/boto/ec2/connection.py", line 2057, in authorize_security_group
params, verb='POST')
File "/usr/lib/python2.6/site-packages/boto-2.2.1_dev-py2.6.egg/boto/connection.py", line 935, in get_status
raise self.ResponseError(response.status, response.reason, body)
boto.exception.EC2ResponseError: EC2ResponseError: 400 Bad Request

InvalidParameterValueInvalid value 'name' for groupName. You may not reference Amazon VPC security groups by name. Please use the corresponding id for this operation.ab9b9930-d00f-4683-af50-f9cee9f49db6
>>> boto.authorize_security_group(ip_protocol='tcp
File "", line 1
boto.authorize_security_group(ip_protocol='tcp
^
SyntaxError: EOL while scanning string literal

Thanks,
Rayson

==========================================
Open Grid Scheduler / Scalable Grid Engine
http://gridscheduler.sourceforge.net/