AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: >
  IM-CAPITAL-BACKEND-SERVICE 

  SAM Template for IM-CAPITAL-BACKEND-SERVICE

Parameters:
  Environment:
    Type: String
    Default: dev
    AllowedValues:
      - dev
      - prod
    Description: Environment of this stack of resources

      # More info about Globals: https://github.com/awslabs/serverless-application-model/blob/master/docs/globals.rst
Globals:
  Function:
    Timeout: 30
    MemorySize: 1536
    Runtime: java17
    Architectures:
      - x86_64
    VpcConfig:
      SecurityGroupIds:
        - sg-0089502251d79aa23
      SubnetIds:
        - subnet-08882af1374cdd5d2
        - subnet-0b9b9e77b66be7a4d
    Environment:
      Variables:
        SECRET_NAME: imcapital-dev-mysql-aurora
        REGION: eu-west-1

Resources:
  MyApiGatewayRole:
    Type: AWS::IAM::Role
    Properties:
      AssumeRolePolicyDocument:
        Version: "2012-10-17"
        Statement:
          - Effect: Allow
            Principal:
              Service:
                - amplify.amazonaws.com
            Action: sts:AssumeRole
      Policies:
        - PolicyName: ApiGatewayAccess
          PolicyDocument:
            Version: "2012-10-17"
            Statement:
              - Effect: Allow
                Action:
                  - apigateway:*
                Resource: "*"
  AWSApiGateway:
    Type: AWS::Serverless::Api
    Properties:
      Name: IM-CAPITAL-BACKEND-SERVICE
      StageName: !Sub ${Environment}
      Cors:
        AllowMethods: "'GET, POST, OPTIONS'"
        AllowHeaders: "'*'"
        AllowOrigin: "'*'"
      Auth:
        DefaultAuthorizer:
          Type: AWS_IAM
          AuthorizerId:
            Ref: MyApiGatewayRole

  GetToken:
    Type: AWS::Serverless::Function # More info about Function Resource: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#awsserverlessfunction
    Properties:
      FunctionName: !Sub "${Environment}-GetToken"
      CodeUri: IM-CAPITAL-BACKEND-SERVICE
      Handler: getToken.GetToken::handleRequest
      Role: arn:aws:iam::597707462019:role/IMCapital_serverless_deployment
      Policies:
        - Statement:
              Effect: Allow
              Action:
                - ec2:DescribeNetworkInterfaces
                - ec2:CreateNetworkInterface
                - ec2:DeleteNetworkInterface
                - ec2:DescribeInstances
                - ec2:AttachNetworkInterface
              Resource: '*'
      Events:
        IMCAPITAL:
          Type: Api # More info about API Event Source: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#api
          Properties:
            RestApiId: !Ref AWSApiGateway
            Path: /gettoken
            Method: get

  TokenCheck:
    Type: AWS::Serverless::Function # More info about Function Resource: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#awsserverlessfunction
    Properties:
      FunctionName: !Sub "${Environment}-TokenCheck"
      CodeUri: IM-CAPITAL-BACKEND-SERVICE
      Handler: TokenCheck.TokenCheck::handleRequest
      Role: arn:aws:iam::597707462019:role/IMCapital_serverless_deployment
      Policies:
        - Statement:
              Effect: Allow
              Action:
                - ec2:DescribeNetworkInterfaces
                - ec2:CreateNetworkInterface
                - ec2:DeleteNetworkInterface
                - ec2:DescribeInstances
                - ec2:AttachNetworkInterface
              Resource: '*'
      Events:
        IMCAPITAL:
          Type: Api # More info about API Event Source: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#api
          Properties:
            RestApiId: !Ref AWSApiGateway
            Path: /tokencheck
            Method: get

  StatementData:
    Type: AWS::Serverless::Function # More info about Function Resource: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#awsserverlessfunction
    Properties:
      FunctionName: !Sub "${Environment}-StatementData"
      CodeUri: IM-CAPITAL-BACKEND-SERVICE
      Handler: SanlamStatementData.SanlamStatementData::handleRequest
      Role: arn:aws:iam::597707462019:role/IMCapital_serverless_deployment
      Policies:
        - Statement:
              Effect: Allow
              Action:
                - ec2:DescribeNetworkInterfaces
                - ec2:CreateNetworkInterface
                - ec2:DeleteNetworkInterface
                - ec2:DescribeInstances
                - ec2:AttachNetworkInterface
              Resource: '*'
      Events:
        IMCAPITAL:
          Type: Api # More info about API Event Source: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#api
          Properties:
            RestApiId: !Ref AWSApiGateway
            Path: /statementdata
            Method: post

        IMCAPITALOPTIONS:
          Type: Api # More info about API Event Source: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#api
          Properties:
            RestApiId: !Ref AWSApiGateway
            Path: /statementdata
            Method: options

        IMCAPITALGET:
          Type: Api # More info about API Event Source: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#api
          Properties:
            RestApiId: !Ref AWSApiGateway
            Path: /statementdata
            Method: get

  SubGroupMembers:
    Type: AWS::Serverless::Function # More info about Function Resource: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#awsserverlessfunction
    Properties:
      FunctionName: !Sub "${Environment}-SubGroupMembers"
      CodeUri: IM-CAPITAL-BACKEND-SERVICE
      Handler: SanlamSubGroupMembers.SanlamSubGroupMembers::handleRequest
      Role: arn:aws:iam::597707462019:role/IMCapital_serverless_deployment
      Policies:
        - Statement:
              Effect: Allow
              Action:
                - ec2:DescribeNetworkInterfaces
                - ec2:CreateNetworkInterface
                - ec2:DeleteNetworkInterface
                - ec2:DescribeInstances
                - ec2:AttachNetworkInterface
              Resource: '*'
      Events:
        IMCAPITAL:
          Type: Api # More info about API Event Source: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#api
          Properties:
            RestApiId: !Ref AWSApiGateway
            Path: /subgroupmembers
            Method: get

  RequestOTP:
    Type: AWS::Serverless::Function # More info about Function Resource: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#awsserverlessfunction
    Properties:
      FunctionName: !Sub "${Environment}-RequestOTP"
      CodeUri: IM-CAPITAL-BACKEND-SERVICE
      Handler: RequestOTP.RequestOTP::handleRequest
      Role: arn:aws:iam::597707462019:role/IMCapital_serverless_deployment
      Policies:
        - Statement:
              Effect: Allow
              Action:
                - ec2:DescribeNetworkInterfaces
                - ec2:CreateNetworkInterface
                - ec2:DeleteNetworkInterface
                - ec2:DescribeInstances
                - ec2:AttachNetworkInterface
              Resource: '*'
      Events:
        IMCAPITAL:
          Type: Api # More info about API Event Source: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#api
          Properties:
            RestApiId: !Ref AWSApiGateway
            Path: /requestotp
            Method: get
        IMCAPITALPOST:
          Type: Api # More info about API Event Source: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#api
          Properties:
            RestApiId: !Ref AWSApiGateway
            Path: /requestotp
            Method: post
        IMCAPITALOPTIONS:
          Type: Api # More info about API Event Source: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#api
          Properties:
            RestApiId: !Ref AWSApiGateway
            Path: /requestotp
            Method: options

  ValidateOTP:
    Type: AWS::Serverless::Function # More info about Function Resource: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#awsserverlessfunction
    Properties:
      FunctionName: !Sub "${Environment}-ValidateOTP"
      CodeUri: IM-CAPITAL-BACKEND-SERVICE
      Handler: ValidateOTP.ValidateOTP::handleRequest
      Role: arn:aws:iam::597707462019:role/IMCapital_serverless_deployment
      Policies:
        - Statement:
              Effect: Allow
              Action:
                - ec2:DescribeNetworkInterfaces
                - ec2:CreateNetworkInterface
                - ec2:DeleteNetworkInterface
                - ec2:DescribeInstances
                - ec2:AttachNetworkInterface
              Resource: '*'
      Events:
        IMCAPITAL:
          Type: Api # More info about API Event Source: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#api
          Properties:
            RestApiId: !Ref AWSApiGateway
            Path: /validateotp
            Method: get
        IMCAPITALPOST:
          Type: Api # More info about API Event Source: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#api
          Properties:
            RestApiId: !Ref AWSApiGateway
            Path: /validateotp
            Method: post
        IMCAPITALOPTIONS:
          Type: Api # More info about API Event Source: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#api
          Properties:
            RestApiId: !Ref AWSApiGateway
            Path: /validateotp
            Method: options

  AccountBalance:
    Type: AWS::Serverless::Function # More info about Function Resource: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#awsserverlessfunction
    Properties:
      FunctionName: !Sub "${Environment}-AccountBalance"
      CodeUri: IM-CAPITAL-BACKEND-SERVICE
      Handler: AccountBalance.AccountBalance::handleRequest
      Role: arn:aws:iam::597707462019:role/IMCapital_serverless_deployment
      Policies:
        - Statement:
              Effect: Allow
              Action:
                - ec2:DescribeNetworkInterfaces
                - ec2:CreateNetworkInterface
                - ec2:DeleteNetworkInterface
                - ec2:DescribeInstances
                - ec2:AttachNetworkInterface
              Resource: '*'
      Events:
        IMCAPITAL:
          Type: Api # More info about API Event Source: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#api
          Properties:
            RestApiId: !Ref AWSApiGateway
            Path: /accountbalance
            Method: get

  ServiceAgreement:
    Type: AWS::Serverless::Function # More info about Function Resource: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#awsserverlessfunction
    Properties:
      FunctionName: !Sub "${Environment}-ServiceAgreement"
      CodeUri: IM-CAPITAL-BACKEND-SERVICE
      Handler: ServiceAgreement.ServiceAgreement::handleRequest
      Role: arn:aws:iam::597707462019:role/IMCapital_serverless_deployment
      Policies:
        - Statement:
            Effect: Allow
            Action:
              - ec2:DescribeNetworkInterfaces
              - ec2:CreateNetworkInterface
              - ec2:DeleteNetworkInterface
              - ec2:DescribeInstances
              - ec2:AttachNetworkInterface
            Resource: '*'
      Events:
        IMCAPITAL:
          Type: Api # More info about API Event Source: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#api
          Properties:
            RestApiId: !Ref AWSApiGateway
            Path: /serviceagreement
            Method: get
        IMCAPITALPOST:
          Type: Api # More info about API Event Source: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#api
          Properties:
            RestApiId: !Ref AWSApiGateway
            Path: /serviceagreement
            Method: post
        IMCAPITALOPTIONS:
          Type: Api # More info about API Event Source: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#api
          Properties:
            RestApiId: !Ref AWSApiGateway
            Path: /serviceagreement
            Method: options

  ProfileImage:
    Type: AWS::Serverless::Function # More info about Function Resource: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#awsserverlessfunction
    Properties:
      FunctionName: !Sub "${Environment}-ProfileImage"
      CodeUri: IM-CAPITAL-BACKEND-SERVICE
      Handler: ProfileImage.ProfileImage::handleRequest
      Role: arn:aws:iam::597707462019:role/IMCapital_serverless_deployment
      Policies:
        - Statement:
            Effect: Allow
            Action:
              - ec2:DescribeNetworkInterfaces
              - ec2:CreateNetworkInterface
              - ec2:DeleteNetworkInterface
              - ec2:DescribeInstances
              - ec2:AttachNetworkInterface
            Resource: '*'
      Events:
        IMCAPITAL:
          Type: Api # More info about API Event Source: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#api
          Properties:
            RestApiId: !Ref AWSApiGateway
            Path: /profileimage
            Method: post
        IMCAPITALOPTIONS:
          Type: Api # More info about API Event Source: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#api
          Properties:
            RestApiId: !Ref AWSApiGateway
            Path: /profileimage
            Method: options

  CreateUser:
    Type: AWS::Serverless::Function # More info about Function Resource: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#awsserverlessfunction
    Properties:
      FunctionName: !Sub "${Environment}-CreateUser"
      CodeUri: IM-CAPITAL-BACKEND-SERVICE
      Handler: CreateUser.CreateUser::handleRequest
      Role: arn:aws:iam::597707462019:role/IMCapital_serverless_deployment
      Policies:
        - Statement:
            Effect: Allow
            Action:
              - ec2:DescribeNetworkInterfaces
              - ec2:CreateNetworkInterface
              - ec2:DeleteNetworkInterface
              - ec2:DescribeInstances
              - ec2:AttachNetworkInterface
            Resource: '*'
      Events:
        IMCAPITAL:
          Type: Api # More info about API Event Source: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#api
          Properties:
            RestApiId: !Ref AWSApiGateway
            Path: /createuser
            Method: get
        IMCAPITALPOST:
          Type: Api # More info about API Event Source: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#api
          Properties:
            RestApiId: !Ref AWSApiGateway
            Path: /createuser
            Method: post
        IMCAPITALOPTIONS:
          Type: Api # More info about API Event Source: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#api
          Properties:
            RestApiId: !Ref AWSApiGateway
            Path: /createuser
            Method: options
  GetUser:
    Type: AWS::Serverless::Function # More info about Function Resource: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#awsserverlessfunction
    Properties:
      FunctionName: !Sub "${Environment}-GetUser"
      CodeUri: IM-CAPITAL-BACKEND-SERVICE
      Handler: GetUser.GetUser::handleRequest
      Role: arn:aws:iam::597707462019:role/IMCapital_serverless_deployment
      Policies:
        - Statement:
            Effect: Allow
            Action:
              - ec2:DescribeNetworkInterfaces
              - ec2:CreateNetworkInterface
              - ec2:DeleteNetworkInterface
              - ec2:DescribeInstances
              - ec2:AttachNetworkInterface
            Resource: '*'
      Events:
        IMCAPITAL:
          Type: Api # More info about API Event Source: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#api
          Properties:
            RestApiId: !Ref AWSApiGateway
            Path: /getuser
            Method: get
        IMCAPITALPOST:
          Type: Api # More info about API Event Source: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#api
          Properties:
            RestApiId: !Ref AWSApiGateway
            Path: /getuser
            Method: post
        IMCAPITALOPTIONS:
          Type: Api # More info about API Event Source: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#api
          Properties:
            RestApiId: !Ref AWSApiGateway
            Path: /getuser
            Method: options

  PostTransaction:
    Type: AWS::Serverless::Function # More info about Function Resource: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#awsserverlessfunction
    Properties:
      FunctionName: !Sub "${Environment}-PostTransaction"
      CodeUri: IM-CAPITAL-BACKEND-SERVICE
      Handler: Transaction.Transaction::handleRequest
      Role: arn:aws:iam::597707462019:role/IMCapital_serverless_deployment
      Policies:
        - Statement:
            Effect: Allow
            Action:
              - ec2:DescribeNetworkInterfaces
              - ec2:CreateNetworkInterface
              - ec2:DeleteNetworkInterface
              - ec2:DescribeInstances
              - ec2:AttachNetworkInterface
            Resource: '*'
      Events:
        IMCAPITAL:
          Type: Api # More info about API Event Source: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#api
          Properties:
            RestApiId: !Ref AWSApiGateway
            Path: /transaction
            Method: post

        IMCAPITALOPTIONS:
          Type: Api # More info about API Event Source: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#api
          Properties:
            RestApiId: !Ref AWSApiGateway
            Path: /transaction
            Method: options

        IMCAPITALGET:
          Type: Api # More info about API Event Source: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#api
          Properties:
            RestApiId: !Ref AWSApiGateway
            Path: /transaction
            Method: get
  PostUpdateTransaction:
    Type: AWS::Serverless::Function # More info about Function Resource: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#awsserverlessfunction
    Properties:
      FunctionName: !Sub "${Environment}-PostUpdateTransaction"
      CodeUri: IM-CAPITAL-BACKEND-SERVICE
      Handler: UpdateTransaction.UpdateTransaction::handleRequest
      Role: arn:aws:iam::597707462019:role/IMCapital_serverless_deployment
      Policies:
        - Statement:
            Effect: Allow
            Action:
              - ec2:DescribeNetworkInterfaces
              - ec2:CreateNetworkInterface
              - ec2:DeleteNetworkInterface
              - ec2:DescribeInstances
              - ec2:AttachNetworkInterface
            Resource: '*'
      Events:
        IMCAPITAL:
          Type: Api # More info about API Event Source: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#api
          Properties:
            RestApiId: !Ref AWSApiGateway
            Path: /updatetransaction
            Method: post

        IMCAPITALOPTIONS:
          Type: Api # More info about API Event Source: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#api
          Properties:
            RestApiId: !Ref AWSApiGateway
            Path: /updatetransaction
            Method: options

        IMCAPITALGET:
          Type: Api # More info about API Event Source: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#api
          Properties:
            RestApiId: !Ref AWSApiGateway
            Path: /updatetransaction
            Method: get
  GetTransactions:
    Type: AWS::Serverless::Function # More info about Function Resource: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#awsserverlessfunction
    Properties:
      FunctionName: !Sub "${Environment}-GetTransactions"
      CodeUri: IM-CAPITAL-BACKEND-SERVICE
      Handler: GetTransactions.GetTransactions::handleRequest
      Role: arn:aws:iam::597707462019:role/IMCapital_serverless_deployment
      Policies:
        - Statement:
            Effect: Allow
            Action:
              - ec2:DescribeNetworkInterfaces
              - ec2:CreateNetworkInterface
              - ec2:DeleteNetworkInterface
              - ec2:DescribeInstances
              - ec2:AttachNetworkInterface
            Resource: '*'
      Events:
        IMCAPITALGET:
          Type: Api # More info about API Event Source: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#api
          Properties:
            RestApiId: !Ref AWSApiGateway
            Path: /gettransaction
            Method: get
        IMCAPITALPOST:
          Type: Api # More info about API Event Source: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#api
          Properties:
            RestApiId: !Ref AWSApiGateway
            Path: /gettransaction
            Method: post
        IMCAPITALOPTIONS:
          Type: Api # More info about API Event Source: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#api
          Properties:
            RestApiId: !Ref AWSApiGateway
            Path: /gettransaction
            Method: options

  UserToken:
    Type: AWS::Serverless::Function # More info about Function Resource: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#awsserverlessfunction
    Properties:
      FunctionName: !Sub "${Environment}-UserToken"
      CodeUri: IM-CAPITAL-BACKEND-SERVICE
      Handler: UserToken.UserToken::handleRequest
      Role: arn:aws:iam::597707462019:role/IMCapital_serverless_deployment
      Policies:
        - Statement:
            Effect: Allow
            Action:
              - ec2:DescribeNetworkInterfaces
              - ec2:CreateNetworkInterface
              - ec2:DeleteNetworkInterface
              - ec2:DescribeInstances
              - ec2:AttachNetworkInterface
            Resource: '*'
      Events:
        IMCAPITAL:
          Type: Api # More info about API Event Source: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#api
          Properties:
            RestApiId: !Ref AWSApiGateway
            Path: /usertoken
            Method: get
  DailyYield:
    Type: AWS::Serverless::Function # More info about Function Resource: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#awsserverlessfunction
    Properties:
      FunctionName: !Sub "${Environment}-DailyYield"
      CodeUri: IM-CAPITAL-BACKEND-SERVICE
      Handler: SanlamDailyYield.SanlamDailyYield::handleRequest
      Role: arn:aws:iam::597707462019:role/IMCapital_serverless_deployment
      Policies:
        - Statement:
            Effect: Allow
            Action:
              - ec2:DescribeNetworkInterfaces
              - ec2:CreateNetworkInterface
              - ec2:DeleteNetworkInterface
              - ec2:DescribeInstances
              - ec2:AttachNetworkInterface
            Resource: '*'
      Events:
        IMCAPITAL:
          Type: Api # More info about API Event Source: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#api
          Properties:
            RestApiId: !Ref AWSApiGateway
            Path: /dailyyield
            Method: get
        IMCAPITALPOST:
          Type: Api # More info about API Event Source: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#api
          Properties:
            RestApiId: !Ref AWSApiGateway
            Path: /dailyyield
            Method: post
        IMCAPITALOPTIONS:
          Type: Api # More info about API Event Source: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#api
          Properties:
            RestApiId: !Ref AWSApiGateway
            Path: /dailyyield
            Method: options
  IMCustomerDetails:
    Type: AWS::Serverless::Function # More info about Function Resource: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#awsserverlessfunction
    Properties:
      FunctionName: !Sub "${Environment}-IMCustomerDetails"
      CodeUri: IM-CAPITAL-BACKEND-SERVICE
      Handler: IMCustomerDetails.IMCustomerDetails::handleRequest
      Role: arn:aws:iam::597707462019:role/IMCapital_serverless_deployment
      Policies:
        - Statement:
            Effect: Allow
            Action:
              - ec2:DescribeNetworkInterfaces
              - ec2:CreateNetworkInterface
              - ec2:DeleteNetworkInterface
              - ec2:DescribeInstances
              - ec2:AttachNetworkInterface
            Resource: '*'
      Events:
        IMCAPITAL:
          Type: Api # More info about API Event Source: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#api
          Properties:
            RestApiId: !Ref AWSApiGateway
            Path: /imcustomerdetails
            Method: get
        IMCAPITALPOST:
          Type: Api # More info about API Event Source: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#api
          Properties:
            RestApiId: !Ref AWSApiGateway
            Path: /imcustomerdetails
            Method: post
        IMCAPITALOPTIONS:
          Type: Api # More info about API Event Source: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#api
          Properties:
            RestApiId: !Ref AWSApiGateway
            Path: /imcustomerdetails
            Method: options
  InitiatePayment:
    Type: AWS::Serverless::Function # More info about Function Resource: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#awsserverlessfunction
    Properties:
      Timeout: 45
      FunctionName: !Sub "${Environment}-InitiatePayment"
      CodeUri: IM-CAPITAL-BACKEND-SERVICE
      Handler: InitiatePayment.InitiatePayment::handleRequest
      Role: arn:aws:iam::597707462019:role/IMCapital_serverless_deployment
      Policies:
        - Statement:
            Effect: Allow
            Action:
              - ec2:DescribeNetworkInterfaces
              - ec2:CreateNetworkInterface
              - ec2:DeleteNetworkInterface
              - ec2:DescribeInstances
              - ec2:AttachNetworkInterface
            Resource: '*'
      Events:
        IMCAPITAL:
          Type: Api # More info about API Event Source: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#api
          Properties:
            RestApiId: !Ref AWSApiGateway
            Path: /initiatepayment
            Method: get
        IMCAPITALPOST:
          Type: Api # More info about API Event Source: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#api
          Properties:
            RestApiId: !Ref AWSApiGateway
            Path: /initiatepayment
            Method: post
        IMCAPITALOPTIONS:
          Type: Api # More info about API Event Source: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#api
          Properties:
            RestApiId: !Ref AWSApiGateway
            Path: /initiatepayment
            Method: options
  Preferred2FA:
    Type: AWS::Serverless::Function # More info about Function Resource: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#awsserverlessfunction
    Properties:
      FunctionName: !Sub "${Environment}-Preferred2FA"
      CodeUri: IM-CAPITAL-BACKEND-SERVICE
      Handler: GetPreferred2FA.GetPreferred2FA::handleRequest
      Role: arn:aws:iam::597707462019:role/IMCapital_serverless_deployment
      Policies:
        - Statement:
            Effect: Allow
            Action:
              - ec2:DescribeNetworkInterfaces
              - ec2:CreateNetworkInterface
              - ec2:DeleteNetworkInterface
              - ec2:DescribeInstances
              - ec2:AttachNetworkInterface
            Resource: '*'
      Events:
        IMCAPITAL:
          Type: Api # More info about API Event Source: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#api
          Properties:
            RestApiId: !Ref AWSApiGateway
            Path: /preferred2fa
            Method: get
        IMCAPITALPOST:
          Type: Api # More info about API Event Source: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#api
          Properties:
            RestApiId: !Ref AWSApiGateway
            Path: /preferred2fa
            Method: post
        IMCAPITALOPTIONS:
          Type: Api # More info about API Event Source: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#api
          Properties:
            RestApiId: !Ref AWSApiGateway
            Path: /preferred2fa
            Method: options
  IMStatement:
    Type: AWS::Serverless::Function # More info about Function Resource: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#awsserverlessfunction
    Properties:
      FunctionName: !Sub "${Environment}-IMStatement"
      CodeUri: IM-CAPITAL-BACKEND-SERVICE
      Handler: IMStatement.IMStatement::handleRequest
      Role: arn:aws:iam::597707462019:role/IMCapital_serverless_deployment
      Policies:
        - Statement:
            Effect: Allow
            Action:
              - ec2:DescribeNetworkInterfaces
              - ec2:CreateNetworkInterface
              - ec2:DeleteNetworkInterface
              - ec2:DescribeInstances
              - ec2:AttachNetworkInterface
            Resource: '*'
      Events:
        IMCAPITAL:
          Type: Api # More info about API Event Source: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#api
          Properties:
            RestApiId: !Ref AWSApiGateway
            Path: /imstatement
            Method: get
        IMCAPITALPOST:
          Type: Api # More info about API Event Source: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#api
          Properties:
            RestApiId: !Ref AWSApiGateway
            Path: /imstatement
            Method: post
        IMCAPITALOPTIONS:
          Type: Api # More info about API Event Source: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#api
          Properties:
            RestApiId: !Ref AWSApiGateway
            Path: /imstatement
            Method: options
  SanlamGetToken:
    Type: AWS::Serverless::Function # More info about Function Resource: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#awsserverlessfunction
    Properties:
      FunctionName: !Sub "${Environment}-SanlamGetToken"
      CodeUri: IM-CAPITAL-BACKEND-SERVICE
      Handler: SanlamGetToken.SanlamGetToken::handleRequest
      Role: arn:aws:iam::597707462019:role/IMCapital_serverless_deployment
      Policies:
        - Statement:
            Effect: Allow
            Action:
              - ec2:DescribeNetworkInterfaces
              - ec2:CreateNetworkInterface
              - ec2:DeleteNetworkInterface
              - ec2:DescribeInstances
              - ec2:AttachNetworkInterface
            Resource: '*'
      Events:
        IMCAPITAL:
          Type: Api # More info about API Event Source: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#api
          Properties:
            RestApiId: !Ref AWSApiGateway
            Path: /sanlamgettoken
            Method: get
  SanlamPurchaseFlow:
    Type: AWS::Serverless::Function # More info about Function Resource: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#awsserverlessfunction
    Properties:
      FunctionName: !Sub "${Environment}-SanlamPurchaseFlow"
      CodeUri: IM-CAPITAL-BACKEND-SERVICE
      Handler: SanlamPurchaseFlow.SanlamPurchaseFlow::handleRequest
      Role: arn:aws:iam::597707462019:role/IMCapital_serverless_deployment
      Policies:
        - Statement:
            Effect: Allow
            Action:
              - ec2:DescribeNetworkInterfaces
              - ec2:CreateNetworkInterface
              - ec2:DeleteNetworkInterface
              - ec2:DescribeInstances
              - ec2:AttachNetworkInterface
            Resource: '*'
      Events:
        IMCAPITAL:
          Type: Api # More info about API Event Source: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#api
          Properties:
            RestApiId: !Ref AWSApiGateway
            Path: /sanlampurchaseflow
            Method: get
        IMCAPITALPOST:
          Type: Api # More info about API Event Source: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#api
          Properties:
            RestApiId: !Ref AWSApiGateway
            Path: /sanlampurchaseflow
            Method: post
        IMCAPITALOPTIONS:
          Type: Api # More info about API Event Source: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#api
          Properties:
            RestApiId: !Ref AWSApiGateway
            Path: /sanlampurchaseflow
            Method: options
  SanlamWithdrawalFlow:
    Type: AWS::Serverless::Function # More info about Function Resource: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#awsserverlessfunction
    Properties:
      FunctionName: !Sub "${Environment}-SanlamWithdrawalFlow"
      CodeUri: IM-CAPITAL-BACKEND-SERVICE
      Handler: SanlamWithdrawalFlow.SanlamWithdrawalFlow::handleRequest
      Role: arn:aws:iam::597707462019:role/IMCapital_serverless_deployment
      Policies:
        - Statement:
            Effect: Allow
            Action:
              - ec2:DescribeNetworkInterfaces
              - ec2:CreateNetworkInterface
              - ec2:DeleteNetworkInterface
              - ec2:DescribeInstances
              - ec2:AttachNetworkInterface
            Resource: '*'
      Events:
        IMCAPITAL:
          Type: Api # More info about API Event Source: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#api
          Properties:
            RestApiId: !Ref AWSApiGateway
            Path: /sanlamwithdrawalflow
            Method: get
        IMCAPITALPOST:
          Type: Api # More info about API Event Source: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#api
          Properties:
            RestApiId: !Ref AWSApiGateway
            Path: /sanlamwithdrawalflow
            Method: post
        IMCAPITALOPTIONS:
          Type: Api # More info about API Event Source: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#api
          Properties:
            RestApiId: !Ref AWSApiGateway
            Path: /sanlamwithdrawalflow
            Method: options
  GetSanlamMembers:
    Type: AWS::Serverless::Function # More info about Function Resource: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#awsserverlessfunction
    Properties:
      FunctionName: !Sub "${Environment}-GetSanlamMembers"
      CodeUri: IM-CAPITAL-BACKEND-SERVICE
      Handler: GetSanlamMembers.GetSanlamMembers::handleRequest
      Role: arn:aws:iam::597707462019:role/IMCapital_serverless_deployment
      Policies:
        - Statement:
            Effect: Allow
            Action:
              - ec2:DescribeNetworkInterfaces
              - ec2:CreateNetworkInterface
              - ec2:DeleteNetworkInterface
              - ec2:DescribeInstances
              - ec2:AttachNetworkInterface
            Resource: '*'
      Events:
        IMCAPITAL:
          Type: Api # More info about API Event Source: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#api
          Properties:
            RestApiId: !Ref AWSApiGateway
            Path: /getsanlammembers
            Method: get
        IMCAPITALPOST:
          Type: Api # More info about API Event Source: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#api
          Properties:
            RestApiId: !Ref AWSApiGateway
            Path: /getsanlammembers
            Method: post
        IMCAPITALOPTIONS:
          Type: Api # More info about API Event Source: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#api
          Properties:
            RestApiId: !Ref AWSApiGateway
            Path: /getsanlammembers
            Method: options
  GetSanlamWithdrawalCharges:
    Type: AWS::Serverless::Function # More info about Function Resource: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#awsserverlessfunction
    Properties:
      FunctionName: !Sub "${Environment}-SanlamWithdrawalCharges"
      CodeUri: IM-CAPITAL-BACKEND-SERVICE
      Handler: SanlamWithdrawalCharges.SanlamWithdrawalCharges::handleRequest
      Role: arn:aws:iam::597707462019:role/IMCapital_serverless_deployment
      Policies:
        - Statement:
            Effect: Allow
            Action:
              - ec2:DescribeNetworkInterfaces
              - ec2:CreateNetworkInterface
              - ec2:DeleteNetworkInterface
              - ec2:DescribeInstances
              - ec2:AttachNetworkInterface
            Resource: '*'
      Events:
        IMCAPITAL:
          Type: Api # More info about API Event Source: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#api
          Properties:
            RestApiId: !Ref AWSApiGateway
            Path: /sanlamwitdrawalcharge
            Method: get
        IMCAPITALPOST:
          Type: Api # More info about API Event Source: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#api
          Properties:
            RestApiId: !Ref AWSApiGateway
            Path: /sanlamwitdrawalcharge
            Method: post
        IMCAPITALOPTIONS:
          Type: Api # More info about API Event Source: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#api
          Properties:
            RestApiId: !Ref AWSApiGateway
            Path: /sanlamwitdrawalcharge
            Method: options
  GetSanlamAccountBalance:
    Type: AWS::Serverless::Function # More info about Function Resource: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#awsserverlessfunction
    Properties:
      FunctionName: !Sub "${Environment}-GetSanlamAccountBalance"
      CodeUri: IM-CAPITAL-BACKEND-SERVICE
      Handler: SanlamAccountBalance.SanlamAccountBalance::handleRequest
      Role: arn:aws:iam::597707462019:role/IMCapital_serverless_deployment
      Policies:
        - Statement:
            Effect: Allow
            Action:
              - ec2:DescribeNetworkInterfaces
              - ec2:CreateNetworkInterface
              - ec2:DeleteNetworkInterface
              - ec2:DescribeInstances
              - ec2:AttachNetworkInterface
            Resource: '*'
      Events:
        IMCAPITAL:
          Type: Api # More info about API Event Source: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#api
          Properties:
            RestApiId: !Ref AWSApiGateway
            Path: /sanlamaccountbalance
            Method: get
        IMCAPITALPOST:
          Type: Api # More info about API Event Source: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#api
          Properties:
            RestApiId: !Ref AWSApiGateway
            Path: /sanlamaccountbalance
            Method: post
        IMCAPITALOPTIONS:
          Type: Api # More info about API Event Source: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#api
          Properties:
            RestApiId: !Ref AWSApiGateway
            Path: /sanlamaccountbalance
            Method: options
  IMGetCustomer:
    Type: AWS::Serverless::Function # More info about Function Resource: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#awsserverlessfunction
    Properties:
      FunctionName: !Sub "${Environment}-IMGetCustomer"
      CodeUri: IM-CAPITAL-BACKEND-SERVICE
      Handler: IMGetCustomer.IMGetCustomer::handleRequest
      Role: arn:aws:iam::597707462019:role/IMCapital_serverless_deployment
      Policies:
        - Statement:
            Effect: Allow
            Action:
              - ec2:DescribeNetworkInterfaces
              - ec2:CreateNetworkInterface
              - ec2:DeleteNetworkInterface
              - ec2:DescribeInstances
              - ec2:AttachNetworkInterface
            Resource: '*'
      Events:
        IMCAPITAL:
          Type: Api # More info about API Event Source: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#api
          Properties:
            RestApiId: !Ref AWSApiGateway
            Path: /imgetcustomer
            Method: get
        IMCAPITALPOST:
          Type: Api # More info about API Event Source: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#api
          Properties:
            RestApiId: !Ref AWSApiGateway
            Path: /imgetcustomer
            Method: post
        IMCAPITALOPTIONS:
          Type: Api # More info about API Event Source: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#api
          Properties:
            RestApiId: !Ref AWSApiGateway
            Path: /imgetcustomer
            Method: options
  LogError:
    Type: AWS::Serverless::Function # More info about Function Resource: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#awsserverlessfunction
    Properties:
      FunctionName: !Sub "${Environment}-LogError"
      CodeUri: IM-CAPITAL-BACKEND-SERVICE
      Handler: LogError.LogError::handleRequest
      Role: arn:aws:iam::597707462019:role/IMCapital_serverless_deployment
      Policies:
        - Statement:
            Effect: Allow
            Action:
              - ec2:DescribeNetworkInterfaces
              - ec2:CreateNetworkInterface
              - ec2:DeleteNetworkInterface
              - ec2:DescribeInstances
              - ec2:AttachNetworkInterface
            Resource: '*'
      Events:
        IMCAPITAL:
          Type: Api # More info about API Event Source: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#api
          Properties:
            RestApiId: !Ref AWSApiGateway
            Path: /logerror
            Method: get
        IMCAPITALPOST:
          Type: Api # More info about API Event Source: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#api
          Properties:
            RestApiId: !Ref AWSApiGateway
            Path: /logerror
            Method: post
        IMCAPITALOPTIONS:
          Type: Api # More info about API Event Source: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#api
          Properties:
            RestApiId: !Ref AWSApiGateway
            Path: /logerror
            Method: options
  WriteLogs:
    Type: AWS::Serverless::Function # More info about Function Resource: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#awsserverlessfunction
    Properties:
      FunctionName: !Sub "${Environment}-WriteS3Logs"
      CodeUri: IM-CAPITAL-BACKEND-SERVICE
      Handler: WriteS3Logs.WriteS3Logs::handleRequest
      Role: arn:aws:iam::597707462019:role/IMCapital_serverless_deployment
      Policies:
        - Statement:
            Effect: Allow
            Action:
              - ec2:DescribeNetworkInterfaces
              - ec2:CreateNetworkInterface
              - ec2:DeleteNetworkInterface
              - ec2:DescribeInstances
              - ec2:AttachNetworkInterface
            Resource: '*'
      Events:
        ScheduleEvent:
          Type: Schedule
          Properties:
            Schedule: rate(1 hour)
  StatementTest:
    Type: AWS::Serverless::Function # More info about Function Resource: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#awsserverlessfunction
    Properties:
      FunctionName: !Sub "${Environment}-StatementTest"
      CodeUri: IM-CAPITAL-BACKEND-SERVICE
      Handler: StatementTest.StatementTest::handleRequest
      Role: arn:aws:iam::597707462019:role/IMCapital_serverless_deployment
      Policies:
        - Statement:
            Effect: Allow
            Action:
              - ec2:DescribeNetworkInterfaces
              - ec2:CreateNetworkInterface
              - ec2:DeleteNetworkInterface
              - ec2:DescribeInstances
              - ec2:AttachNetworkInterface
            Resource: '*'
  CheckWhiteList:
    Type: AWS::Serverless::Function # More info about Function Resource: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#awsserverlessfunction
    Properties:
      FunctionName: !Sub "${Environment}-CheckWhiteList"
      CodeUri: IM-CAPITAL-BACKEND-SERVICE
      Handler: CheckWhiteList.CheckWhiteList::handleRequest
      Role: arn:aws:iam::597707462019:role/IMCapital_serverless_deployment
      Policies:
        - Statement:
            Effect: Allow
            Action:
              - ec2:DescribeNetworkInterfaces
              - ec2:CreateNetworkInterface
              - ec2:DeleteNetworkInterface
              - ec2:DescribeInstances
              - ec2:AttachNetworkInterface
            Resource: '*'
      Events:
        IMCAPITAL:
          Type: Api # More info about API Event Source: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#api
          Properties:
            RestApiId: !Ref AWSApiGateway
            Path: /checkwhitelist
            Method: get
        IMCAPITALPOST:
          Type: Api # More info about API Event Source: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#api
          Properties:
            RestApiId: !Ref AWSApiGateway
            Path: /checkwhitelist
            Method: post
        IMCAPITALOPTIONS:
          Type: Api # More info about API Event Source: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#api
          Properties:
            RestApiId: !Ref AWSApiGateway
            Path: /checkwhitelist
            Method: options
  GetSettings:
    Type: AWS::Serverless::Function # More info about Function Resource: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#awsserverlessfunction
    Properties:
      FunctionName: !Sub "${Environment}-GetSettings"
      CodeUri: IM-CAPITAL-BACKEND-SERVICE
      Handler: GetSettings.GetSettings::handleRequest
      Role: arn:aws:iam::597707462019:role/IMCapital_serverless_deployment
      Policies:
        - Statement:
            Effect: Allow
            Action:
              - ec2:DescribeNetworkInterfaces
              - ec2:CreateNetworkInterface
              - ec2:DeleteNetworkInterface
              - ec2:DescribeInstances
              - ec2:AttachNetworkInterface
            Resource: '*'
      Events:
        IMCAPITAL:
          Type: Api # More info about API Event Source: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#api
          Properties:
            RestApiId: !Ref AWSApiGateway
            Path: /getsettings
            Method: get


#  ApplicationResourceGroup:
#    Type: AWS::ResourceGroups::Group
#    Properties:
#      Name:
#        !Sub ApplicationInsights-SAM-${AWS::StackName}
#      ResourceQuery:
#        Type: CLOUDFORMATION_STACK_1_0
#  ApplicationInsightsMonitoring:
#    Type: AWS::ApplicationInsights::Application
#    Properties:
#      ResourceGroupName:
#        Ref: ApplicationResourceGroup
#      AutoConfigurationEnabled: 'true'
#Outputs:
  # ServerlessRestApi is an implicit API created out of Events key under Serverless::Function
  # Find out more about other implicit resources you can reference within SAM
  # https://github.com/awslabs/serverless-application-model/blob/master/docs/internals/generated_resources.rst#api
#  HelloWorldApi:
#    Description: API Gateway endpoint URL for Prod stage for
#    Value: !Sub "https://${ServerlessRestApi}.execute-api.${AWS::Region}.amazonaws.com/Prod/hello/"
#  HelloWorldFunction:
#    Description: Hello World Lambda Function ARN
#    Value: !GetAtt HelloWorldFunction.Arn
#  HelloWorldFunctionIamRole:
#    Description: Implicit IAM Role created for Hello World function
#    Value: !GetAtt HelloWorldFunctionRole.Arn
