AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Globals:
  Function:
    Environment:
      Variables:
        APP_ENV: prod
Resources:
  Website:
    Type: AWS::Serverless::Function
    Properties:
      FunctionName: 'kontatudo-site'
      CodeUri: .
      Handler: public/index.php
      Timeout: 30 # in seconds (API Gateway has a timeout of 30 seconds)
      MemorySize: 1024
      Runtime: provided
      Layers:
        - 'arn:aws:lambda:us-east-2:209497400698:layer:php-73-fpm:18'
      Events:
        HttpRoot:
          Type: Api
          Properties:
            Path: /
            Method: ANY
        HttpSubPaths:
          Type: Api
          Properties:
            Path: /{proxy+}
            Method: ANY
  Console:
    Type: AWS::Serverless::Function
    Properties:
      FunctionName: 'kontatudo-console'
      CodeUri: .
      Handler: bin/console
      Timeout: 120 # in seconds
      Runtime: provided
      Layers:
        - 'arn:aws:lambda:us-east-2:209497400698:layer:php-73-fpm:18' # PHP
        - 'arn:aws:lambda:us-east-2:209497400698:layer:console:7' # The "console" layer
Outputs:
  DemoApi:
    Description: 'URL of our function in the *Prod* environment'
    Value: !Sub 'https://${ServerlessRestApi}.execute-api.${AWS::Region}.amazonaws.com/Prod/' 
  |