I am trying to laucnh an instance using boto. The instance needs to be launched on a specific subnet within my VPC and also in a specific security group within my vpc.
The following code successfully launches an instance in my VPC on the correct subnet:
conn.run_instances(
image_id=base_ami,
key_name=bakery_key,
subnet_id=bakery_subnet)
The following code gives me the following error:
reservation = conn.run_instances(
image_id=base_ami,
key_name=bakery_key,
security_groups=['TheNameOfMySecurityGroup'],
subnet_id=bakery_subnet)
Here is the error I get. I get the same error when I specify use the subnet ID instead of the actual name of the subnet:
Traceback (most recent call last):
File "./botobakery.py", line 24, in <module>
subnet_id=bakery_subnet)
File "/usr/lib/python2.6/site-packages/boto/ec2/connection.py", line 935, in run_instances
verb='POST')
File "/usr/lib/python2.6/site-packages/boto/connection.py", line 1177, in get_object
raise self.ResponseError(response.status, response.reason, body)
boto.exception.EC2ResponseError: 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>c8a6b824-4ab3-41d2-9633-9830c167d2d6</RequestID></Response>
I would be extremely greatful and appreciative if anybody knows how to launch my instance into my specific subnet AND into my specific security group
Because you are launching into a VPC, you must specify the security groups by their ID rather than their name. Names are valid only in "classic" EC2. So, if the security group in question had an ID of sg-12345678
you could use a command like this:
reservation = conn.run_instances(
image_id=base_ami,
key_name=bakery_key,
security_group_ids=['sg-12345678'],
subnet_id=bakery_subnet)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With