Skip to content

Instantly share code, notes, and snippets.

@jmelloy
Created October 9, 2017 19:11
Show Gist options
  • Save jmelloy/c0d9295b94e4286c1f006f3e3297e421 to your computer and use it in GitHub Desktop.
Save jmelloy/c0d9295b94e4286c1f006f3e3297e421 to your computer and use it in GitHub Desktop.
# Welcome to Serverless!
#
# This file is the main config file for your service.
# It's very minimal at this point and uses default values.
# You can always add more config options for more control.
# We've included some commented out config examples here.
# Just uncomment any of them to get that config option.
#
# For full config options, check the docs:
# docs.serverless.com
#
# Happy Coding!
service: dfareporting
# You can pin your service to only deploy with a specific Serverless version
# Check out our docs for more details
# frameworkVersion: "=X.X.X"
provider:
name: aws
runtime: python3.6
# you can overwrite defaults here
# stage: dev
region: us-west-2
stackTags:
App: dfareporting
memorySize: 128
# you can add statements to the Lambda function's IAM Role here
iamRoleStatements:
- Effect: Allow
Action:
- dynamodb:GetItem
- dynamodb:PutItem
- dynamodb:DeleteItem
- dynamodb:Scan
Resource:
- "arn:aws:dynamodb:*:*:table/${self:custom.prefix}-reports-table"
- Effect: Allow
Action:
- sqs:Get*
- sqs:List*
- cloudwatch:*
Resource: "*"
- Effect: "Allow"
Action:
- "s3:ListBucket"
- "s3:PutObject"
- "s3:GetObject"
Resource:
- arn:aws:s3:::${self:custom.prefix}-reports
- "arn:aws:s3:::${self:custom.prefix}-reports/*"
# you can define service wide environment variables here
# environment:
# variable1: value1
# you can add packaging information here
package:
include:
# - include-me.py
- lib/**
# exclude:
# - exclude-me.py
# - exclude-me-dir/**
custom:
region: ${self:provider.region}
stage: ${opt:stage, self:provider.stage}
prefix: ${self:service}-${self:custom.stage}
s3_bucket: ${self:custom.prefix}-reports
functions:
run_reports:
handler: handler.run_reports
events:
- schedule: cron(0 0/3 * * ? *)
environment:
table_name: ${self:custom.prefix}-reports-table
s3_bucket: ${self:custom.prefix}-reports
download_reports:
handler: handler.load_reports
events:
- schedule: cron(10 0/3 * * ? *)
environment:
table_name: ${self:custom.prefix}-reports-table
s3_bucket: ${self:custom.s3_bucket}
timeout: 300
memorySize: 256
process_reports:
handler: process.process_file
events:
- s3:
bucket: ${self:custom.s3_bucket}
# event: s3:ObjectCreated:*
environment:
s3_bucket: ${self:custom.s3_bucket}
memorySize: 512
timeout: 300
resources:
Resources:
Reports:
Type: AWS::DynamoDB::Table
Properties:
TableName: ${self:custom.prefix}-reports-table
AttributeDefinitions:
- AttributeName: id
AttributeType: S
KeySchema:
- AttributeName: id
KeyType: HASH
ProvisionedThroughput:
ReadCapacityUnits: 5
WriteCapacityUnits: 5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment