AWSTemplateFormatVersion: "2010-09-09"
Transform: AWS::Serverless-2016-10-31

Globals:
  Function:
    Timeout: 10

Parameters:
  HelloWorldLayerName:
    Type: String
    Description: Name of the HelloWorldLayer which will be used with current deployment

Resources:
  HelloWorldFunction:
    Type: AWS::Serverless::Function
    Properties:
      CodeUri: before/Python/function/
      Handler: app.lambda_handler
      Runtime: python3.7
      Layers:
        - Ref: HelloWorldLayer
      Tracing: Active

  HelloWorldApi:
    Type: AWS::Serverless::Api
    Properties:
      StageName: prod
      DefinitionUri: before/Python/apigateway/definition.json

  HelloWorldApiV2:
    Type: AWS::Serverless::HttpApi
    Properties:
      StageName: beta
      DefinitionUri: before/Python/apigateway2/definition.yaml

  HelloWorldLayer:
    Type: AWS::Serverless::LayerVersion
    Properties:
      LayerName: !Ref HelloWorldLayerName
      Description: Hello World Layer
      ContentUri: before/Python/layer/
      CompatibleRuntimes:
        - python3.7
    Metadata:
      BuildMethod: python3.7

  HelloStepFunction:
    Type: AWS::Serverless::StateMachine
    Properties:
      DefinitionUri: before/Python/statemachine/function.asl.json
      Policies:
        - LambdaInvokePolicy:
            FunctionName: !Ref HelloWorldFunction