Skip to content

Ministack: Free, open-source local AWS emulator - 60+ services, Terraform compatible, real databases. Free forever. MIT licensed.

fix(stepfunctions): route aws-sdk:cloudwatchlogs (#1512)

Maximilian Bandle0566809d8d50
diff --git a/ministack/services/stepfunctions.py b/ministack/services/stepfunctions.py
index 28e3aa4e..b6a0eb63 100644
--- a/ministack/services/stepfunctions.py
+++ b/ministack/services/stepfunctions.py
@@ -4323,6 +4323,8 @@ _AWS_SDK_SERVICE_MAP = {
"param_case": "lower-camel",
},
"logs": {"target_prefix": "Logs_20140328", "protocol": "json"},
+ "cloudwatchlogs": {"target_prefix": "Logs_20140328", "protocol": "json",
+ "param_case": "lower-camel", "service_key": "logs"},
"ssm": {"target_prefix": "AmazonSSM", "protocol": "json"},
"eventbridge": {"target_prefix": "AWSEvents", "protocol": "json", "service_key": "events"},
"kinesis": {"target_prefix": "Kinesis_20131202", "protocol": "json"},
@@ -4356,6 +4358,7 @@ _AWS_SDK_ERROR_PREFIX = {
"dynamodb": "DynamoDb",
"sfn": "Sfn",
"logs": "CloudWatchLogs",
+ "cloudwatchlogs": "CloudWatchLogs",
"ssm": "Ssm",
"eventbridge": "EventBridge",
"kinesis": "Kinesis",
diff --git a/tests/test_stepfunctions.py b/tests/test_stepfunctions.py
index ecee6134..d402fcc6 100644
--- a/tests/test_stepfunctions.py
+++ b/tests/test_stepfunctions.py
@@ -805,6 +805,50 @@ def test_sfn_intrinsic_nested(sfn, sfn_sync):
output = json.loads(resp["output"])
assert output["result"] == {"key": "hello"}
+def test_sfn_aws_sdk_cloudwatchlogs_create_and_tag(sfn_sync):
+ """aws-sdk:cloudwatchlogs routes, and takes the parameter case a machine writes."""
+ group = f"/sfn-sdk-test/{_uuid_mod.uuid4().hex[:8]}"
+ group_arn = f"arn:aws:logs:us-east-1:000000000000:log-group:{group}"
+ sm_name = f"sdk-logs-{_uuid_mod.uuid4().hex[:8]}"
+
+ definition = json.dumps({
+ "StartAt": "CreateLogGroup",
+ "States": {
+ "CreateLogGroup": {
+ "Type": "Task",
+ "Resource": "arn:aws:states:::aws-sdk:cloudwatchlogs:createLogGroup",
+ "Parameters": {"LogGroupName": group},
+ "ResultPath": "$.created",
+ "Next": "TagLogGroup",
+ },
+ "TagLogGroup": {
+ "Type": "Task",
+ "Resource": "arn:aws:states:::aws-sdk:cloudwatchlogs:tagResource",
+ "Parameters": {"ResourceArn": group_arn, "Tags": {"owner": "sfn"}},
+ "ResultPath": "$.tagged",
+ "Next": "ReadTags",
+ },
+ "ReadTags": {
+ "Type": "Task",
+ "Resource": "arn:aws:states:::aws-sdk:cloudwatchlogs:listTagsForResource",
+ "Parameters": {"ResourceArn": group_arn},
+ "ResultPath": "$.tags",
+ "End": True,
+ },
+ },
+ })
+
+ sm_arn = sfn_sync.create_state_machine(
+ name=sm_name,
+ definition=definition,
+ roleArn="arn:aws:iam::000000000000:role/sfn-role",
+ )["stateMachineArn"]
+
+ resp = sfn_sync.start_sync_execution(stateMachineArn=sm_arn, input=json.dumps({}))
+ assert resp["status"] == "SUCCEEDED", f"Execution failed: {resp.get('error')} — {resp.get('cause')}"
+ assert json.loads(resp["output"])["tags"]["Tags"] == {"owner": "sfn"}
+
+
def test_sfn_aws_sdk_secretsmanager_create_and_get(sfn, sfn_sync, sm):
"""aws-sdk:secretsmanager integration creates and retrieves a secret."""
import uuid as _uuid