Using boto to connect to pre-existing windows instance
Question: My code is the folliwing

    
    
    import boto.ec2
    conn = boto.ec2.connect_to_region("us-west-2",aws_access_key_id='secret1',aws_secret_access_key='secret2')
    
    
    
    
    conn.run_instances(
            'i-41ffc2c0',
            key_name='MyWindowsKey',
            instance_type='t2.micro',
            security_groups=['launch-wizard-3'])
    
    
    print conn
    

Where launch-wizard-3 allows RDP connections with no problem.

Now when I run the above I get the following error:

    
    
    Traceback (most recent call last):
      File "Documents/boto_test.py", line 11, in <module>
        security_groups=['launch-wizard-3'])
      File "/Library/Python/2.7/site-packages/boto/ec2/connection.py", line 973, in run_instances
        verb='POST')
      File "/Library/Python/2.7/site-packages/boto/connection.py", line 1208, 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>InvalidParameterValue</Code><Message>Value () for parameter groupId is invalid. The value cannot be empty</Message></Error></Errors><RequestID>e9d2cb00-a49b-4de5-a60e-178067f88119</RequestID></Response>
    

This is my first time connecting to this via boto.

Thanks for any pointers.


Answer: From the error message, seems only provide `security_groups` is not enough.

Please provide `security_group_ids` when create a new ec2 instance. You can
also create the instance without it, and add the security group later after
the instance is created.

**security_groups** (list of strings) – The names of the EC2 classic security
groups with which to associate instances

**security_group_ids** (list of strings) – The ID of the VPC security groups
with which to associate instances.

### Notes, maybe there is one more problem in your code. which @jarmod has
pointed it out

`i-41ffc2c0` is not ami id, it is a ec2 instance id. You need update it as
well.

