diff --git a/.gitignore b/.gitignore index fd4f2b0..59d37e2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ node_modules .DS_Store +.serverless diff --git a/serverless.yml b/serverless.yml new file mode 100644 index 0000000..b920ce3 --- /dev/null +++ b/serverless.yml @@ -0,0 +1,61 @@ +service: dynamodb-backup +frameworkVersion: "=1.26.0" + +provider: + name: aws + runtime: nodejs6.10 + region: ap-southeast-2 + + iamRoleStatements: + - Effect: "Allow" + Action: + - "logs:CreateLogGroup" + - "logs:CreateLogStream" + - "logs:PutLogEvents" + Resource: "arn:aws:logs:*:*:*" + - Effect: "Allow" + Action: + - "s3:ListBucket" + Resource: "" + - Effect: "Allow" + Action: + - "s3:GetObject" + - "s3:PutObject" + - "s3:DeleteObject" + Resource: "arn:aws:s3:::/*" + - 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: + + environment: + BackupRegion: + BackupBucket: + BackupPrefix: + +resources: + Resources: + BackupBucket: + Type: AWS::S3::Bucket + Properties: + BucketName: + VersioningConfiguration: + Status: "Enabled"