Discussion:
[boto-users] How to delete default egress rule in a specific security group using boto
Andy Andy
2015-08-09 06:57:56 UTC
Permalink
Hi everyone,

I notice there is always a default outbound rule once a security group is
created.
The rule's type is 'All traffic' with Protocol 'All'.
How should i delete this default rule using boto?

I tried
group = c.revoke_security_group_egress(group.id,'All')
Traceback (most recent call last):
File "<pyshell#8>", line 1, in <module>
group = c.revoke_security_group_egress(group.id,'All')
File
"C:\Python27\lib\site-packages\boto-2.38.0-py2.7.egg\boto\ec2\connection.py",
line 3447, in revoke_security_group_egress
params, verb='POST')
File
"C:\Python27\lib\site-packages\boto-2.38.0-py2.7.egg\boto\connection.py",
line 1227, in get_status
raise self.ResponseError(response.status, response.reason, body)
EC2ResponseError: EC2ResponseError: 400 Bad Request
<?xml version="1.0" encoding="UTF-8"?>
<Response><Errors><Error><Code>InvalidParameterValue</Code><Message>Invalid
value 'All' for IP protocol. Unknown
protocol.</Message></Error></Errors><RequestID>105afe65-1a4e-42a3-b754-1fc519c54ca4</RequestID></Response>

Please help me take a look at this issue.
Thanks,

Best wishes,
Andy
--
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.
For more options, visit https://groups.google.com/d/optout.
k***@reancloud.com
2015-11-25 09:01:51 UTC
Permalink
you can use following snippet

import boto.ec2
conn = boto.ec2.connect_to_region("us-west-2")
groups = conn.get_all_security_groups(filters={'group-name':
['SG-Name']})[0]
for rule in groups.rules_egress:
for grant in rule.grants:

conn.revoke_security_group_egress(groups.id,rule.ip_protocol,rule.from_port,rule.to_port,grant.group_id,grant.cidr_ip)
Post by Andy Andy
Hi everyone,
I notice there is always a default outbound rule once a security group is
created.
The rule's type is 'All traffic' with Protocol 'All'.
How should i delete this default rule using boto?
I tried
group = c.revoke_security_group_egress(group.id,'All')
File "<pyshell#8>", line 1, in <module>
group = c.revoke_security_group_egress(group.id,'All')
File
"C:\Python27\lib\site-packages\boto-2.38.0-py2.7.egg\boto\ec2\connection.py",
line 3447, in revoke_security_group_egress
params, verb='POST')
File
"C:\Python27\lib\site-packages\boto-2.38.0-py2.7.egg\boto\connection.py",
line 1227, in get_status
raise self.ResponseError(response.status, response.reason, body)
EC2ResponseError: EC2ResponseError: 400 Bad Request
<?xml version="1.0" encoding="UTF-8"?>
<Response><Errors><Error><Code>InvalidParameterValue</Code><Message>Invalid
value 'All' for IP protocol. Unknown
protocol.</Message></Error></Errors><RequestID>105afe65-1a4e-42a3-b754-1fc519c54ca4</RequestID></Response>
Please help me take a look at this issue.
Thanks,
Best wishes,
Andy
--
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.
For more options, visit https://groups.google.com/d/optout.
Loading...