service: lc-classified
description: LC Classified Lambda stack

frameworkVersion: '=1.36'

plugins:
  - serverless-plugin-canary-deployments
  - serverless-tag-api-gateway

custom:
  apiGatewayTags:
    App: lcpab
    Bloc: classified
    Comp: classified
    Env: ${opt:stage}
    Managed_by: Serverless
  deploymentSettings:
    codeDeployRole: arn:aws:iam::${self:custom.${opt:stage}.accountId}:role/lc-classified-codepipeline-codebuild-${opt:stage}
  dev:
    accountId: 629307289374
    statsBridgeLog: stats-logs-bridge-dev
    deploymentType: AllAtOnce
  dev2:
    accountId: 629307289374
    statsBridgeLog: stats-logs-bridge-dev
    deploymentType: AllAtOnce
  rec:
    accountId: 395174950964
    statsBridgeLog: stats-logs-bridge-rec
    deploymentType: AllAtOnce
  rec2:
    accountId: 395174950964
    statsBridgeLog: stats-logs-bridge-rec
    deploymentType: AllAtOnce
  prod:
    accountId: 395174950964
    statsBridgeLog: stats-logs-bridge-prod
    deploymentType: AllAtOnce

provider:
  role: arn:aws:iam::${self:custom.${opt:stage}.accountId}:role/lc-classified-lambda-role-${opt:stage}
  name: aws
  runtime: nodejs8.10
  region: eu-west-1
  memorySize: 768
  deploymentBucket: applications.${opt:stage}
  endpointType: REGIONAL
  stackTags:
   Bloc: classified
   App: lcpab
   Comp: classified
   Env: ${opt:stage}
  environment:
    NODE_ENV: production

package:
  exclude:
    - '**/*'
  include:
    - 'build/server.js'
    - 'build/classifiedShareByEmail.js'

functions:
  generalInformations:
    deploymentSettings:
      type: ${self:custom.${opt:stage}.deploymentType}
      alias: live
    handler: build/server.default
    events:
      - http: GET /general-informations
  mainInformations:
    deploymentSettings:
      type: ${self:custom.${opt:stage}.deploymentType}
      alias: live
    handler: build/server.default
    events:
    - http: GET /main-informations
  mainInformationsPriceEvolution:
    deploymentSettings:
      type: ${self:custom.${opt:stage}.deploymentType}
      alias: live
    handler: build/server.default
    events:
    - http: GET /main-informations-price-evolution
  maintenanceRepairs:
    deploymentSettings:
      type: ${self:custom.${opt:stage}.deploymentType}
      alias: live
    handler: build/server.default
    events:
    - http: GET /maintenance-repairs
  optionEquipment:
    deploymentSettings:
      type: ${self:custom.${opt:stage}.deploymentType}
      alias: live
    handler: build/server.default
    events:
    - http: GET /options-equipment
  photos:
    deploymentSettings:
      type: ${self:custom.${opt:stage}.deploymentType}
      alias: live
    handler: build/server.default
    events:
    - http: GET /photos
  sellerContact:
    deploymentSettings:
      type: ${self:custom.${opt:stage}.deploymentType}
      alias: live
    handler: build/server.default
    events:
    - http: 
        method: GET 
        path: /seller-contact
        cors: true
    - http: 
        method: OPTIONS 
        path: /seller-contact
        cors: true
  sellerContactForm:
    deploymentSettings:
      type: ${self:custom.${opt:stage}.deploymentType}
      alias: live
    handler: build/server.default
    events:
    - http: 
        method: GET 
        path: /seller-contact-form
        cors: true
    - http: 
        method: OPTIONS 
        path: /seller-contact-form
        cors: true
  sellerContactlocate:
    deploymentSettings:
      type: ${self:custom.${opt:stage}.deploymentType}
      alias: live
    handler: build/server.default
    events:
    - http: 
        method: GET 
        path: /seller-contact-locate
        cors: true
    - http: 
        method: OPTIONS 
        path: /seller-contact-locate
        cors: true
  sellerContactPhone:
    deploymentSettingsPhone:
      type: ${self:custom.${opt:stage}.deploymentType}
      alias: live
    handler: build/server.default
    events:
    - http:
        method: GET
        path: /seller-contact-phone
        cors: true
    - http:
        method: OPTIONS
        path: /seller-contact-phone
        cors: true
  sellerContactDisplayPhone:
    deploymentSettingsPhone:
      type: ${self:custom.${opt:stage}.deploymentType}
      alias: live
    handler: build/server.default
    events:
      - http:
          method: GET
          path: /seller-contact-display-phone
          cors: true
      - http:
          method: OPTIONS
          path: /seller-contact-display-phone
          cors: true
  security:
    deploymentSettings:
      type: ${self:custom.${opt:stage}.deploymentType}
      alias: live
    handler: build/server.default
    events:
    - http: GET /security
  sondage:
    deploymentSettings:
      type: ${self:custom.${opt:stage}.deploymentType}
      alias: live
    handler: build/server.default
    events:
    - http: GET /sondage
  bookmarks:
    deploymentSettings:
      type: ${self:custom.${opt:stage}.deploymentType}
      alias: live
    handler: build/server.default
    events:
    - http: GET /toolbox-buttons
  classifiedShareByEmail:
    deploymentSettings:
      type: ${self:custom.${opt:stage}.deploymentType}
      alias: live
    handler: build/classifiedShareByEmail.default
    events:
    - http:
       method: POST
       path: /classified-share-by-email
       cors: true
    - http:
       method: OPTIONS
       path: /classified-share-by-email
       cors: true
resources:
  Resources:
    SubscriptionFilterGeneralInformationsLambdaFunction:
      Type: "AWS::Logs::SubscriptionFilter"
      Properties:
        LogGroupName: { Fn::Join: ["", ["/aws/lambda/", {"Ref": "GeneralInformationsLambdaFunction"}]]}
        FilterPattern: "{ $.event_date = * || $.log_index = * }"
        DestinationArn: { Fn::Join: ["", ["arn:aws:lambda:", { Ref: "AWS::Region" }, ":", { Ref: "AWS::AccountId" }, ":function:", "${self:custom.${opt:stage}.statsBridgeLog}" ]] }
    SubscriptionFilterMainInformationsLambdaFunction:
      Type: "AWS::Logs::SubscriptionFilter"
      Properties:
        LogGroupName: { Fn::Join: ["", ["/aws/lambda/", {"Ref": "MainInformationsLambdaFunction"}]]}
        FilterPattern: "{ $.event_date = * || $.log_index = * }"
        DestinationArn: { Fn::Join: ["", ["arn:aws:lambda:", { Ref: "AWS::Region" }, ":", { Ref: "AWS::AccountId" }, ":function:", "${self:custom.${opt:stage}.statsBridgeLog}" ]] }
    SubscriptionMainInformationsPriceEvolutionLambdaFunction:
      Type: "AWS::Logs::SubscriptionFilter"
      Properties:
        LogGroupName: { Fn::Join: ["", ["/aws/lambda/", {"Ref": "MainInformationsPriceEvolutionLambdaFunction"}]]}
        FilterPattern: "{ $.event_date = * || $.log_index = * }"
        DestinationArn: { Fn::Join: ["", ["arn:aws:lambda:", { Ref: "AWS::Region" }, ":", { Ref: "AWS::AccountId" }, ":function:", "${self:custom.${opt:stage}.statsBridgeLog}" ]] }
    SubscriptionMaintenanceRepairsLambdaFunction:
      Type: "AWS::Logs::SubscriptionFilter"
      Properties:
        LogGroupName: { Fn::Join: ["", ["/aws/lambda/", {"Ref": "MaintenanceRepairsLambdaFunction"}]]}
        FilterPattern: "{ $.event_date = * || $.log_index = * }"
        DestinationArn: { Fn::Join: ["", ["arn:aws:lambda:", { Ref: "AWS::Region" }, ":", { Ref: "AWS::AccountId" }, ":function:", "${self:custom.${opt:stage}.statsBridgeLog}" ]] }
    SubscriptionOptionEquipmentLambdaFunction:
      Type: "AWS::Logs::SubscriptionFilter"
      Properties:
        LogGroupName: { Fn::Join: ["", ["/aws/lambda/", {"Ref": "OptionEquipmentLambdaFunction"}]]}
        FilterPattern: "{ $.event_date = * || $.log_index = * }"
        DestinationArn: { Fn::Join: ["", ["arn:aws:lambda:", { Ref: "AWS::Region" }, ":", { Ref: "AWS::AccountId" }, ":function:", "${self:custom.${opt:stage}.statsBridgeLog}" ]] }
    SubscriptionPhotosLambdaFunction:
      Type: "AWS::Logs::SubscriptionFilter"
      Properties:
        LogGroupName: { Fn::Join: ["", ["/aws/lambda/", {"Ref": "PhotosLambdaFunction"}]]}
        FilterPattern: "{ $.event_date = * || $.log_index = * }"
        DestinationArn: { Fn::Join: ["", ["arn:aws:lambda:", { Ref: "AWS::Region" }, ":", { Ref: "AWS::AccountId" }, ":function:", "${self:custom.${opt:stage}.statsBridgeLog}" ]] }
    SubscriptionSellerContactFormLambdaFunction:
      Type: "AWS::Logs::SubscriptionFilter"
      Properties:
        LogGroupName: { Fn::Join: ["", ["/aws/lambda/", {"Ref": "SellerContactFormLambdaFunction"}]]}
        FilterPattern: "{ $.event_date = * || $.log_index = * }"
        DestinationArn: { Fn::Join: ["", ["arn:aws:lambda:", { Ref: "AWS::Region" }, ":", { Ref: "AWS::AccountId" }, ":function:", "${self:custom.${opt:stage}.statsBridgeLog}" ]] }
    SubscriptionSellerContactlocateLambdaFunction:
      Type: "AWS::Logs::SubscriptionFilter"
      Properties:
        LogGroupName: { Fn::Join: ["", ["/aws/lambda/", {"Ref": "SellerContactlocateLambdaFunction"}]]}
        FilterPattern: "{ $.event_date = * || $.log_index = * }"
        DestinationArn: { Fn::Join: ["", ["arn:aws:lambda:", { Ref: "AWS::Region" }, ":", { Ref: "AWS::AccountId" }, ":function:", "${self:custom.${opt:stage}.statsBridgeLog}" ]] }
    SubscriptionSellerContactLambdaFunction:
      Type: "AWS::Logs::SubscriptionFilter"
      Properties:
        LogGroupName: { Fn::Join: ["", ["/aws/lambda/", {"Ref": "SellerContactLambdaFunction"}]]}
        FilterPattern: "{ $.event_date = * || $.log_index = * }"
        DestinationArn: { Fn::Join: ["", ["arn:aws:lambda:", { Ref: "AWS::Region" }, ":", { Ref: "AWS::AccountId" }, ":function:", "${self:custom.${opt:stage}.statsBridgeLog}" ]] }
    SubscriptionSellerContactPhoneLambdaFunction:
      Type: "AWS::Logs::SubscriptionFilter"
      Properties:
        LogGroupName: { Fn::Join: ["", ["/aws/lambda/", {"Ref": "SellerContactPhoneLambdaFunction"}]]}
        FilterPattern: "{ $.event_date = * || $.log_index = * }"
        DestinationArn: { Fn::Join: ["", ["arn:aws:lambda:", { Ref: "AWS::Region" }, ":", { Ref: "AWS::AccountId" }, ":function:", "${self:custom.${opt:stage}.statsBridgeLog}" ]] }
    SubscriptionSellerContactDisplayPhoneLambdaFunction:
      Type: "AWS::Logs::SubscriptionFilter"
      Properties:
        LogGroupName: { Fn::Join: ["", ["/aws/lambda/", {"Ref": "SellerContactDisplayPhoneLambdaFunction"}]]}
        FilterPattern: "{ $.event_date = * || $.log_index = * }"
        DestinationArn: { Fn::Join: ["", ["arn:aws:lambda:", { Ref: "AWS::Region" }, ":", { Ref: "AWS::AccountId" }, ":function:", "${self:custom.${opt:stage}.statsBridgeLog}" ]] }
    SubscriptionSecurityLambdaFunction:
      Type: "AWS::Logs::SubscriptionFilter"
      Properties:
        LogGroupName: { Fn::Join: ["", ["/aws/lambda/", {"Ref": "SecurityLambdaFunction"}]]}
        FilterPattern: "{ $.event_date = * || $.log_index = * }"
        DestinationArn: { Fn::Join: ["", ["arn:aws:lambda:", { Ref: "AWS::Region" }, ":", { Ref: "AWS::AccountId" }, ":function:", "${self:custom.${opt:stage}.statsBridgeLog}" ]] }
    SubscriptionSondageLambdaFunction:
      Type: "AWS::Logs::SubscriptionFilter"
      Properties:
        LogGroupName: { Fn::Join: ["", ["/aws/lambda/", {"Ref": "SondageLambdaFunction"}]]}
        FilterPattern: "{ $.event_date = * || $.log_index = * }"
        DestinationArn: { Fn::Join: ["", ["arn:aws:lambda:", { Ref: "AWS::Region" }, ":", { Ref: "AWS::AccountId" }, ":function:", "${self:custom.${opt:stage}.statsBridgeLog}" ]] }
    SubscriptionBookmarksLambdaFunction:
      Type: "AWS::Logs::SubscriptionFilter"
      Properties:
        LogGroupName: { Fn::Join: ["", ["/aws/lambda/", {"Ref": "BookmarksLambdaFunction"}]]}
        FilterPattern: "{ $.event_date = * || $.log_index = * }"
        DestinationArn: { Fn::Join: ["", ["arn:aws:lambda:", { Ref: "AWS::Region" }, ":", { Ref: "AWS::AccountId" }, ":function:", "${self:custom.${opt:stage}.statsBridgeLog}" ]] }
    SubscriptionClassifiedShareByEmailLambdaFunction:
      Type: "AWS::Logs::SubscriptionFilter"
      Properties:
        LogGroupName: { Fn::Join: ["", ["/aws/lambda/", {"Ref": "ClassifiedShareByEmailLambdaFunction"}]]}
        FilterPattern: "{ $.event_date = * || $.log_index = * }"
        DestinationArn: { Fn::Join: ["", ["arn:aws:lambda:", { Ref: "AWS::Region" }, ":", { Ref: "AWS::AccountId" }, ":function:", "${self:custom.${opt:stage}.statsBridgeLog}" ]] }
