Ministack: Free, open-source local AWS emulator - 60+ services, Terraform compatible, real databases. Free forever. MIT licensed.
Python awsaws-emulatoraws-localaws-sdkdevtoolsdockerdynamodbec2emulatorlambdalocalstacklocalstack-alternativeministackmock-awsopen-sourcepythons3sqsterraform
fix(cloudformation): delete AWS::Logs::LogGroup through the Logs service (#2139)
iot-rocketa98ec3e5bf8f
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 417dce66..683cca21 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -9,6 +9,7 @@ Versioning follows [Semantic Versioning](https://semver.org/).### Fixed+- **CloudFormation — `AWS::Logs::LogGroup` delete** — a stack delete or a `LogGroupName` replacement removed only the group record, so a metric filter or resource policy added through the Logs API stayed and came back with a new group of the same name; the group is now deleted through `DeleteLogGroup`. Contributed by @iot-rocket.- **Cognito Identity — `GetOpenIdToken` claims** — the token was a user-pool ID token with an empty audience; it is now issued by `https://cognito-identity.amazonaws.com` with the identity pool id as `aud`, the identity id as `sub`, an `amr` list naming the login providers and the user-pool sign-in, the pool ARN in `https://cognito-identity.amazonaws.com/identity-pool-arn` and a 10-minute lifetime. An identity id that no pool knows gets `ResourceNotFoundException` instead of a token. Contributed by @iot-rocket.- **CloudTrail — new trails start with logging off** — `CreateTrail` left a new trail logging, and `GetTrailStatus` reported a `StartLoggingTime` an hour back and a `LatestDeliveryTime` of now. A new trail now reports `IsLogging` false until `StartLogging`, and `GetTrailStatus` returns only the `StartLoggingTime` and `StopLoggingTime` of calls made (a restart keeps the last stop time), without `LatestDeliveryTime` or empty error strings. Contributed by @iot-rocket.## [1.5.26] — 2026-10-11diff --git a/ministack/services/cloudformation/provisioners.py b/ministack/services/cloudformation/provisioners.pyindex 72a00b7a..98c0abf1 100644--- a/ministack/services/cloudformation/provisioners.py+++ b/ministack/services/cloudformation/provisioners.py@@ -3377,7 +3377,8 @@ def _cwlogs_import(identifier):def _cwlogs_delete(physical_id, props):- _cw_logs._log_groups.pop(physical_id, None)+ """Delete through DeleteLogGroup, which also drops the group's metric filters, policy and records."""+ _cw_logs._delete_log_group({"logGroupName": physical_id})# --- CloudWatch Logs ResourcePolicy ---diff --git a/tests/test_cfn.py b/tests/test_cfn.pyindex 71110ec1..d6284796 100644--- a/tests/test_cfn.py+++ b/tests/test_cfn.py@@ -21128,6 +21128,53 @@ def test_cfn_update_logs_log_group_in_place(cfn, logs):_delete_cfn_test_stack(cfn, stack_name)[email protected]("rename", [False, True], ids=["delete", "rename"])+def test_cfn_logs_log_group_removal_drops_api_metric_filters(cfn, logs, rename):+ """A stack delete or a LogGroupName replacement drops the group's API metric filters."""+ uid = _uuid_mod.uuid4().hex[:8]+ stack_name = f"cfn-logs-gone-{uid}"+ group = f"/cfn/logs-gone-{uid}"+ namespace = f"CfnGone{uid}"++ def tpl(name):+ return json.dumps({"Resources": {+ "Group": {"Type": "AWS::Logs::LogGroup", "Properties": {"LogGroupName": name}},+ }})++ def described():+ return [g for g in logs.describe_log_groups(logGroupNamePrefix=group)["logGroups"]+ if g["logGroupName"] == group]++ cfn.create_stack(StackName=stack_name, TemplateBody=tpl(group))+ try:+ stack = _wait_stack(cfn, stack_name)+ assert stack["StackStatus"] == "CREATE_COMPLETE", stack.get("StackStatusReason")+ logs.put_metric_filter(+ logGroupName=group, filterName="api", filterPattern='"ERROR"',+ metricTransformations=[{"metricNamespace": namespace, "metricName": "Errors", "metricValue": "1"}])++ if rename:+ cfn.update_stack(StackName=stack_name, TemplateBody=tpl(f"{group}-new"))+ stack = _wait_stack(cfn, stack_name)+ assert stack["StackStatus"] == "UPDATE_COMPLETE", stack.get("StackStatusReason")+ else:+ cfn.delete_stack(StackName=stack_name)+ _wait_stack(cfn, stack_name)+ assert described() == []+ assert logs.describe_metric_filters(+ metricNamespace=namespace, metricName="Errors")["metricFilters"] == []++ logs.create_log_group(logGroupName=group)+ assert described()[0]["metricFilterCount"] == 0+ assert logs.describe_metric_filters(logGroupName=group)["metricFilters"] == []+ finally:+ _delete_cfn_test_stack(cfn, stack_name)+ try:+ logs.delete_log_group(logGroupName=group)+ except ClientError:+ pass++def test_cfn_update_s3_bucket_policy_in_place(cfn, s3):"""A bucket policy's document is rewritten in place on the same bucket."""suffix = _uuid_mod.uuid4().hex[:8]