8000 CloudFormation: Fix LoggingConfiguration Parameter Handling in StepFunctions Resource Provider by MEPalma · Pull Request #12433 · localstack/localstack · GitHub
[go: up one dir, main page]

Skip to content

CloudFormation: Fix LoggingConfiguration Parameter Handling in StepFunctions Resource Provider #12433

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 26, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,9 @@ def create(
"roleArn": model.get("RoleArn"),
"type": model.get("StateMachineType", "STANDARD"),
}
logging_configuration = model.get("LoggingConfiguration")
if logging_configuration is not None:
params["loggingConfiguration"] = logging_configuration

# get definition
s3_client = request.aws_client_factory.s3
Expand Down Expand Up @@ -221,6 +224,9 @@ def update(
"stateMachineArn": model["Arn"],
"definition": definition_str,
}
logging_configuration = model.get("LoggingConfiguration")
if logging_configuration is not None:
params["loggingConfiguration"] = logging_configuration

step_function.update_state_machine(**params)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -352,3 +352,31 @@ def test_cfn_statemachine_default_s3_location(
sfn_snapshot.match(
"describe_state_machine_output_on_update", describe_state_machine_output_on_update
)


@markers.aws.validated
@markers.snapshot.skip_snapshot_verify(
paths=["$..encryptionConfiguration", "$..tracingConfiguration"]
)
def test_statemachine_create_with_logging_configuration(
deploy_cfn_template, aws_client, sfn_snapshot
):
sfn_snapshot.add_transformers_list(
[
JsonpathTransformer("$..roleArn", "role-arn"),
JsonpathTransformer("$..stateMachineArn", "state-machine-arn"),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 It might be worth adding such transformers to the default StepFunctions service transformers in the future for the ones appearing frequently

JsonpathTransformer("$..name", "state-machine-name"),
JsonpathTransformer("$..logGroupArn", "log-group-arn"),
]
)
stack = deploy_cfn_template(
template_path=os.path.join(
os.path.dirname(__file__),
"../../../templates/statemachine_machine_logging_configuration.yml",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style nit: having a path helper or variable could simplify these error-prone ../../.... path navigations

)
)
statemachine_arn = stack.outputs["StateMachineArnOutput"]
describe_state_machine_result = aws_client.stepfunctions.describe_state_machine(
stateMachineArn=statemachine_arn
)
sfn_snapshot.match("describe_state_machine_result", describe_state_machine_result)
Original file line number Diff line number Diff line change
Expand Up @@ -66,5 +66,48 @@
}
}
}
},
"tests/aws/services/cloudformation/resources/test_stepfunctions.py::test_statemachine_create_with_logging_configuration": {
"recorded-date": "24-03-2025, 21:58:55",
"recorded-content": {
"describe_state_machine_result": {
"creationDate": "datetime",
"definition": {
"StartAt": "S0",
"States": {
"S0": {
"Type": "Pass",
"End": true
}
}
},
"encryptionConfiguration": {
"type": "AWS_OWNED_KEY"
},
"loggingConfiguration": {
"destinations": [
{
"cloudWatchLogsLogGroup": {
"logGroupArn": "<log-group-arn:1>"
}
}
],
"includeExecutionData": true,
"level": "ALL"
},
"name": "<state-machine-name:1>",
"roleArn": "<role-arn:1>",
"stateMachineArn": "<state-machine-arn:1>",
"status": "ACTIVE",
"tracingConfiguration": {
"enabled": false
},
"type": "STANDARD",
"ResponseMetadata": {
"HTTPHeaders": {},
"HTTPStatusCode": 200
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
{
"tests/aws/services/cloudformation/resources/test_stepfunctions.py::test_cfn_statemachine_default_s3_location": {
"last_validated_date": "2024-12-17T16:06:46+00:00"
},
"tests/aws/services/cloudformation/resources/test_stepfunctions.py::test_statemachine_create_with_logging_configuration": {
"last_validated_date": "2025-03-24T21:58:55+00:00"
}
}
52 changes: 52 additions & 0 deletions tests/aws/templates/statemachine_machine_logging_configuration.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
AWSTemplateFormatVersion: '2010-09-09'

Resources:
StateMachineRole:
Type: AWS::IAM::Role
Properties:
AssumeRolePolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Allow
Principal:
Service: states.amazonaws.com
Action: sts:AssumeRole
Policies:
- PolicyName: StateMachineFullAccess
PolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Allow
Action: "*"
Resource: "*"

LogGroup:
Type: AWS::Logs::LogGroup
Properties:
RetentionInDays: 14

StateMachine:
Type: AWS::StepFunctions::StateMachine
Properties:
StateMachineType: STANDARD
RoleArn: !GetAtt StateMachineRole.Arn
DefinitionString: |
{
"StartAt": "S0",
"States": {
"S0": {
"Type": "Pass",
"End": true
}
}
}
LoggingConfiguration:
Destinations:
- CloudWatchLogsLogGroup:
LogGroupArn: !GetAtt LogGroup.Arn
IncludeExecutionData: true
Level: ALL

Outputs:
StateMachineArnOutput:
Value: !Ref StateMachine
Loading
0