This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const publishToKinesis = async (payload) => { | |
// Publishing logic here which is irrelevant now | |
}; | |
// NOTE : Although I believe that this code is mostly correct, I confess that I never ran it | |
// so it may contain some minor syntax errors or something like that.... | |
export const handler = ({ Records: dynamoDbRecords }) => { | |
const promises = dynamoDbRecords.map(({ dynamodb: { OldImage: oldImage } }) => { | |
if (oldImage && oldImage.recordType === 'STATUS_TASK') { // We interested only in deleted records of type STATUS_TASK | |
return oldImage; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const aws = require('aws-sdk'); | |
const dynamodb = new aws.DynamoDB.DocumentClient(); | |
const uuid = require('uuid/v4'); | |
const addToDynamoDb = async ({ butterflyName, bornTime }) => { | |
const butterflyId = uuid(); | |
const nowTimestamp = new Date().getTime(); // Date when a butterfly is born as an egg | |
const becomesCaterpilarAt = nowTimestamp + 7 * 24 * 60 * 60 * 1000; // Time when an egg becomes a caterpilar (update terminology in the blog) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
service: wick-quotes | |
provider: | |
name: aws | |
runtime: nodejs8.10 | |
stage: dev | |
environment: | |
iamRoleStatements: | |
- Effect: Allow | |
Action: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
region=$1 | |
# Quit on error | |
set -e | |
# 1. Update stream settings. | |
aws dynamodb update-table --table-name "JohnWickQuotes" --stream-specification StreamEnabled=true,StreamViewType=NEW_AND_OLD_IMAGES --region $region |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
region=$1 | |
tableName="JohnWickQuotes" | |
aws dynamodb update-time-to-live --table-name $tableName --time-to-live-specification Enabled=true,AttributeName=ttl --region $region |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Passing the region name as a parameter | |
region=$1 | |
tableName="JohnWickQuotes" | |
dir="${BASH_SOURCE%/*}" | |
tableDefinitionPath="$dir/table-definition.json" | |
# Trigger table creation |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM amazonlinux:latest | |
RUN curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.8/install.sh | bash | |
RUN export NVM_DIR="$HOME/.nvm" && [ -s "$NVM_DIR/nvm.sh" ] \ | |
&& \. "$NVM_DIR/nvm.sh" && [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" \ | |
&& nvm install v6.10.0 \ | |
&& npm install serverless -g \ | |
&& npm install newman -g \ | |
&& npm install serverless-localstack -g |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const R = require('ramda'); | |
// Imaginary repository that has a promisified method called putHello(). | |
const repo = require('./hello-repo'); | |
// Imaginary notification scheduler. | |
const notificationService = require('./notification-service'); | |
// First, let's write the steps one by one. | |
module.exports = R.pipeP( |