Last active
June 29, 2019 08:38
-
-
Save jokeyrhyme/bb9aa1f11be7f4103981bd5ea1eaf5ed to your computer and use it in GitHub Desktop.
stress-test script to add 45 AWS APIG routes and 500 AWS Lambda functions via Serverless: https://serverless.com/
This file contains hidden or 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
'use strict' | |
const fs = require('fs') | |
const path = require('path') | |
const padStart = require('lodash.padstart') | |
const yaml = require('js-yaml') | |
const PROJECT_PATH = path.join(__dirname, '..') | |
const SERVERLESS_PATH = path.join(PROJECT_PATH, 'serverless.yml') | |
const TEMPLATE_PATH = path.join(PROJECT_PATH, 'handler.js') | |
const config = yaml.safeLoad(fs.readFileSync(SERVERLESS_PATH, 'utf8')) | |
for (let i = 1; i <= 45; i += 1) { | |
const name = 'handler' + padStart('' + i, 3, '0') | |
const targetPath = path.join(PROJECT_PATH, `${name}.js`) | |
fs.writeFileSync(targetPath, fs.readFileSync(TEMPLATE_PATH, 'utf8'), 'utf8') | |
config.functions[name] = { | |
events: [ | |
{ | |
http: `GET ${name}` | |
} | |
], | |
handler: `${name}.hello` | |
} | |
} | |
fs.writeFileSync(SERVERLESS_PATH, yaml.safeDump(config), 'utf8') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment