AWSTemplateFormatVersion: '2010-09-09' Transform: AWS::Serverless-2016-10-31 Description: APPNAMEHERE Lambda (HTTP API)

Parameters:

RailsEnv:
  Type: String
  Default: production
  AllowedValues:
    - staging
    - production

Resources:

RailsLambda:
  Type: AWS::Serverless::Function
  Metadata:
    DockerContext: .
    Dockerfile: Dockerfile
  Properties:
    MemorySize: 512
    Timeout: 30
    Environment:
      Variables:
        RAILS_ENV: !Ref RailsEnv
    FunctionName: !Join [ '', [ 'APPNAMEHERE-', !Ref RailsEnv, '-', !Ref 'AWS::Region' ] ]
    Events:
      RailsApiProxy:
        Type: HttpApi
        Properties:
          ApiId: !Ref RailsApi
    PackageType: Image

RailsApi:
  Type: AWS::Serverless::HttpApi
  Properties:
    StageName: !Ref RailsEnv

Outputs:

RailsApiUrl:
  Description: API Gateway Endpoint
  Value: !Sub "https://${RailsApi}.execute-api.${AWS::Region}.amazonaws.com/${RailsEnv}/"

RailsLambdaArn:
  Description: Lambda ARN
  Value: !GetAtt RailsLambda.Arn