Skip to content

Added serverless service config #103

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
node_modules
.DS_Store
.serverless
61 changes: 61 additions & 0 deletions serverless.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
service: dynamodb-backup
frameworkVersion: "=1.26.0"

provider:
name: aws
runtime: nodejs6.10

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can update this to Node 8 now 😄

region: ap-southeast-2

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May be better not to specify region or to use a command line option instead


iamRoleStatements:
- Effect: "Allow"
Action:
- "logs:CreateLogGroup"
- "logs:CreateLogStream"
- "logs:PutLogEvents"
Resource: "arn:aws:logs:*:*:*"
- Effect: "Allow"
Action:
- "s3:ListBucket"
Resource: "<YOUR BACKUP BUCKET NAME>"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the environment variables were global (instead of per-function), we could retrieve this without users having to replace them manually

- Effect: "Allow"
Action:
- "s3:GetObject"
- "s3:PutObject"
- "s3:DeleteObject"
Resource: "arn:aws:s3:::<YOUR BACKUP BUCKET NAME>/*"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above

- Effect: "Allow"
Action: "lambda:InvokeFunction"
Resource: "*"
- Effect: "Allow"
Action:
- "dynamodb:DescribeStream"
- "dynamodb:GetRecords"
- "dynamodb:GetShardIterator"
- "dynamodb:ListStreams"
Resource: "*"

package:
include:
- ./*.js
- ./node_modules

functions:
index:
handler: index.backup

events:
- stream: <YOUR DYNAMODB STREAM ARN>

environment:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be better to move this to the global section so that we can reference them in other parts of the serverless.yml

BackupRegion: <YOUR REGION>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These could be retrieved as environment variables: ${env:REGION}

BackupBucket: <YOUR BACKUP BUCKET NAME>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above

BackupPrefix: <YOUR PREFIX>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above


resources:
Resources:
BackupBucket:
Type: AWS::S3::Bucket
Properties:
BucketName: <YOUR BACKUP BUCKET NAME>
VersioningConfiguration:
Status: "Enabled"