Skip to content

Instantly share code, notes, and snippets.

@owfm
owfm / serverless.yml
Created May 9, 2020 16:18
step-functions-serverless-yml-1
service: step-functions
plugins:
- serverless-step-functions
- serverless-bundle
provider:
profile: medium
name: aws
runtime: nodejs12.x
// email.js
'use-strict'
export const congratulations = (event, context) => {
return "Congrats! You got the job!";
};
export const commiserations = (event, context) => {
return "We're sorry, you weren't lucky this time.";
// proposePromotion.js
"use-strict";
import sample from "lodash/sample";
export const call = (event, context, callback) => {
const roles = [
"Tea Fetcher",
"CEO",
# serverless.yml
# ...
stepFunctions:
stateMachines:
promotionFlow:
events:
- http:
method: post
// generateProposal.js
"use-strict";
import sample from "lodash/sample";
export const call = (event, context, callback) => {
const roles = [
"Tea Fetcher",
"CEO",
service: step-functions
plugins:
- serverless-step-functions
- serverless-bundle
provider:
profile: medium
name: aws
runtime: nodejs12.x
// libs/handler-lib.js
export default function handler(lambda) {
return function (event, context) {
return Promise.resolve()
// Run the Lambda
.then(() => lambda(event, context))
// On success
.then((responseBody) => [200, responseBody])
// On failure
// email.js
"use-strict";
export const congratulations = (event, context, callback) => {
callback(
null,
`Dear ${event.employeeDetails.employeeName}, Congrats!
We'd like to offer you the promotion to the role of ${event.employeeDetails.proposedRole}!"`
);
# serverless.yml
service: step-functions
plugins:
- serverless-step-functions
- serverless-bundle
provider:
profile: medium
// storePromotions.js
import AWS from "aws-sdk";
const client = new AWS.DynamoDB.DocumentClient();
export const call = async (event, context) => {
const params = {
TableName: process.env.promotionsTable,
Item: {