Skip to content

Commit c59ab8f

Browse files
authored
CloudFormation: Fix LoggingConfiguration Parameter Handling in StepFunctions Resource Provider (#12433)
1 parent 8489276 commit c59ab8f

File tree

5 files changed

+132
-0
lines changed

5 files changed

+132
-0
lines changed

localstack-core/localstack/services/stepfunctions/resource_providers/aws_stepfunctions_statemachine.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,9 @@ def create(
110110
"roleArn": model.get("RoleArn"),
111111
"type": model.get("StateMachineType", "STANDARD"),
112112
}
113+
logging_configuration = model.get("LoggingConfiguration")
114+
if logging_configuration is not None:
115+
params["loggingConfiguration"] = logging_configuration
113116

114117
# get definition
115118
s3_client = request.aws_client_factory.s3
@@ -221,6 +224,9 @@ def update(
221224
"stateMachineArn": model["Arn"],
222225
"definition": definition_str,
223226
}
227+
logging_configuration = model.get("LoggingConfiguration")
228+
if logging_configuration is not None:
229+
params["loggingConfiguration"] = logging_configuration
224230

225231
step_function.update_state_machine(**params)
226232

tests/aws/services/cloudformation/resources/test_stepfunctions.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,3 +352,31 @@ def test_cfn_statemachine_default_s3_location(
352352
sfn_snapshot.match(
353353
"describe_state_machine_output_on_update", describe_state_machine_output_on_update
354354
)
355+
356+
357+
@markers.aws.validated
358+
@markers.snapshot.skip_snapshot_verify(
359+
paths=["$..encryptionConfiguration", "$..tracingConfiguration"]
360+
)
361+
def test_statemachine_create_with_logging_configuration(
362+
deploy_cfn_template, aws_client, sfn_snapshot
363+
):
364+
sfn_snapshot.add_transformers_list(
365+
[
366+
JsonpathTransformer("$..roleArn", "role-arn"),
367+
JsonpathTransformer("$..stateMachineArn", "state-machine-arn"),
368+
JsonpathTransformer("$..name", "state-machine-name"),
369+
JsonpathTransformer("$..logGroupArn", "log-group-arn"),
370+
]
371+
)
372+
stack = deploy_cfn_template(
373+
template_path=os.path.join(
374+
os.path.dirname(__file__),
375+
"../../../templates/statemachine_machine_logging_configuration.yml",
376+
)
377+
)
378+
statemachine_arn = stack.outputs["StateMachineArnOutput"]
379+
describe_state_machine_result = aws_client.stepfunctions.describe_state_machine(
380+
stateMachineArn=statemachine_arn
381+
)
382+
sfn_snapshot.match("describe_state_machine_result", describe_state_machine_result)

tests/aws/services/cloudformation/resources/test_stepfunctions.snapshot.json

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,5 +66,48 @@
6666
}
6767
}
6868
}
69+
},
70+
"tests/aws/services/cloudformation/resources/test_stepfunctions.py::test_statemachine_create_with_logging_configuration": {
71+
"recorded-date": "24-03-2025, 21:58:55",
72+
"recorded-content": {
73+
"describe_state_machine_result": {
74+
"creationDate": "datetime",
75+
"definition": {
76+
"StartAt": "S0",
77+
"States": {
78+
"S0": {
79+
"Type": "Pass",
80+
"End": true
81+
}
82+
}
83+
},
84+
"encryptionConfiguration": {
85+
"type": "AWS_OWNED_KEY"
86+
},
87+
"loggingConfiguration": {
88+
"destinations": [
89+
{
90+
"cloudWatchLogsLogGroup": {
91+
"logGroupArn": "<log-group-arn:1>"
92+
}
93+
}
94+
],
95+
"includeExecutionData": true,
96+
"level": "ALL"
97+
},
98+
"name": "<state-machine-name:1>",
99+
"roleArn": "<role-arn:1>",
100+
"stateMachineArn": "<state-machine-arn:1>",
101+
"status": "ACTIVE",
102+
"tracingConfiguration": {
103+
"enabled": false
104+
},
105+
"type": "STANDARD",
106+
"ResponseMetadata": {
107+
"HTTPHeaders": {},
108+
"HTTPStatusCode": 200
109+
}
110+
}
111+
}
69112
}
70113
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
{
22
"tests/aws/services/cloudformation/resources/test_stepfunctions.py::test_cfn_statemachine_default_s3_location": {
33
"last_validated_date": "2024-12-17T16:06:46+00:00"
4+
},
5+
"tests/aws/services/cloudformation/resources/test_stepfunctions.py::test_statemachine_create_with_logging_configuration": {
6+
"last_validated_date": "2025-03-24T21:58:55+00:00"
47
}
58
}
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
AWSTemplateFormatVersion: '2010-09-09'
2+
3+
Resources:
4+
StateMachineRole:
5+
Type: AWS::IAM::Role
6+
Properties:
7+
AssumeRolePolicyDocument:
8+
Version: '2012-10-17'
9+
Statement:
10+
- Effect: Allow
11+
Principal:
12+
Service: states.amazonaws.com
13+
Action: sts:AssumeRole
14+
Policies:
15+
- PolicyName: StateMachineFullAccess
16+
PolicyDocument:
17+
Version: '2012-10-17'
18+
Statement:
19+
- Effect: Allow
20+
Action: "*"
21+
Resource: "*"
22+
23+
LogGroup:
24+
Type: AWS::Logs::LogGroup
25+
Properties:
26+
RetentionInDays: 14
27+
28+
StateMachine:
29+
Type: AWS::StepFunctions::StateMachine
30+
Properties:
31+
StateMachineType: STANDARD
32+
RoleArn: !GetAtt StateMachineRole.Arn
33+
DefinitionString: |
34+
{
35+
"StartAt": "S0",
36+
"States": {
37+
"S0": {
38+
"Type": "Pass",
39+
"End": true
40+
}
41+
}
42+
}
43+
LoggingConfiguration:
44+
Destinations:
45+
- CloudWatchLogsLogGroup:
46+
LogGroupArn: !GetAtt LogGroup.Arn
47+
IncludeExecutionData: true
48+
Level: ALL
49+
50+
Outputs:
51+
StateMachineArnOutput:
52+
Value: !Ref StateMachine

0 commit comments

Comments
 (0)