Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

security_group_ids again not accepted in boto.ec2.connection.EC2Connection.run_instances - it's not possible to launch instances into VPC #1884

Open
tR-ASallamon opened this Issue · 3 comments

3 participants

@tR-ASallamon

Hi,

I just recognized that its not possible to launch instances in vpc, again.
This error was already commited 2 years ago:
Changes: https://github.com/boto/boto/pull/221/files
Issue: #221
Issue: #350

I get the same error, that appeared 2 years before:

EC2ResponseError: 400 Bad Request
<?xml version="1.0" encoding="UTF-8"?>
<Response><Errors><Error><Code>InvalidParameterCombination</Code><Message>The parameter groupName cannot be used with the parameter subnet</Message></Error></Errors><RequestID>8e10e522-1a9b-4e09-9817-0b2b7ff1cc68</RequestID></Response>

Best Regards

Alexander Sallamon

@danielgtaylor danielgtaylor was assigned
@danielgtaylor

@tR-ASallamon, how are you making your request? The issues you link to are solved and stem from a documentation issue and from calling the method with the wrong parameter values. Do you have an example piece of code which fails?

As mentioned in #350, when launching in a VPC you should use security_group_ids instead of security_groups and there is also an example for the AWS CLI:

aws ec2 run-instances --image-id ami-8e987ef9 --count 1 --instance-type 't1.micro' --key-name 'KEY_NAME' \
--security-group-ids sg-b14149d3 --subnet-id 'subnet-ID' \
--instance-initiated-shutdown-behavior 'stop'

The equivalent code with boto looks like:

ec2conn.run_instances('ami-8e987ef9', instance_type='t1.micro', key_name='KEY_NAME', 
                      subnet_id='subnet-ID', security_group_ids=['sg-b14149d3'],
                      instance_initiated_shutdown_behavior='stop')

If you are still getting an error, please describe how you are making the call, what parameters you are sending, etc.

@tR-ASallamon

@danielgtaylor, thank you very much for helping.

I'm using the following code (shortened):

import boto.ec2
import boto.exception


def create_ec2_instance(info):
    try:
        ec2conn = boto.ec2.connect_to_region(info["region"][:-1],
                                             aws_access_key_id=iamAccessKeyId,
                                             aws_secret_access_key=iamSecretAccessKey)
        if info["insidevpc"] is True:
            reservation = ec2conn.run_instances(info["ami_id"],
                                                key_name=info["keypair"],
                                                security_group_ids=str(info["securitygroup"]).split(),
                                                subnet_id=info["subnetvpc"],
                                                instance_type=info["instance_type"],
                                                ebs_optimized=info["ebsoptimized"])
        else:
            reservation = ec2conn.run_instances(info["ami_id"],
                                                placement=info["region"],
                                                key_name=info["keypair"],
                                                security_groups=str(info["securitygroup"]).split(),
                                                instance_type=info["instance_type"],
                                                ebs_optimized=info["ebsoptimized"])
    except Exception, e:
        msg = str(e)
        print(msg)
        exit(1)

So for VPC instances I'm already using security_group_ids instead of security_groups.

My IDE is JetBrains PyCharm 3.0.2 and the (via PyCharm paket manager) latest installed Boto version is 2.19.0.
I'm a little bit confused, this code worked before, since there was an update on the 28th Nov (to 2.19.0) for boto through the paket manager of PyCharm.

Best Regards

@cbsmith

Based on the error, it looks like your security group has a '_' in its name instead of a '-'.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.