service: heisenberg-medicine
package:
  excludeDevDependencies: true
  individually: true
  exclude:
    - database/**
    - docker/**
    - openapi/**
    - .serverless/**
    - serverless/**
    - src/**
    - tests/**
    - .env
    - .env.example
    - env.yml.example
    - "*.env.yml"
    - .gitlab-ci.yml
    - .gitignore
    - README.md
    - node_modules/**
    - tests/**

plugins:
  - serverless-jetpack
  - serverless-import-apigateway

app:  heisenberg-medicine

provider:
  name: aws
  runtime: nodejs14.x
  stage: dev
  region: eu-west-1
  deploymentBucket:
    name: heisenberg-serverless-deployments-${self:custom.stage}
  logs:
    restApi: true

custom:
  # General
  stage: "${opt:stage, self:provider.stage}"
  region: ${opt:region, self:provider.region}
  accountId: ${file(./serverless/helpers/account-id.js):getAccountId}
  # API Gateway
  importApiGateway:
    name: admin-${self:custom.stage}  # Required 
    path: / 
  # Authorizer
  superAdminAuthorizer: !ImportValue ${self:custom.stage}AdminApiGatewaySuperAdminAuthorizerId
  prescriptionAuthorizer: !ImportValue ${self:custom.stage}AdminApiGatewayPrescriptionAuthorizerId
  fulfilmentAuthorizer: !ImportValue ${self:custom.stage}AdminApiGatewayFulfilmentAuthorizerId
  packagingAuthorizer: !ImportValue ${self:custom.stage}AdminApiGatewayPackagingAuthorizerId
  cognitoAuthorizer: !ImportValue ${self:custom.stage}AdminApiGatewayCognitoAuthorizerId
  # RDS
  rdsUser: ${file(${self:custom.stage}.env.yml):db_details.RDS_USER}
  rdsPass: ${file(${self:custom.stage}.env.yml):db_details.RDS_PASS}
  rdsDBName: ${file(${self:custom.stage}.env.yml):db_details.RDS_DB}
  # Layer
  authorizeLayer: arn:aws:lambda:${self:custom.region}:${self:custom.accountId}:layer:authorize-${self:custom.stage}:${file(${self:custom.stage}.env.yml):layer-versions.AUTHORIZE}
  awsServicesLayer: arn:aws:lambda:${self:custom.region}:${self:custom.accountId}:layer:aws-services-${self:custom.stage}:${file(${self:custom.stage}.env.yml):layer-versions.AWS_SERVICES}
  databaseLayer: arn:aws:lambda:${self:custom.region}:${self:custom.accountId}:layer:database-${self:custom.stage}:${file(${self:custom.stage}.env.yml):layer-versions.DATABASE}
  generalUtilsLayer: arn:aws:lambda:${self:custom.region}:${self:custom.accountId}:layer:general-utils-${self:custom.stage}:${file(${self:custom.stage}.env.yml):layer-versions.GENERAL_UTILS}
  emailLayer: arn:aws:lambda:${self:custom.region}:${self:custom.accountId}:layer:email-${self:custom.stage}:${file(${self:custom.stage}.env.yml):layer-versions.EMAIL}

functions:
  MedicineCreate:
    handler: src/medicine/create/handler.handle
    vpc:
        securityGroupIds:
          - {"Fn::ImportValue": "${self:custom.stage}LambdaSecurityGroup"}
        subnetIds:
          - {"Fn::ImportValue": "${self:custom.stage}PublicSubnet1"}
          - {"Fn::ImportValue": "${self:custom.stage}PublicSubnet2"}
    name: medicine-create-${self:custom.stage}
    memorySize: 128
    timeout: 6
    environment: ${file(${self:custom.stage}.env.yml):db-lambda}
    events:
      - http: 
          path: medicine
          method: post
          cors:
            origin: '*'
            headers: 
              - Content-Type
              - X-Amz-Date
              - Authorization
              - X-Api-Key
              - X-Amz-Security-Token
              - AccessToken
              - IdToken
            allowCredentials: false
          authorizer:
            type: TOKEN
            authorizerId: ${self:custom.prescriptionAuthorizer}
    layers:
      - ${self:custom.databaseLayer}
      - ${self:custom.generalUtilsLayer}
    package:  
      include:
        - src/medicine/create/**

  MedicineList:
    handler: src/medicine/list/handler.handle
    vpc:
        securityGroupIds:
          - {"Fn::ImportValue": "${self:custom.stage}LambdaSecurityGroup"}
        subnetIds:
          - {"Fn::ImportValue": "${self:custom.stage}PublicSubnet1"}
          - {"Fn::ImportValue": "${self:custom.stage}PublicSubnet2"}
    name: medicine-list-${self:custom.stage}
    memorySize: 128
    timeout: 6
    environment: ${file(${self:custom.stage}.env.yml):db-lambda}
    events:
      - http: 
          path: medicine
          method: get
          cors:
            origin: '*'
            headers: 
              - Content-Type
              - X-Amz-Date
              - Authorization
              - X-Api-Key
              - X-Amz-Security-Token
              - AccessToken
              - IdToken
            allowCredentials: false
          authorizer:
            type: COGNITO_USER_POOLS
            authorizerId: ${self:custom.cognitoAuthorizer}
    layers:
      - ${self:custom.databaseLayer}
      - ${self:custom.generalUtilsLayer}
    package:  
      include:
        - src/medicine/list/**

  MedicineEdit:
    handler: src/medicine/edit/handler.handle
    vpc:
        securityGroupIds:
          - {"Fn::ImportValue": "${self:custom.stage}LambdaSecurityGroup"}
        subnetIds:
          - {"Fn::ImportValue": "${self:custom.stage}PublicSubnet1"}
          - {"Fn::ImportValue": "${self:custom.stage}PublicSubnet2"}
    name: medicine-edit-${self:custom.stage}
    memorySize: 128
    timeout: 6
    environment: ${file(${self:custom.stage}.env.yml):db-lambda}
    events:
      - http: 
          path: medicine/{medicine_id}
          method: put
          cors:
            origin: '*'
            headers: 
              - Content-Type
              - X-Amz-Date
              - Authorization
              - X-Api-Key
              - X-Amz-Security-Token
              - AccessToken
              - IdToken
            allowCredentials: false
          authorizer:
            type: TOKEN
            authorizerId: ${self:custom.prescriptionAuthorizer}
    layers:
      - ${self:custom.databaseLayer}
      - ${self:custom.generalUtilsLayer}
    package:  
      include:
        - src/medicine/edit/**

  MedicineView:
    handler: src/medicine/view/handler.handle
    vpc:
        securityGroupIds:
          - {"Fn::ImportValue": "${self:custom.stage}LambdaSecurityGroup"}
        subnetIds:
          - {"Fn::ImportValue": "${self:custom.stage}PublicSubnet1"}
          - {"Fn::ImportValue": "${self:custom.stage}PublicSubnet2"}
    name: medicine-view-${self:custom.stage}
    memorySize: 128
    timeout: 6
    environment: ${file(${self:custom.stage}.env.yml):db-lambda}
    events:
      - http: 
          path: medicine/{medicine_id}
          method: get
          cors:
            origin: '*'
            headers: 
              - Content-Type
              - X-Amz-Date
              - Authorization
              - X-Api-Key
              - X-Amz-Security-Token
              - AccessToken
              - IdToken
            allowCredentials: false
          authorizer:
            type: COGNITO_USER_POOLS
            authorizerId: ${self:custom.cognitoAuthorizer}
    layers:
      - ${self:custom.databaseLayer}
      - ${self:custom.generalUtilsLayer}
    package:  
      include:
        - src/medicine/view/**

  MedicineDelete:
    handler: src/medicine/delete/handler.handle
    vpc:
        securityGroupIds:
          - {"Fn::ImportValue": "${self:custom.stage}LambdaSecurityGroup"}
        subnetIds:
          - {"Fn::ImportValue": "${self:custom.stage}PublicSubnet1"}
          - {"Fn::ImportValue": "${self:custom.stage}PublicSubnet2"}
    name: medicine-delete-${self:custom.stage}
    memorySize: 128
    timeout: 6
    environment: ${file(${self:custom.stage}.env.yml):db-lambda}
    events:
      - http: 
          path: medicine/{medicine_id}
          method: delete
          cors:
            origin: '*'
            headers: 
              - Content-Type
              - X-Amz-Date
              - Authorization
              - X-Api-Key
              - X-Amz-Security-Token
              - AccessToken
              - IdToken
            allowCredentials: false
          authorizer:
            type: TOKEN
            authorizerId: ${self:custom.superAdminAuthorizer}
    layers:
      - ${self:custom.databaseLayer}
      - ${self:custom.generalUtilsLayer}
    package:  
      include:
        - src/medicine/delete/**

  DosageUnitCreate:
    handler: src/dosage-unit/create/handler.handle
    vpc:
        securityGroupIds:
          - {"Fn::ImportValue": "${self:custom.stage}LambdaSecurityGroup"}
        subnetIds:
          - {"Fn::ImportValue": "${self:custom.stage}PublicSubnet1"}
          - {"Fn::ImportValue": "${self:custom.stage}PublicSubnet2"}
    name: dosage-unit-create-${self:custom.stage}
    memorySize: 128
    timeout: 6
    environment: ${file(${self:custom.stage}.env.yml):db-lambda}
    events:
      - http: 
          path: dosage-unit
          method: post
          cors:
            origin: '*'
            headers: 
              - Content-Type
              - X-Amz-Date
              - Authorization
              - X-Api-Key
              - X-Amz-Security-Token
              - AccessToken
              - IdToken
            allowCredentials: false
          authorizer:
            type: TOKEN
            authorizerId: ${self:custom.prescriptionAuthorizer}
    layers:
      - ${self:custom.databaseLayer}
      - ${self:custom.generalUtilsLayer}
    package:  
      include:
        - src/dosage-unit/create/**

  DosageUnitList:
    handler: src/dosage-unit/list/handler.handle
    vpc:
        securityGroupIds:
          - {"Fn::ImportValue": "${self:custom.stage}LambdaSecurityGroup"}
        subnetIds:
          - {"Fn::ImportValue": "${self:custom.stage}PublicSubnet1"}
          - {"Fn::ImportValue": "${self:custom.stage}PublicSubnet2"}
    name: dosage-unit-list-${self:custom.stage}
    memorySize: 128
    timeout: 6
    environment: ${file(${self:custom.stage}.env.yml):db-lambda}
    events:
      - http: 
          path: dosage-unit
          method: get
          cors:
            origin: '*'
            headers: 
              - Content-Type
              - X-Amz-Date
              - Authorization
              - X-Api-Key
              - X-Amz-Security-Token
              - AccessToken
              - IdToken
            allowCredentials: false
          authorizer:
            type: COGNITO_USER_POOLS
            authorizerId: ${self:custom.cognitoAuthorizer}
    layers:
      - ${self:custom.databaseLayer}
      - ${self:custom.generalUtilsLayer}
    package:  
      include:
        - src/dosage-unit/list/**

  DosageUnitEdit:
    handler: src/dosage-unit/edit/handler.handle
    vpc:
        securityGroupIds:
          - {"Fn::ImportValue": "${self:custom.stage}LambdaSecurityGroup"}
        subnetIds:
          - {"Fn::ImportValue": "${self:custom.stage}PublicSubnet1"}
          - {"Fn::ImportValue": "${self:custom.stage}PublicSubnet2"}
    name: dosage-unit-edit-${self:custom.stage}
    memorySize: 128
    timeout: 6
    environment: ${file(${self:custom.stage}.env.yml):db-lambda}
    events:
      - http: 
          path: dosage-unit/{dosage_unit_id}
          method: put
          cors:
            origin: '*'
            headers: 
              - Content-Type
              - X-Amz-Date
              - Authorization
              - X-Api-Key
              - X-Amz-Security-Token
              - AccessToken
              - IdToken
            allowCredentials: false
          authorizer:
            type: TOKEN
            authorizerId: ${self:custom.prescriptionAuthorizer}
    layers:
      - ${self:custom.databaseLayer}
      - ${self:custom.generalUtilsLayer}
    package:  
      include:
        - src/dosage-unit/edit/**

  DosageUnitView:
    handler: src/dosage-unit/view/handler.handle
    vpc:
        securityGroupIds:
          - {"Fn::ImportValue": "${self:custom.stage}LambdaSecurityGroup"}
        subnetIds:
          - {"Fn::ImportValue": "${self:custom.stage}PublicSubnet1"}
          - {"Fn::ImportValue": "${self:custom.stage}PublicSubnet2"}
    name: dosage-unit-view-${self:custom.stage}
    memorySize: 128
    timeout: 6
    environment: ${file(${self:custom.stage}.env.yml):db-lambda}
    events:
      - http: 
          path: dosage-unit/{dosage_unit_id}
          method: get
          cors:
            origin: '*'
            headers: 
              - Content-Type
              - X-Amz-Date
              - Authorization
              - X-Api-Key
              - X-Amz-Security-Token
              - AccessToken
              - IdToken
            allowCredentials: false
          authorizer:
            type: COGNITO_USER_POOLS
            authorizerId: ${self:custom.cognitoAuthorizer}
    layers:
      - ${self:custom.databaseLayer}
      - ${self:custom.generalUtilsLayer}
    package:  
      include:
        - src/dosage-unit/view/**

  DosageUnitDelete:
    handler: src/dosage-unit/delete/handler.handle
    vpc:
        securityGroupIds:
          - {"Fn::ImportValue": "${self:custom.stage}LambdaSecurityGroup"}
        subnetIds:
          - {"Fn::ImportValue": "${self:custom.stage}PublicSubnet1"}
          - {"Fn::ImportValue": "${self:custom.stage}PublicSubnet2"}
    name: dosage-unit-delete-${self:custom.stage}
    memorySize: 128
    timeout: 6
    environment: ${file(${self:custom.stage}.env.yml):db-lambda}
    events:
      - http: 
          path: dosage-unit/{dosage_unit_id}
          method: delete
          cors:
            origin: '*'
            headers: 
              - Content-Type
              - X-Amz-Date
              - Authorization
              - X-Api-Key
              - X-Amz-Security-Token
              - AccessToken
              - IdToken
            allowCredentials: false
          authorizer:
            type: TOKEN
            authorizerId: ${self:custom.superAdminAuthorizer}
    layers:
      - ${self:custom.databaseLayer}
      - ${self:custom.generalUtilsLayer}
    package:  
      include:
        - src/dosage-unit/delete/**

  DosageTypeCreate:
    handler: src/dosage-type/create/handler.handle
    vpc:
        securityGroupIds:
          - {"Fn::ImportValue": "${self:custom.stage}LambdaSecurityGroup"}
        subnetIds:
          - {"Fn::ImportValue": "${self:custom.stage}PublicSubnet1"}
          - {"Fn::ImportValue": "${self:custom.stage}PublicSubnet2"}
    name: dosage-type-create-${self:custom.stage}
    memorySize: 128
    timeout: 6
    environment: ${file(${self:custom.stage}.env.yml):db-lambda}
    events:
      - http: 
          path: dosage-type
          method: post
          cors:
            origin: '*'
            headers: 
              - Content-Type
              - X-Amz-Date
              - Authorization
              - X-Api-Key
              - X-Amz-Security-Token
              - AccessToken
              - IdToken
            allowCredentials: false
          authorizer:
            type: TOKEN
            authorizerId: ${self:custom.prescriptionAuthorizer}
    layers:
      - ${self:custom.databaseLayer}
      - ${self:custom.generalUtilsLayer}
    package:  
      include:
        - src/dosage-type/create/**

  DosageTypeList:
    handler: src/dosage-type/list/handler.handle
    vpc:
        securityGroupIds:
          - {"Fn::ImportValue": "${self:custom.stage}LambdaSecurityGroup"}
        subnetIds:
          - {"Fn::ImportValue": "${self:custom.stage}PublicSubnet1"}
          - {"Fn::ImportValue": "${self:custom.stage}PublicSubnet2"}
    name: dosage-type-list-${self:custom.stage}
    memorySize: 128
    timeout: 6
    environment: ${file(${self:custom.stage}.env.yml):db-lambda}
    events:
      - http: 
          path: dosage-type
          method: get
          cors:
            origin: '*'
            headers: 
              - Content-Type
              - X-Amz-Date
              - Authorization
              - X-Api-Key
              - X-Amz-Security-Token
              - AccessToken
              - IdToken
            allowCredentials: false
          authorizer:
            type: COGNITO_USER_POOLS
            authorizerId: ${self:custom.cognitoAuthorizer}
    layers:
      - ${self:custom.databaseLayer}
      - ${self:custom.generalUtilsLayer}
    package:  
      include:
        - src/dosage-type/list/**

  DosageTypeEdit:
    handler: src/dosage-type/edit/handler.handle
    vpc:
        securityGroupIds:
          - {"Fn::ImportValue": "${self:custom.stage}LambdaSecurityGroup"}
        subnetIds:
          - {"Fn::ImportValue": "${self:custom.stage}PublicSubnet1"}
          - {"Fn::ImportValue": "${self:custom.stage}PublicSubnet2"}
    name: dosage-type-edit-${self:custom.stage}
    memorySize: 128
    timeout: 6
    environment: ${file(${self:custom.stage}.env.yml):db-lambda}
    events:
      - http: 
          path: dosage-type/{dosage_type_id}
          method: put
          cors:
            origin: '*'
            headers: 
              - Content-Type
              - X-Amz-Date
              - Authorization
              - X-Api-Key
              - X-Amz-Security-Token
              - AccessToken
              - IdToken
            allowCredentials: false
          authorizer:
            type: TOKEN
            authorizerId: ${self:custom.prescriptionAuthorizer}
    layers:
      - ${self:custom.databaseLayer}
      - ${self:custom.generalUtilsLayer}
    package:  
      include:
        - src/dosage-type/edit/**

  DosageTypeView:
    handler: src/dosage-type/view/handler.handle
    vpc:
        securityGroupIds:
          - {"Fn::ImportValue": "${self:custom.stage}LambdaSecurityGroup"}
        subnetIds:
          - {"Fn::ImportValue": "${self:custom.stage}PublicSubnet1"}
          - {"Fn::ImportValue": "${self:custom.stage}PublicSubnet2"}
    name: dosage-type-view-${self:custom.stage}
    memorySize: 128
    timeout: 6
    environment: ${file(${self:custom.stage}.env.yml):db-lambda}
    events:
      - http: 
          path: dosage-type/{dosage_type_id}
          method: get
          cors:
            origin: '*'
            headers: 
              - Content-Type
              - X-Amz-Date
              - Authorization
              - X-Api-Key
              - X-Amz-Security-Token
              - AccessToken
              - IdToken
            allowCredentials: false
          authorizer:
            type: COGNITO_USER_POOLS
            authorizerId: ${self:custom.cognitoAuthorizer}
    layers:
      - ${self:custom.databaseLayer}
      - ${self:custom.generalUtilsLayer}
    package:  
      include:
        - src/dosage-type/view/**

  DosageTypeDelete:
    handler: src/dosage-type/delete/handler.handle
    vpc:
        securityGroupIds:
          - {"Fn::ImportValue": "${self:custom.stage}LambdaSecurityGroup"}
        subnetIds:
          - {"Fn::ImportValue": "${self:custom.stage}PublicSubnet1"}
          - {"Fn::ImportValue": "${self:custom.stage}PublicSubnet2"}
    name: dosage-type-delete-${self:custom.stage}
    memorySize: 128
    timeout: 6
    environment: ${file(${self:custom.stage}.env.yml):db-lambda}
    events:
      - http: 
          path: dosage-type/{dosage_type_id}
          method: delete
          cors:
            origin: '*'
            headers: 
              - Content-Type
              - X-Amz-Date
              - Authorization
              - X-Api-Key
              - X-Amz-Security-Token
              - AccessToken
              - IdToken
            allowCredentials: false
          authorizer:
            type: TOKEN
            authorizerId: ${self:custom.superAdminAuthorizer}
    layers:
      - ${self:custom.databaseLayer}
      - ${self:custom.generalUtilsLayer}
    package:  
      include:
        - src/dosage-type/delete/**

  PackageTypeCreate:
    handler: src/package-type/create/handler.handle
    vpc:
        securityGroupIds:
          - {"Fn::ImportValue": "${self:custom.stage}LambdaSecurityGroup"}
        subnetIds:
          - {"Fn::ImportValue": "${self:custom.stage}PublicSubnet1"}
          - {"Fn::ImportValue": "${self:custom.stage}PublicSubnet2"}
    name: package-type-create-${self:custom.stage}
    memorySize: 128
    timeout: 6
    environment: ${file(${self:custom.stage}.env.yml):db-lambda}
    events:
      - http: 
          path: package-type
          method: post
          cors:
            origin: '*'
            headers: 
              - Content-Type
              - X-Amz-Date
              - Authorization
              - X-Api-Key
              - X-Amz-Security-Token
              - AccessToken
              - IdToken
            allowCredentials: false
          authorizer:
            type: TOKEN
            authorizerId: ${self:custom.prescriptionAuthorizer}
    layers:
      - ${self:custom.databaseLayer}
      - ${self:custom.generalUtilsLayer}
    package:  
      include:
        - src/package-type/create/**

  PackageTypeList:
    handler: src/package-type/list/handler.handle
    vpc:
        securityGroupIds:
          - {"Fn::ImportValue": "${self:custom.stage}LambdaSecurityGroup"}
        subnetIds:
          - {"Fn::ImportValue": "${self:custom.stage}PublicSubnet1"}
          - {"Fn::ImportValue": "${self:custom.stage}PublicSubnet2"}
    name: package-type-list-${self:custom.stage}
    memorySize: 128
    timeout: 6
    environment: ${file(${self:custom.stage}.env.yml):db-lambda}
    events:
      - http: 
          path: package-type
          method: get
          cors:
            origin: '*'
            headers: 
              - Content-Type
              - X-Amz-Date
              - Authorization
              - X-Api-Key
              - X-Amz-Security-Token
              - AccessToken
              - IdToken
            allowCredentials: false
          authorizer:
            type: COGNITO_USER_POOLS
            authorizerId: ${self:custom.cognitoAuthorizer}
    layers:
      - ${self:custom.databaseLayer}
      - ${self:custom.generalUtilsLayer}
    package:  
      include:
        - src/package-type/list/**

  PackageTypeEdit:
    handler: src/package-type/edit/handler.handle
    vpc:
        securityGroupIds:
          - {"Fn::ImportValue": "${self:custom.stage}LambdaSecurityGroup"}
        subnetIds:
          - {"Fn::ImportValue": "${self:custom.stage}PublicSubnet1"}
          - {"Fn::ImportValue": "${self:custom.stage}PublicSubnet2"}
    name: package-type-edit-${self:custom.stage}
    memorySize: 128
    timeout: 6
    environment: ${file(${self:custom.stage}.env.yml):db-lambda}
    events:
      - http: 
          path: package-type/{package_type_id}
          method: put
          cors:
            origin: '*'
            headers: 
              - Content-Type
              - X-Amz-Date
              - Authorization
              - X-Api-Key
              - X-Amz-Security-Token
              - AccessToken
              - IdToken
            allowCredentials: false
          authorizer:
            type: TOKEN
            authorizerId: ${self:custom.prescriptionAuthorizer}
    layers:
      - ${self:custom.databaseLayer}
      - ${self:custom.generalUtilsLayer}
    package:  
      include:
        - src/package-type/edit/**

  PackageTypeView:
    handler: src/package-type/view/handler.handle
    vpc:
        securityGroupIds:
          - {"Fn::ImportValue": "${self:custom.stage}LambdaSecurityGroup"}
        subnetIds:
          - {"Fn::ImportValue": "${self:custom.stage}PublicSubnet1"}
          - {"Fn::ImportValue": "${self:custom.stage}PublicSubnet2"}
    name: package-type-view-${self:custom.stage}
    memorySize: 128
    timeout: 6
    environment: ${file(${self:custom.stage}.env.yml):db-lambda}
    events:
      - http: 
          path: package-type/{package_type_id}
          method: get
          cors:
            origin: '*'
            headers: 
              - Content-Type
              - X-Amz-Date
              - Authorization
              - X-Api-Key
              - X-Amz-Security-Token
              - AccessToken
              - IdToken
            allowCredentials: false
          authorizer:
            type: COGNITO_USER_POOLS
            authorizerId: ${self:custom.cognitoAuthorizer}
    layers:
      - ${self:custom.databaseLayer}
      - ${self:custom.generalUtilsLayer}
    package:  
      include:
        - src/package-type/view/**

  PackageTypeDelete:
    handler: src/package-type/delete/handler.handle
    vpc:
        securityGroupIds:
          - {"Fn::ImportValue": "${self:custom.stage}LambdaSecurityGroup"}
        subnetIds:
          - {"Fn::ImportValue": "${self:custom.stage}PublicSubnet1"}
          - {"Fn::ImportValue": "${self:custom.stage}PublicSubnet2"}
    name: package-type-delete-${self:custom.stage}
    memorySize: 128
    timeout: 6
    environment: ${file(${self:custom.stage}.env.yml):db-lambda}
    events:
      - http: 
          path: package-type/{package_type_id}
          method: delete
          cors:
            origin: '*'
            headers: 
              - Content-Type
              - X-Amz-Date
              - Authorization
              - X-Api-Key
              - X-Amz-Security-Token
              - AccessToken
              - IdToken
            allowCredentials: false
          authorizer:
            type: TOKEN
            authorizerId: ${self:custom.superAdminAuthorizer}
    layers:
      - ${self:custom.databaseLayer}
      - ${self:custom.generalUtilsLayer}
    package:  
      include:
        - src/package-type/delete/**

  MedicineDosageTypeCreate:
    handler: src/medicine-dosage-type/create/handler.handle
    vpc:
        securityGroupIds:
          - {"Fn::ImportValue": "${self:custom.stage}LambdaSecurityGroup"}
        subnetIds:
          - {"Fn::ImportValue": "${self:custom.stage}PublicSubnet1"}
          - {"Fn::ImportValue": "${self:custom.stage}PublicSubnet2"}
    name: medicine-dosage-type-create-${self:custom.stage}
    memorySize: 128
    timeout: 6
    environment: ${file(${self:custom.stage}.env.yml):db-lambda}
    events:
      - http: 
          path: medicine/{medicine_id}/dosage-type
          method: post
          cors:
            origin: '*'
            headers: 
              - Content-Type
              - X-Amz-Date
              - Authorization
              - X-Api-Key
              - X-Amz-Security-Token
              - AccessToken
              - IdToken
            allowCredentials: false
          authorizer:
            type: TOKEN
            authorizerId: ${self:custom.prescriptionAuthorizer}
    layers:
      - ${self:custom.databaseLayer}
      - ${self:custom.generalUtilsLayer}
    package:  
      include:
        - src/medicine-dosage-type/create/**

  MedicineDosageTypeList:
    handler: src/medicine-dosage-type/list/handler.handle
    vpc:
        securityGroupIds:
          - {"Fn::ImportValue": "${self:custom.stage}LambdaSecurityGroup"}
        subnetIds:
          - {"Fn::ImportValue": "${self:custom.stage}PublicSubnet1"}
          - {"Fn::ImportValue": "${self:custom.stage}PublicSubnet2"}
    name: medicine-dosage-type-list-${self:custom.stage}
    memorySize: 128
    timeout: 6
    environment: ${file(${self:custom.stage}.env.yml):db-lambda}
    events:
      - http: 
          path: medicine/{medicine_id}/dosage-type
          method: get
          cors:
            origin: '*'
            headers: 
              - Content-Type
              - X-Amz-Date
              - Authorization
              - X-Api-Key
              - X-Amz-Security-Token
              - AccessToken
              - IdToken
            allowCredentials: false
          authorizer:
            type: COGNITO_USER_POOLS
            authorizerId: ${self:custom.cognitoAuthorizer}
    layers:
      - ${self:custom.databaseLayer}
      - ${self:custom.generalUtilsLayer}
    package:  
      include:
        - src/medicine-dosage-type/list/**

  MedicineDosageTypeEdit:
    handler: src/medicine-dosage-type/edit/handler.handle
    vpc:
        securityGroupIds:
          - {"Fn::ImportValue": "${self:custom.stage}LambdaSecurityGroup"}
        subnetIds:
          - {"Fn::ImportValue": "${self:custom.stage}PublicSubnet1"}
          - {"Fn::ImportValue": "${self:custom.stage}PublicSubnet2"}
    name: medicine-dosage-type-edit-${self:custom.stage}
    memorySize: 128
    timeout: 6
    environment: ${file(${self:custom.stage}.env.yml):db-lambda}
    events:
      - http: 
          path: medicine/{medicine_id}/dosage-type/{medicine_dosage_type_id}
          method: put
          cors:
            origin: '*'
            headers: 
              - Content-Type
              - X-Amz-Date
              - Authorization
              - X-Api-Key
              - X-Amz-Security-Token
              - AccessToken
              - IdToken
            allowCredentials: false
          authorizer:
            type: TOKEN
            authorizerId: ${self:custom.prescriptionAuthorizer}
    layers:
      - ${self:custom.databaseLayer}
      - ${self:custom.generalUtilsLayer}
    package:  
      include:
        - src/medicine-dosage-type/edit/**

  MedicineDosageTypeView:
    handler: src/medicine-dosage-type/view/handler.handle
    vpc:
        securityGroupIds:
          - {"Fn::ImportValue": "${self:custom.stage}LambdaSecurityGroup"}
        subnetIds:
          - {"Fn::ImportValue": "${self:custom.stage}PublicSubnet1"}
          - {"Fn::ImportValue": "${self:custom.stage}PublicSubnet2"}
    name: medicine-dosage-type-view-${self:custom.stage}
    memorySize: 128
    timeout: 6
    environment: ${file(${self:custom.stage}.env.yml):db-lambda}
    events:
      - http: 
          path: medicine/{medicine_id}/dosage-type/{medicine_dosage_type_id}
          method: get
          cors:
            origin: '*'
            headers: 
              - Content-Type
              - X-Amz-Date
              - Authorization
              - X-Api-Key
              - X-Amz-Security-Token
              - AccessToken
              - IdToken
            allowCredentials: false
          authorizer:
            type: COGNITO_USER_POOLS
            authorizerId: ${self:custom.cognitoAuthorizer}
    layers:
      - ${self:custom.databaseLayer}
      - ${self:custom.generalUtilsLayer}
    package:  
      include:
        - src/medicine-dosage-type/view/**

  MedicineDosageTypeDelete:
    handler: src/medicine-dosage-type/delete/handler.handle
    vpc:
        securityGroupIds:
          - {"Fn::ImportValue": "${self:custom.stage}LambdaSecurityGroup"}
        subnetIds:
          - {"Fn::ImportValue": "${self:custom.stage}PublicSubnet1"}
          - {"Fn::ImportValue": "${self:custom.stage}PublicSubnet2"}
    name: medicine-dosage-type-delete-${self:custom.stage}
    memorySize: 128
    timeout: 6
    environment: ${file(${self:custom.stage}.env.yml):db-lambda}
    events:
      - http: 
          path: medicine/{medicine_id}/dosage-type/{medicine_dosage_type_id}
          method: delete
          cors:
            origin: '*'
            headers: 
              - Content-Type
              - X-Amz-Date
              - Authorization
              - X-Api-Key
              - X-Amz-Security-Token
              - AccessToken
              - IdToken
            allowCredentials: false
          authorizer:
            type: TOKEN
            authorizerId: ${self:custom.superAdminAuthorizer}
    layers:
      - ${self:custom.databaseLayer}
      - ${self:custom.generalUtilsLayer}
    package:  
      include:
        - src/medicine-dosage-type/delete/**

  MedicineDosagePackageTypeCreate:
    handler: src/medicine-dosage-package-type/create/handler.handle
    vpc:
        securityGroupIds:
          - {"Fn::ImportValue": "${self:custom.stage}LambdaSecurityGroup"}
        subnetIds:
          - {"Fn::ImportValue": "${self:custom.stage}PublicSubnet1"}
          - {"Fn::ImportValue": "${self:custom.stage}PublicSubnet2"}
    name: medicine-dosage-package-type-create-${self:custom.stage}
    memorySize: 128
    timeout: 6
    environment: ${file(${self:custom.stage}.env.yml):db-lambda}
    events:
      - http: 
          path: medicine/{medicine_id}/dosage-type/{medicine_dosage_type_id}/package
          method: post
          cors:
            origin: '*'
            headers: 
              - Content-Type
              - X-Amz-Date
              - Authorization
              - X-Api-Key
              - X-Amz-Security-Token
              - AccessToken
              - IdToken
            allowCredentials: false
          authorizer:
            type: TOKEN
            authorizerId: ${self:custom.prescriptionAuthorizer}
    layers:
      - ${self:custom.databaseLayer}
      - ${self:custom.generalUtilsLayer}
    package:  
      include:
        - src/medicine-dosage-package-type/create/**

  MedicineDosagePackageTypeList:
    handler: src/medicine-dosage-package-type/list/handler.handle
    vpc:
        securityGroupIds:
          - {"Fn::ImportValue": "${self:custom.stage}LambdaSecurityGroup"}
        subnetIds:
          - {"Fn::ImportValue": "${self:custom.stage}PublicSubnet1"}
          - {"Fn::ImportValue": "${self:custom.stage}PublicSubnet2"}
    name: medicine-dosage-package-type-list-${self:custom.stage}
    memorySize: 128
    timeout: 6
    environment: ${file(${self:custom.stage}.env.yml):db-lambda}
    events:
      - http: 
          path: medicine/{medicine_id}/dosage-type/{medicine_dosage_type_id}/package
          method: get
          cors:
            origin: '*'
            headers: 
              - Content-Type
              - X-Amz-Date
              - Authorization
              - X-Api-Key
              - X-Amz-Security-Token
              - AccessToken
              - IdToken
            allowCredentials: false
          authorizer:
            type: COGNITO_USER_POOLS
            authorizerId: ${self:custom.cognitoAuthorizer}
    layers:
      - ${self:custom.databaseLayer}
      - ${self:custom.generalUtilsLayer}
    package:  
      include:
        - src/medicine-dosage-package-type/list/**

  MedicineDosagePackageTypeEdit:
    handler: src/medicine-dosage-package-type/edit/handler.handle
    vpc:
        securityGroupIds:
          - {"Fn::ImportValue": "${self:custom.stage}LambdaSecurityGroup"}
        subnetIds:
          - {"Fn::ImportValue": "${self:custom.stage}PublicSubnet1"}
          - {"Fn::ImportValue": "${self:custom.stage}PublicSubnet2"}
    name: medicine-dosage-package-type-edit-${self:custom.stage}
    memorySize: 128
    timeout: 6
    environment: ${file(${self:custom.stage}.env.yml):db-lambda}
    events:
      - http: 
          path: medicine/{medicine_id}/dosage-type/{medicine_dosage_type_id}/package/{medicine_dosage_package_type_id}
          method: put
          cors:
            origin: '*'
            headers: 
              - Content-Type
              - X-Amz-Date
              - Authorization
              - X-Api-Key
              - X-Amz-Security-Token
              - AccessToken
              - IdToken
            allowCredentials: false
          authorizer:
            type: TOKEN
            authorizerId: ${self:custom.prescriptionAuthorizer}
    layers:
      - ${self:custom.databaseLayer}
      - ${self:custom.generalUtilsLayer}
    package:  
      include:
        - src/medicine-dosage-package-type/edit/**

  MedicineDosagePackageTypeView:
    handler: src/medicine-dosage-package-type/view/handler.handle
    vpc:
        securityGroupIds:
          - {"Fn::ImportValue": "${self:custom.stage}LambdaSecurityGroup"}
        subnetIds:
          - {"Fn::ImportValue": "${self:custom.stage}PublicSubnet1"}
          - {"Fn::ImportValue": "${self:custom.stage}PublicSubnet2"}
    name: medicine-dosage-package-type-view-${self:custom.stage}
    memorySize: 128
    timeout: 6
    environment: ${file(${self:custom.stage}.env.yml):db-lambda}
    events:
      - http: 
          path: medicine/{medicine_id}/dosage-type/{medicine_dosage_type_id}/package/{medicine_dosage_package_type_id}
          method: get
          cors:
            origin: '*'
            headers: 
              - Content-Type
              - X-Amz-Date
              - Authorization
              - X-Api-Key
              - X-Amz-Security-Token
              - AccessToken
              - IdToken
            allowCredentials: false
          authorizer:
            type: COGNITO_USER_POOLS
            authorizerId: ${self:custom.cognitoAuthorizer}
    layers:
      - ${self:custom.databaseLayer}
      - ${self:custom.generalUtilsLayer}
    package:  
      include:
        - src/medicine-dosage-package-type/view/**

  MedicineDosagePackageTypeDelete:
    handler: src/medicine-dosage-package-type/delete/handler.handle
    vpc:
        securityGroupIds:
          - {"Fn::ImportValue": "${self:custom.stage}LambdaSecurityGroup"}
        subnetIds:
          - {"Fn::ImportValue": "${self:custom.stage}PublicSubnet1"}
          - {"Fn::ImportValue": "${self:custom.stage}PublicSubnet2"}
    name: medicine-dosage-package-type-delete-${self:custom.stage}
    memorySize: 128
    timeout: 6
    environment: ${file(${self:custom.stage}.env.yml):db-lambda}
    events:
      - http: 
          path: medicine/{medicine_id}/dosage-type/{medicine_dosage_type_id}/package/{medicine_dosage_package_type_id}
          method: delete
          cors:
            origin: '*'
            headers: 
              - Content-Type
              - X-Amz-Date
              - Authorization
              - X-Api-Key
              - X-Amz-Security-Token
              - AccessToken
              - IdToken
            allowCredentials: false
          authorizer:
            type: TOKEN
            authorizerId: ${self:custom.superAdminAuthorizer}
    layers:
      - ${self:custom.databaseLayer}
      - ${self:custom.generalUtilsLayer}
    package:  
      include:
        - src/medicine-dosage-package-type/delete/**