AWSTemplateFormatVersion: '2010-09-09' Transform: AWS::Serverless-2016-10-31 Description: > A Step Functions Express Workflow triggered syncronously by an API Gatewat HTTP APIs integration Resources: ########################################################################## # STEP FUNCTION # ########################################################################## StateMachineExpressSynctoLambda: Type: AWS::Serverless::StateMachine # More info about State Machine Resource: https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-resource-statemachine.html Properties: DefinitionUri: statemachine/StateMachine.asl.json DefinitionSubstitutions: GenerateRefernceNumberArn: !GetAtt GenerateRefernceNumber.Arn Role: Fn::GetAtt: [ StatesExecutionRole, Arn ] Type: EXPRESS Logging: Destinations: - CloudWatchLogsLogGroup: LogGroupArn: !GetAtt StateMachineLogGroup.Arn IncludeExecutionData: false Level: 'ALL' ########################################################################## # Lambda function # ########################################################################## GenerateRefernceNumber: Type: AWS::Serverless::Function # More info about Function Resource: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#awsserverlessfunction Properties: CodeUri: src/ Handler: app.handler Runtime: nodejs12.x Timeout: 3 Policies: - CloudWatchPutMetricPolicy: {} ########################################################################## # STEP FUNCTION LOG GROUP # ########################################################################## StateMachineLogGroup: Type: AWS::Logs::LogGroup Properties: LogGroupName: !Join [ "/", [ "stepfunctions", StateMachineExpressSynctoLambda]] ########################################################################## # Roles # ########################################################################## StatesExecutionRole: Type: "AWS::IAM::Role" Properties: AssumeRolePolicyDocument: Version: "2012-10-17" Statement: - Effect: "Allow" Principal: Service: - !Sub states.${AWS::Region}.amazonaws.com Action: "sts:AssumeRole" Path: "/" Policies: - PolicyName: LambdaExecute PolicyDocument: Version: "2012-10-17" Statement: - Effect: Allow Action: - "lambda:InvokeFunction" Resource: !GetAtt GenerateRefernceNumber.Arn ########################################################################## # Outputs # ########################################################################## Outputs: StateMachineExpressSynctoLambda: Value: !Ref StateMachineExpressSynctoLambda Description: StateMachineExpressSynctoLambda Arn