7

I have this code below to create a RDS instance in aws:

import boto.rds

REGION="us-east-1"
INSTANCE_TYPE="db.t1.micro"
ID = "MySQL-db-instance-database-test2"
USERNAME="root"
PASSWORD = "pass"
DB_PORT = 3306
DB_SIZE = 5
DB_ENGINE = "MySQL5.1"
DB_NAME = "databasetest2"
SECGROUP_HANDLE="default"

print "Connecting to RDS"

conn = boto.rds.connect_to_region(REGION)

print "Creating a RDS Instance"

instance = conn.create_dbinstance(ID, DB_SIZE, INSTANCE_TYPE, USERNAME, PASSWORD, port=DB_PORT, engine=DB_ENGINE,db_name=DB_NAME, security_groups = [SECGROUP_HANDLE],)

print instance

But I am having always this error related to security groups:

DB Security Groups can only be associated with VPC DB Instances using API versions 2012-01-15 through 2012-09-17.

Can anyone please help solve this issue?

If I use vpc_security_groups instead of security_groups Im having:

 <Message>Invalid security group , groupId= f, u, d, t, e, a, l, groupName=.</Message>
2
  • It would help to see the stack trace and the exact error message. Based on this similar thread I have a hunch you're leaving off a bit of your error message (i.e. some particular API versions)... Apr 7, 2015 at 20:41
  • Thanks for your comment. I forget to put the full message, but now I updated the question with that!
    – UserX
    Apr 7, 2015 at 22:56

3 Answers 3

14

RDS instances in VPCs can not be members of RDS security groups. Instead, a RDS within a VPC should be in a VPC security group. In boto, use the vpc_security_groups parameter (with the VPC security group ID as its value) rather the security_groups parameter. See also the boto RDS docs for create_dbinstance().

3
  • 1
    Upaang's answer is also interesting. You might use version 2 instead, in which case create_dbinstance() remains the same function but the vpc_security_groups parameter has changed to vpc_security_group_ids.
    – Ben Whaley
    Apr 9, 2015 at 16:42
  • Thanks for your answer. But Im not understanding why Im having this vpc error. Im not using any vpc, and I dont have nothing in my question code relative to vpc, only the error Im having. But I tried use vpc_security_groups instead of security_groups but dont works!
    – UserX
    Apr 11, 2015 at 16:09
  • I also Im having this: TypeError: create_dbinstance() got an unexpected keyword argument 'vpc_security_group_ids'
    – UserX
    Apr 17, 2015 at 17:09
3

Boto is migrating RDSConnection from version 1 to version 2. You can check this - Earlier we could have got all the db_instances using get_all_dbinstances()but now we can only fetch using describe_db_instances(). Try using vpc_security_group(). The official doc for new version of RDS, i.e. RDS2 is here.

0

this may work. I'm not getting the error with my script but my client is. I'm guessing it's because I have a default VPC security group, which AWS is silently using, and he does not.

boto.rds.RDSConnection.APIVersion = '2012-09-17'

the idea being that, since this API is within (at the end of) the specified range, the error will not apply.

I got the idea from https://github.com/boto/boto/issues/2923

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.