support default ports in RDS
This commit is contained in:
parent
df84675ae6
commit
6d8aa9d8f1
@ -57,6 +57,8 @@ class Database(BaseModel):
|
|||||||
self.source_db_identifier = kwargs.get("source_db_identifier")
|
self.source_db_identifier = kwargs.get("source_db_identifier")
|
||||||
self.db_instance_class = kwargs.get('db_instance_class')
|
self.db_instance_class = kwargs.get('db_instance_class')
|
||||||
self.port = kwargs.get('port')
|
self.port = kwargs.get('port')
|
||||||
|
if self.port is None:
|
||||||
|
self.port = Database.default_port(self.engine)
|
||||||
self.db_instance_identifier = kwargs.get('db_instance_identifier')
|
self.db_instance_identifier = kwargs.get('db_instance_identifier')
|
||||||
self.db_name = kwargs.get("db_name")
|
self.db_name = kwargs.get("db_name")
|
||||||
self.publicly_accessible = kwargs.get("publicly_accessible")
|
self.publicly_accessible = kwargs.get("publicly_accessible")
|
||||||
@ -241,6 +243,22 @@ class Database(BaseModel):
|
|||||||
return self.port
|
return self.port
|
||||||
raise UnformattedGetAttTemplateException()
|
raise UnformattedGetAttTemplateException()
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def default_port(engine):
|
||||||
|
return {
|
||||||
|
'mysql': 3306,
|
||||||
|
'mariadb': 3306,
|
||||||
|
'postgres': 5432,
|
||||||
|
'oracle-ee': 1521,
|
||||||
|
'oracle-se2': 1521,
|
||||||
|
'oracle-se1': 1521,
|
||||||
|
'oracle-se': 1521,
|
||||||
|
'sqlserver-ee': 1433,
|
||||||
|
'sqlserver-ex': 1433,
|
||||||
|
'sqlserver-se': 1433,
|
||||||
|
'sqlserver-web': 1433,
|
||||||
|
}[engine]
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def create_from_cloudformation_json(cls, resource_name, cloudformation_json, region_name):
|
def create_from_cloudformation_json(cls, resource_name, cloudformation_json, region_name):
|
||||||
properties = cloudformation_json['Properties']
|
properties = cloudformation_json['Properties']
|
||||||
|
@ -973,6 +973,20 @@ def test_create_db_instance_with_parameter_group():
|
|||||||
'ParameterApplyStatus'].should.equal('in-sync')
|
'ParameterApplyStatus'].should.equal('in-sync')
|
||||||
|
|
||||||
|
|
||||||
|
@disable_on_py3()
|
||||||
|
@mock_rds2
|
||||||
|
def test_create_database_with_default_port():
|
||||||
|
conn = boto3.client('rds', region_name='us-west-2')
|
||||||
|
database = conn.create_db_instance(DBInstanceIdentifier='db-master-1',
|
||||||
|
AllocatedStorage=10,
|
||||||
|
Engine='postgres',
|
||||||
|
DBInstanceClass='db.m1.small',
|
||||||
|
MasterUsername='root',
|
||||||
|
MasterUserPassword='hunter2',
|
||||||
|
DBSecurityGroups=["my_sg"])
|
||||||
|
database['DBInstance']['Endpoint']['Port'].should.equal(5432)
|
||||||
|
|
||||||
|
|
||||||
@disable_on_py3()
|
@disable_on_py3()
|
||||||
@mock_rds2
|
@mock_rds2
|
||||||
def test_modify_db_instance_with_parameter_group():
|
def test_modify_db_instance_with_parameter_group():
|
||||||
|
Loading…
Reference in New Issue
Block a user