AWSTemplateFormatVersion: '2010-09-09' Transform: AWS::Serverless-2016-10-31 Description: > Async invoke a StepFunctions state machine from a Lambda function Resources: ########################################################################## # Lambda Function # ########################################################################## LambdaProxy: Type: AWS::Serverless::Function Properties: CodeUri: src/ Handler: app.handler Runtime: nodejs12.x Timeout: 3 Policies: - StepFunctionsExecutionPolicy: StateMachineName: !GetAtt StateMachine.Name Environment: Variables: StateMachineArn: !GetAtt StateMachine.Arn ########################################################################## # STEP FUNCTION # ########################################################################## StateMachine: 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 Type: EXPRESS Policies: - Version: "2012-10-17" Statement: - Effect: Allow Action: - "cloudwatch:*" - "logs:*" Resource: "*" Logging: Destinations: - CloudWatchLogsLogGroup: LogGroupArn: !GetAtt StateMachineLogGroup.Arn IncludeExecutionData: false Level: 'ALL' ########################################################################## # STEP FUNCTION LOG GROUP # ########################################################################## StateMachineLogGroup: Type: AWS::Logs::LogGroup Properties: LogGroupName: !Join [ "/", [ "stepfunctions", StateMachine]] Outputs: StateMachine: Value: !GetAtt StateMachine.Arn Description: Statemachine Arn LambdaFuncton: Value: !Ref LambdaProxy Description: Lambda Function Name