diff --git a/ec2/spark_ec2.py b/ec2/spark_ec2.py
index 35209aec5fcfe4aae5ee1ea2eb8985e7418c49fa..c59ab565c6862a12739ee4c38c1afe212c90477c 100755
--- a/ec2/spark_ec2.py
+++ b/ec2/spark_ec2.py
@@ -1174,11 +1174,12 @@ def real_main():
                     time.sleep(30)  # Yes, it does have to be this long :-(
                     for group in groups:
                         try:
-                            conn.delete_security_group(group.name)
-                            print "Deleted security group " + group.name
+                            # It is needed to use group_id to make it work with VPC
+                            conn.delete_security_group(group_id=group.id)
+                            print "Deleted security group %s" % group.name
                         except boto.exception.EC2ResponseError:
                             success = False
-                            print "Failed to delete security group " + group.name
+                            print "Failed to delete security group %s" % group.name
 
                     # Unfortunately, group.revoke() returns True even if a rule was not
                     # deleted, so this needs to be rerun if something fails