AWSTemplateFormatVersion: '2010-09-09' Transform: AWS::Serverless-2016-10-31 Description: > A Step Functions Express Workflow triggered synchronously by an API Gateway HTTP APIs integration Resources: ########################################################################## # STEP FUNCTION # ########################################################################## StateMachineExpressSync: 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: Name: StateMachineExpressSync DefinitionUri: statemachine/stateMachine.asl.json Policies: - Version: "2012-10-17" Statement: - Effect: Allow Action: - "cloudwatch:*" - "logs:*" Resource: "*" Type: EXPRESS Logging: Destinations: - CloudWatchLogsLogGroup: LogGroupArn: !GetAtt StateMachineLogGroup.Arn IncludeExecutionData: false Level: 'ALL' ########################################################################## # STEP FUNCTION LOG GROUP # ########################################################################## StateMachineLogGroup: Type: AWS::Logs::LogGroup Properties: LogGroupName: !Join [ "/", [ "stepfunctions", StateMachineExpressSync]] ########################################################################## # REST API # ########################################################################## RestApiforSyncWF: Type: AWS::Serverless::Api Properties: StageName: dev DefinitionBody: # an OpenApi definition 'Fn::Transform': Name: 'AWS::Include' Parameters: Location: './api.yaml' OpenApiVersion: 3.0.3 EndpointConfiguration: Type: REGIONAL ########################################################################## # Roles # ########################################################################## RestApiRole: Type: 'AWS::IAM::Role' Properties: AssumeRolePolicyDocument: Version: 2012-10-17 Statement: - Effect: Allow Principal: Service: - apigateway.amazonaws.com Action: - 'sts:AssumeRole' Policies: - PolicyName: AllowSFNExec PolicyDocument: Version: 2012-10-17 Statement: - Effect: Allow Action: "states:StartSyncExecution" Resource: !GetAtt StateMachineExpressSync.Arn ########################################################################## # Outputs # ########################################################################## Outputs: HelloWorldApi: Description: "Sync WF API endpoint" Value: !Sub "https://${RestApiforSyncWF}.execute-api.${AWS::Region}.amazonaws.com/dev"