RDS: create_db_cluster() now supports the VpcSecurityGroupIds-parameter (#6567)
This commit is contained in:
parent
b52fd80cb1
commit
35ab6cefe8
@ -182,7 +182,7 @@ class Cluster:
|
|||||||
self.preferred_backup_window = "01:37-02:07"
|
self.preferred_backup_window = "01:37-02:07"
|
||||||
self.preferred_maintenance_window = "wed:02:40-wed:03:10"
|
self.preferred_maintenance_window = "wed:02:40-wed:03:10"
|
||||||
# This should default to the default security group
|
# This should default to the default security group
|
||||||
self.vpc_security_groups: List[str] = []
|
self.vpc_security_group_ids: List[str] = kwargs["vpc_security_group_ids"]
|
||||||
self.hosted_zone_id = "".join(
|
self.hosted_zone_id = "".join(
|
||||||
random.choice(string.ascii_uppercase + string.digits) for _ in range(14)
|
random.choice(string.ascii_uppercase + string.digits) for _ in range(14)
|
||||||
)
|
)
|
||||||
@ -329,7 +329,7 @@ class Cluster:
|
|||||||
{% endfor %}
|
{% endfor %}
|
||||||
</DBClusterMembers>
|
</DBClusterMembers>
|
||||||
<VpcSecurityGroups>
|
<VpcSecurityGroups>
|
||||||
{% for id in cluster.vpc_security_groups %}
|
{% for id in cluster.vpc_security_group_ids %}
|
||||||
<VpcSecurityGroup>
|
<VpcSecurityGroup>
|
||||||
<VpcSecurityGroupId>{{ id }}</VpcSecurityGroupId>
|
<VpcSecurityGroupId>{{ id }}</VpcSecurityGroupId>
|
||||||
<Status>active</Status>
|
<Status>active</Status>
|
||||||
|
@ -211,6 +211,9 @@ class RDSResponse(BaseResponse):
|
|||||||
"replication_source_identifier": self._get_param(
|
"replication_source_identifier": self._get_param(
|
||||||
"ReplicationSourceIdentifier"
|
"ReplicationSourceIdentifier"
|
||||||
),
|
),
|
||||||
|
"vpc_security_group_ids": self.unpack_list_params(
|
||||||
|
"VpcSecurityGroupIds", "VpcSecurityGroupId"
|
||||||
|
),
|
||||||
}
|
}
|
||||||
|
|
||||||
def _get_export_task_kwargs(self) -> Dict[str, Any]:
|
def _get_export_task_kwargs(self) -> Dict[str, Any]:
|
||||||
|
@ -193,29 +193,13 @@ def test_create_db_cluster__verify_default_properties():
|
|||||||
).should.be.greater_than_or_equal_to(cluster["ClusterCreateTime"])
|
).should.be.greater_than_or_equal_to(cluster["ClusterCreateTime"])
|
||||||
|
|
||||||
|
|
||||||
@mock_rds
|
|
||||||
def test_create_db_cluster_with_database_name():
|
|
||||||
client = boto3.client("rds", region_name="eu-north-1")
|
|
||||||
|
|
||||||
resp = client.create_db_cluster(
|
|
||||||
DBClusterIdentifier="cluster-id",
|
|
||||||
DatabaseName="users",
|
|
||||||
Engine="aurora",
|
|
||||||
MasterUsername="root",
|
|
||||||
MasterUserPassword="hunter2_",
|
|
||||||
)
|
|
||||||
cluster = resp["DBCluster"]
|
|
||||||
cluster.should.have.key("DatabaseName").equal("users")
|
|
||||||
cluster.should.have.key("DBClusterIdentifier").equal("cluster-id")
|
|
||||||
cluster.should.have.key("DBClusterParameterGroup").equal("default.aurora8.0")
|
|
||||||
|
|
||||||
|
|
||||||
@mock_rds
|
@mock_rds
|
||||||
def test_create_db_cluster_additional_parameters():
|
def test_create_db_cluster_additional_parameters():
|
||||||
client = boto3.client("rds", region_name="eu-north-1")
|
client = boto3.client("rds", region_name="eu-north-1")
|
||||||
|
|
||||||
resp = client.create_db_cluster(
|
resp = client.create_db_cluster(
|
||||||
AvailabilityZones=["eu-north-1b"],
|
AvailabilityZones=["eu-north-1b"],
|
||||||
|
DatabaseName="users",
|
||||||
DBClusterIdentifier="cluster-id",
|
DBClusterIdentifier="cluster-id",
|
||||||
Engine="aurora",
|
Engine="aurora",
|
||||||
EngineVersion="8.0.mysql_aurora.3.01.0",
|
EngineVersion="8.0.mysql_aurora.3.01.0",
|
||||||
@ -232,11 +216,13 @@ def test_create_db_cluster_additional_parameters():
|
|||||||
"MinCapacity": 5,
|
"MinCapacity": 5,
|
||||||
"AutoPause": True,
|
"AutoPause": True,
|
||||||
},
|
},
|
||||||
|
VpcSecurityGroupIds=["sg1", "sg2"],
|
||||||
)
|
)
|
||||||
|
|
||||||
cluster = resp["DBCluster"]
|
cluster = resp["DBCluster"]
|
||||||
|
|
||||||
cluster.should.have.key("AvailabilityZones").equal(["eu-north-1b"])
|
cluster.should.have.key("AvailabilityZones").equal(["eu-north-1b"])
|
||||||
|
cluster.should.have.key("DatabaseName").equal("users")
|
||||||
cluster.should.have.key("Engine").equal("aurora")
|
cluster.should.have.key("Engine").equal("aurora")
|
||||||
cluster.should.have.key("EngineVersion").equal("8.0.mysql_aurora.3.01.0")
|
cluster.should.have.key("EngineVersion").equal("8.0.mysql_aurora.3.01.0")
|
||||||
cluster.should.have.key("EngineMode").equal("serverless")
|
cluster.should.have.key("EngineMode").equal("serverless")
|
||||||
@ -248,6 +234,11 @@ def test_create_db_cluster_additional_parameters():
|
|||||||
assert cluster["DBSubnetGroup"] == "subnetgroupname"
|
assert cluster["DBSubnetGroup"] == "subnetgroupname"
|
||||||
assert cluster["ScalingConfigurationInfo"] == {"MinCapacity": 5, "AutoPause": True}
|
assert cluster["ScalingConfigurationInfo"] == {"MinCapacity": 5, "AutoPause": True}
|
||||||
|
|
||||||
|
security_groups = cluster["VpcSecurityGroups"]
|
||||||
|
assert len(security_groups) == 2
|
||||||
|
assert {"VpcSecurityGroupId": "sg1", "Status": "active"} in security_groups
|
||||||
|
assert {"VpcSecurityGroupId": "sg2", "Status": "active"} in security_groups
|
||||||
|
|
||||||
|
|
||||||
@mock_rds
|
@mock_rds
|
||||||
def test_describe_db_cluster_after_creation():
|
def test_describe_db_cluster_after_creation():
|
||||||
|
Loading…
Reference in New Issue
Block a user