service: makam-webservice

package:
  include:
    - node_modules/
    - package.json

functions:
  makamQuery:
    handler: handler.makamQuery
    events:
     - http:
         path: makam/query
         method: post
         cors:
           origin: '*'
           headers:
             - Content-Type
             - X-Amz-Date
             - Authorization
             - X-Api-Key
             - X-Amz-Security-Token
             - X-Amz-User-Agent
           allowCredentials: true
    environment:
      MAKAM_CACHE_BUCKET: "${self:custom.cacheBucket}-${self:custom.stage}"

resources:
  Resources:
    S3CacheBucket:
      Type: AWS::S3::Bucket
      Properties:
        BucketName: "${self:custom.cacheBucket}-${self:custom.stage}"

provider:
  name: aws
  runtime: nodejs12.x
  memorySize: 2048
  timeout: 45
  versionFunctions: false
  iamRoleStatements:
    - Effect: Allow
      Action:
        - "s3:PutObject"
      Resource:
        Fn::Join:
          - ""
          - - "arn:aws:s3:::"
            - Ref: S3CacheBucket
            - "/*"
    - Effect: Allow
      Action:
        - "s3:GetObject"
      Resource:
        Fn::Join:
          - ""
          - - "arn:aws:s3:::"
            - Ref: S3CacheBucket
            - "/*"
    - Effect: Allow
      Action:
        - s3:ListBucket
      Resource:
        Fn::Join:
          - ""
          - - "arn:aws:s3:::"
            - Ref: S3CacheBucket

plugins:
  - serverless-offline
  - serverless-s3-remover

custom:
  serverless-offline:
    host: 0.0.0.0
  remover:
    prompt: true
  cacheBucket: "makam-webservice-cache"
  deployBucket: "makam-webservice-deploy"
  stage: ${opt:stage, 'dev'}
