Skip to content

Instantly share code, notes, and snippets.

@shierro
Last active June 25, 2020 10:44
Show Gist options
  • Save shierro/e5136e34ae8ac12f7e3e94c7c6b7b555 to your computer and use it in GitHub Desktop.
Save shierro/e5136e34ae8ac12f7e3e94c7c6b7b555 to your computer and use it in GitHub Desktop.
service: cb-backend-boilerplate-lambda
parameters:
region: ap-southeast-2
path: &path /
provider:
name: aws
runtime: nodejs12.x
stage: ${env:STAGE, 'staging'}
region: ap-southeast-2
versionFunctions: false
logRetentionInDays: 3
stackTags:
SERVICE: ${self:service}
deploymentBucket: "trm-deployments"
environment:
STAGE: ${self:provider.stage}
REGION: ${self:provider.region}
NODE_ENV: ${env:NODE_ENV}
plugins:
- serverless-plugin-typescript
- serverless-dotenv-plugin
- serverless-pseudo-parameters
- serverless-iam-roles-per-function
- serverless-offline
package:
individually: true
functions:
signupAttempt:
handler: src/subscribers/signupAttempt.handler
name: ${self:service}-${self:provider.stage}-signupAttempt
events:
- http:
path: signupAttempt
method: get
- sns:
arn: arn:aws:sns:ap-southeast-2:131358606XXX:cb-user-dev
filterPolicy:
action: "signupAttempt"
resource: "few"
custom:
serverless-offline:
useChildProcesses: true
import * as _ from 'lodash'
export const handler = async (event) => {
// dependencies work as expected
console.log(_.VERSION)
// async/await also works out of the box
await new Promise((resolve, reject) => setTimeout(resolve, 500))
return {
statusCode: 200,
body: JSON.stringify({
message: Math.floor(Math.random() * 10) + 100,
test: true,
}),
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment