2018-05-04 23:01:45 +03:00
|
|
|
service: watchdog-proxy
|
|
|
|
|
|
|
|
plugins:
|
|
|
|
- serverless-s3-remover
|
2018-05-07 23:34:17 +03:00
|
|
|
- serverless-apigw-binary
|
2018-05-04 23:01:45 +03:00
|
|
|
|
|
|
|
custom:
|
2018-05-11 22:43:36 +03:00
|
|
|
localConfig: ${file(serverless.local.yml)}
|
2018-05-04 23:01:45 +03:00
|
|
|
region: ${self:provider.region}
|
2018-05-11 22:43:36 +03:00
|
|
|
stage: ${self:provider.stage}
|
2018-05-04 23:01:45 +03:00
|
|
|
prefix: ${self:service}-${self:custom.stage}
|
|
|
|
process: ${self:custom.prefix}-processQueueItem
|
|
|
|
config: ${self:custom.prefix}-config
|
|
|
|
credentials: ${self:custom.prefix}-credentials
|
|
|
|
sqs: ${self:custom.prefix}-messages
|
|
|
|
contentBucket: ${self:custom.prefix}-content
|
2018-05-09 21:27:08 +03:00
|
|
|
remover:
|
|
|
|
buckets:
|
|
|
|
- ${self:custom.contentBucket}
|
|
|
|
apigwBinary:
|
|
|
|
types:
|
|
|
|
- 'multipart/form-data'
|
2018-05-04 23:01:45 +03:00
|
|
|
fnEnv:
|
|
|
|
NODE_ENV: ${env:NODE_ENV,"production"}
|
2018-05-11 22:43:36 +03:00
|
|
|
DISABLE_AUTH_CACHE: ${env:DISABLE_AUTH_CACHE, "0"}
|
2018-05-04 23:01:45 +03:00
|
|
|
ENABLE_DEV_AUTH: ${env:ENABLE_DEV_AUTH,"0"}
|
2018-05-11 22:43:36 +03:00
|
|
|
UPSTREAM_SERVICE_URL: ${env:UPSTREAM_SERVICE_URL, self:custom.localConfig.upstreamService.url}
|
|
|
|
UPSTREAM_SERVICE_KEY: ${env:UPSTREAM_SERVICE_KEY, self:custom.localConfig.upstreamService.key}
|
2018-05-04 23:01:45 +03:00
|
|
|
SERVICE_STAGE: ${self:custom.stage}
|
|
|
|
SERVICE_PREFIX: ${self:custom.prefix}
|
|
|
|
CONFIG_TABLE: ${self:custom.config}
|
|
|
|
CREDENTIALS_TABLE: ${self:custom.credentials}
|
|
|
|
QUEUE_NAME: ${self:custom.sqs}
|
|
|
|
CONTENT_BUCKET: ${self:custom.contentBucket}
|
|
|
|
PROCESS_QUEUE_FUNCTION: ${self:custom.process}
|
|
|
|
|
|
|
|
provider:
|
|
|
|
name: aws
|
|
|
|
runtime: nodejs8.10
|
2018-05-11 22:43:36 +03:00
|
|
|
stage: ${self:custom.localConfig.stage, opt:stage, 'dev'}
|
2018-05-04 23:01:45 +03:00
|
|
|
region: us-east-1
|
|
|
|
memorySize: 128
|
|
|
|
iamRoleStatements:
|
|
|
|
- Effect: Allow
|
|
|
|
Action:
|
|
|
|
- dynamodb:GetItem
|
|
|
|
- dynamodb:PutItem
|
|
|
|
- dynamodb:DeleteItem
|
|
|
|
- dynamodb:UpdateItem
|
|
|
|
- dynamodb:Query
|
|
|
|
- dynamodb:Scan
|
|
|
|
Resource:
|
|
|
|
- arn:aws:dynamodb:*:*:table/${self:custom.config}
|
|
|
|
- arn:aws:dynamodb:*:*:table/${self:custom.credentials}
|
|
|
|
- Effect: Allow
|
|
|
|
Action:
|
|
|
|
- lambda:InvokeFunction
|
|
|
|
Resource: arn:aws:lambda:*:*:function:${self:custom.process}
|
|
|
|
- Effect: Allow
|
|
|
|
Action:
|
|
|
|
- sqs:ChangeMessageVisibility
|
|
|
|
- sqs:ChangeMessageVisibilityBatch
|
|
|
|
- sqs:DeleteMessage
|
|
|
|
- sqs:DeleteMessageBatch
|
|
|
|
- sqs:GetQueueAttributes
|
|
|
|
- sqs:GetQueueUrl
|
|
|
|
- sqs:ReceiveMessage
|
|
|
|
- sqs:SendMessage
|
|
|
|
- sqs:SendMessageBatch
|
|
|
|
Resource: arn:aws:sqs:*:*:${self:custom.sqs}
|
|
|
|
- Effect: Allow
|
|
|
|
Action:
|
|
|
|
- s3:GetObject
|
|
|
|
- s3:PutObject
|
|
|
|
- s3:PutObjectAcl
|
|
|
|
- s3:DeleteObject
|
|
|
|
- s3:ListBucket
|
|
|
|
Resource:
|
|
|
|
- arn:aws:s3:::${self:custom.contentBucket}
|
|
|
|
- arn:aws:s3:::${self:custom.contentBucket}/*
|
|
|
|
|
|
|
|
resources:
|
|
|
|
Resources:
|
|
|
|
|
|
|
|
S3BucketContent:
|
|
|
|
Type: AWS::S3::Bucket
|
|
|
|
Properties:
|
|
|
|
BucketName: ${self:custom.contentBucket}
|
|
|
|
LifecycleConfiguration:
|
|
|
|
Rules:
|
|
|
|
- Id: DailyCleanup
|
|
|
|
Status: Enabled
|
2018-05-07 23:34:17 +03:00
|
|
|
ExpirationInDays: 30
|
2018-05-04 23:01:45 +03:00
|
|
|
|
|
|
|
Messages:
|
|
|
|
Type: AWS::SQS::Queue
|
|
|
|
Properties:
|
|
|
|
QueueName: ${self:custom.sqs}
|
|
|
|
MessageRetentionPeriod: 1209600
|
|
|
|
VisibilityTimeout: 60
|
|
|
|
RedrivePolicy:
|
|
|
|
deadLetterTargetArn:
|
|
|
|
Fn::GetAtt:
|
|
|
|
- MessagesDeadLetterQueue
|
|
|
|
- Arn
|
|
|
|
maxReceiveCount: 10
|
|
|
|
|
|
|
|
MessagesDeadLetterQueue:
|
|
|
|
Type: AWS::SQS::Queue
|
|
|
|
Properties:
|
|
|
|
QueueName: ${self:custom.sqs}-dead-letter-queue
|
|
|
|
MessageRetentionPeriod: 1209600
|
|
|
|
|
|
|
|
Credentials:
|
|
|
|
Type: AWS::DynamoDB::Table
|
|
|
|
Properties:
|
|
|
|
TableName: ${self:custom.credentials}
|
|
|
|
AttributeDefinitions:
|
|
|
|
- AttributeName: id
|
|
|
|
AttributeType: S
|
|
|
|
KeySchema:
|
|
|
|
- AttributeName: id
|
|
|
|
KeyType: HASH
|
|
|
|
ProvisionedThroughput:
|
|
|
|
ReadCapacityUnits: 5
|
|
|
|
WriteCapacityUnits: 5
|
|
|
|
|
|
|
|
Config:
|
|
|
|
Type: AWS::DynamoDB::Table
|
|
|
|
Properties:
|
|
|
|
TableName: ${self:custom.config}
|
|
|
|
AttributeDefinitions:
|
|
|
|
- AttributeName: key
|
|
|
|
AttributeType: S
|
|
|
|
KeySchema:
|
|
|
|
- AttributeName: key
|
|
|
|
KeyType: HASH
|
|
|
|
ProvisionedThroughput:
|
|
|
|
ReadCapacityUnits: 5
|
|
|
|
WriteCapacityUnits: 5
|
|
|
|
|
|
|
|
package:
|
|
|
|
exclude:
|
|
|
|
- docs/**
|
|
|
|
- helpers/**
|
|
|
|
- test/**
|
2018-05-09 21:27:08 +03:00
|
|
|
- functions/**/*-test.js
|
2018-05-04 23:01:45 +03:00
|
|
|
|
|
|
|
functions:
|
|
|
|
|
|
|
|
accept:
|
|
|
|
handler: functions/accept.post
|
|
|
|
name: ${self:custom.prefix}-accept
|
|
|
|
environment: ${self:custom.fnEnv}
|
|
|
|
events:
|
|
|
|
- http:
|
|
|
|
path: accept
|
|
|
|
method: post
|
|
|
|
|
|
|
|
pollQueue:
|
|
|
|
timeout: 60
|
|
|
|
handler: functions/pollQueue.handler
|
|
|
|
name: ${self:custom.prefix}-pollQueue
|
|
|
|
environment: ${self:custom.fnEnv}
|
|
|
|
events:
|
|
|
|
- schedule: rate(1 minute)
|
|
|
|
|
|
|
|
processQueueItem:
|
|
|
|
timeout: 60
|
|
|
|
handler: functions/processQueueItem.handler
|
|
|
|
name: ${self:custom.process}
|
|
|
|
environment: ${self:custom.fnEnv}
|