Skip to content

Instantly share code, notes, and snippets.

@shierro

shierro/serverless.yml

Last active Jun 25, 2020
Embed
What would you like to do?
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