Skip to content

Instantly share code, notes, and snippets.

# serverless.yml
service: step-functions
plugins:
- serverless-step-functions
- serverless-bundle
provider:
profile: medium
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, 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 [truncated]
# ...
States:
ProposePromotion:
Type: Task
Resource: !GetAtt [proposePromotion, Arn]
ResultPath: "$.employeeDetails"
Next: GetManualReview
// handleDecisions.js
import handler from "./libs/handler-lib";
import AWS from "aws-sdk";
var stepfunctions = new AWS.StepFunctions();
var client = new AWS.DynamoDB.DocumentClient();
export const call = handler(async (event, context) => {
const body = JSON.parse(event.body);
* {
font-family: Arial, Helvetica, sans-serif;
}
.container {
text-align: center;
}
.card-container {
display: grid;
@owfm
owfm / App.js
Last active May 15, 2020 19:45
import React, { useState, useEffect } from "react";
import { useToasts } from "react-toast-notifications";
import { API } from "aws-amplify";
import "./App.css";
function App(props) {
const [promotionProposals, setPromotionProposals] = useState([]);
const [loading, setLoading] = useState(false);
const [refresh, setRefresh] = useState(new Date());
// index.js
import React from "react";
import ReactDOM from "react-dom";
import App from "./App";
import * as serviceWorker from "./serviceWorker";
import Amplify from "aws-amplify";
import { ToastProvider } from "react-toast-notifications";
Amplify.configure({
// 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
// getPendingPromotions.js
import handler from "./libs/handler-lib";
import AWS from "aws-sdk";
const client = new AWS.DynamoDB.DocumentClient();
export const call = handler(async (event, context) => {
const params = {
TableName: process.env.promotionsTable,