DB Security Groups can only be associated with VPC DB Instances using API versions

匆匆过客 提交于 2019-12-23 22:17:18

问题


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>

回答1:


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().




回答2:


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.




回答3:


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



来源:https://stackoverflow.com/questions/29434025/db-security-groups-can-only-be-associated-with-vpc-db-instances-using-api-versio

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!