Skip to content

Commit

Permalink
RDS: update_db_instance() now supports the CloudwatchLogsExportConfig…
Browse files Browse the repository at this point in the history
…uration-parameter (#7993)
  • Loading branch information
bblommers committed Aug 17, 2024
1 parent 479cc5d commit a42d9d1
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 13 deletions.
7 changes: 7 additions & 0 deletions moto/rds/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -999,6 +999,13 @@ def update(self, db_kwargs: Dict[str, Any]) -> None:
if value is not None:
setattr(self, key, value)

cwl_exports = db_kwargs.get("cloudwatch_logs_exports_config") or {}
for exp in cwl_exports.get("DisableLogTypes", []):
self.enabled_cloudwatch_logs_exports.remove(exp)
self.enabled_cloudwatch_logs_exports.extend(
cwl_exports.get("EnableLogTypes", [])
)

@classmethod
def has_cfn_attr(cls, attr: str) -> bool:
return attr in ["Endpoint.Address", "Endpoint.Port"]
Expand Down
3 changes: 3 additions & 0 deletions moto/rds/responses.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ def _get_db_kwargs(self) -> Dict[str, Any]:
"enable_cloudwatch_logs_exports": self._get_params().get(
"EnableCloudwatchLogsExports"
),
"cloudwatch_logs_exports_config": self._get_params().get(
"CloudwatchLogsExportConfiguration"
),
"enable_iam_database_authentication": self._get_bool_param(
"EnableIAMDatabaseAuthentication"
),
Expand Down
25 changes: 12 additions & 13 deletions tests/test_rds/test_rds.py
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,7 @@ def test_describe_non_existent_database():
def test_modify_db_instance():
conn = boto3.client("rds", region_name=DEFAULT_REGION)
conn.create_db_instance(
DBInstanceIdentifier="db-master-1",
DBInstanceIdentifier="db-id",
AllocatedStorage=10,
DBInstanceClass="postgres",
Engine="postgres",
Expand All @@ -560,23 +560,22 @@ def test_modify_db_instance():
Port=1234,
DBSecurityGroups=["my_sg"],
)
instances = conn.describe_db_instances(DBInstanceIdentifier="db-master-1")
assert instances["DBInstances"][0]["AllocatedStorage"] == 10
inst = conn.describe_db_instances(DBInstanceIdentifier="db-id")["DBInstances"][0]
assert inst["AllocatedStorage"] == 10
assert inst["EnabledCloudwatchLogsExports"] == []

conn.modify_db_instance(
DBInstanceIdentifier="db-master-1",
DBInstanceIdentifier="db-id",
AllocatedStorage=20,
ApplyImmediately=True,
VpcSecurityGroupIds=["sg-123456"],
CloudwatchLogsExportConfiguration={"EnableLogTypes": ["error"]},
)
instances = conn.describe_db_instances(DBInstanceIdentifier="db-master-1")
assert instances["DBInstances"][0]["AllocatedStorage"] == 20
assert instances["DBInstances"][0]["PreferredMaintenanceWindow"] == (
"wed:06:38-wed:07:08"
)
assert (
instances["DBInstances"][0]["VpcSecurityGroups"][0]["VpcSecurityGroupId"]
== "sg-123456"
)
inst = conn.describe_db_instances(DBInstanceIdentifier="db-id")["DBInstances"][0]
assert inst["AllocatedStorage"] == 20
assert inst["PreferredMaintenanceWindow"] == "wed:06:38-wed:07:08"
assert inst["VpcSecurityGroups"][0]["VpcSecurityGroupId"] == "sg-123456"
assert inst["EnabledCloudwatchLogsExports"] == ["error"]


@mock_aws
Expand Down

0 comments on commit a42d9d1

Please sign in to comment.