AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: >
  Go Driver lambda function test

Parameters:
  MongoDbUri:
    Type: String
    Description: The MongoDB connection string.

Globals:
  Function:
    Timeout: 30

Resources:
  MongoDBFunction:
    Type: AWS::Serverless::Function
    Metadata:
      BuildMethod: go1.x
    Properties:
      CodeUri: mongodb/
      Handler: bootstrap
      Runtime: provided.al2
      Architectures: [arm64]
      Events:
        MongoDB:
          Type: Api
          Properties:
            Path: /mongodb
            Method: GET
      Environment:
        Variables:
          MONGODB_URI: !Ref MongoDbUri

Outputs:
  MongoDBApi:
    Description: "API Gateway endpoint URL for Prod stage for MongoDB function"
    Value: !Sub "https://${ServerlessRestApi}.execute-api.${AWS::Region}.amazonaws.com/Prod/mongodb/"
  MongoDBFunction:
    Description: "MongoDB Lambda Function ARN"
    Value: !GetAtt MongoDBFunction.Arn
  MongoDBFunctionIamRole:
    Description: "Implicit IAM Role created for MongoDB function"
    Value: !GetAtt MongoDBFunctionRole.Arn
