serverless-application-model icon indicating copy to clipboard operation
serverless-application-model copied to clipboard

Added encryptionconfiguration support for WS::Serverless::StateMachine

Open VanditGupta opened this issue 6 months ago • 1 comments

Summary

Passthrough EncryptionConfiguration from AWS::Serverless::StateMachine to AWS::StepFunctions::StateMachine, enabling customer-managed KMS encryption for Step Functions state machines defined in SAM templates.

Issue

Fixes #3925

Description of changes

  • Added EncryptionConfiguration as a pass-through property on AWS::Serverless::StateMachine (sam_resources.py).
  • Updated StateMachineGenerator to set EncryptionConfiguration on the generated AWS::StepFunctions::StateMachine resource (generators.py, stepfunctions/resources.py).
  • Updated SAM schema and documentation:
    • samtranslator/internal/schema_source/aws_serverless_statemachine.py
    • samtranslator/internal/schema_source/sam-docs.json
    • Regenerated schema_source/sam.schema.json and samtranslator/schema/schema.json
  • Added translator test case state_machine_with_encryption_configuration (input + expected output for aws, aws-cn, and aws-us-gov).

Example SAM usage:

MyStateMachine:
  Type: AWS::Serverless::StateMachine
  Properties:
    Definition:
      StartAt: Hello
      States:
        Hello:
          Type: Pass
          End: true
    EncryptionConfiguration:
      Type: CUSTOMER_MANAGED_KMS_KEY
      KmsKeyId: !GetAtt MyKmsKey.Arn
      KmsDataKeyReusePeriodSeconds: 300
    Policies:
      - ...

Transforms to AWS::StepFunctions::StateMachine with the same EncryptionConfiguration block, aligned with CloudFormation EncryptionConfiguration.

Description of how you validated changes

  • Ran translator tests for the new fixture across partitions:

    pytest tests/translator/test_translator.py -k state_machine_with_encryption_configuration -o addopts=
    

    (3 passed: aws, aws-cn, aws-us-gov)

  • Ran existing state machine generator unit tests:

    pytest tests/model/stepfunctions/test_state_machine_generator.py -o addopts=
    

    (15 passed)

  • Regenerated schemas and confirmed they match committed files:

    python3 -m samtranslator.internal.schema_source.schema \
      --sam-schema .tmp/sam.schema.json \
      --cfn-schema schema_source/cloudformation.schema.json \
      --unified-schema .tmp/schema.json
    diff schema_source/sam.schema.json .tmp/sam.schema.json
    diff samtranslator/schema/schema.json .tmp/schema.json
    

Checklist

Examples?

N/A — no new sam init example template in this PR.


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

VanditGupta avatar May 29 '26 03:05 VanditGupta

Hi, I have pushed another commit to address the failing tests!

VanditGupta avatar Jun 02 '26 01:06 VanditGupta