-
-
Save clstokes/c162a4596061b8d92f9298bb70c9bbb1 to your computer and use it in GitHub Desktop.
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
import * as pulumi from "@pulumi/pulumi"; | |
import * as random from "@pulumi/random"; | |
const config = new pulumi.Config(); | |
const numberOfSecrets = config.getNumber("numberOfSecrets") || 1; | |
for (let i = 0; i < numberOfSecrets; i++) { | |
const secret = new random.RandomPassword(`main-${i}`, { | |
length: 4, | |
}); | |
} |
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
{ | |
"name": "p-secret", | |
"devDependencies": { | |
"@types/node": "^10.0.0" | |
}, | |
"dependencies": { | |
"@pulumi/pulumi": "^2.21.2", | |
"@pulumi/random": "^3.0.3", | |
"ts-node": "^7.0.1" | |
}, | |
"scripts": { | |
"repro": "./node_modules/ts-node/dist/bin.js repro.ts" | |
} | |
} |
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
name: p-secret | |
runtime: nodejs | |
description: A minimal TypeScript Pulumi program |
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
import { LocalWorkspace, Stack } from "@pulumi/pulumi/x/automation"; | |
import * as child_process from "child_process"; | |
const resetStack = async (localWorkspace: Stack) => { | |
// process.stdout.write(`Removing all resources via [export] and [import]...`); | |
const exportedStack = await localWorkspace.exportStack(); | |
exportedStack.deployment.resources = []; | |
await localWorkspace.importStack(exportedStack); | |
// process.stdout.write(` Done.\n`); | |
}; | |
const run = async () => { | |
const localWorkspace = await LocalWorkspace.createOrSelectStack({ | |
stackName: "dev", | |
workDir: ".", | |
}); | |
const iterations = [1, 10, 100, 500, 1000]; | |
for (const num of iterations) { | |
await resetStack(localWorkspace); | |
await localWorkspace.setConfig("numberOfSecrets", { value: num.toString() }); | |
process.stdout.write(`Calling [pulumi up] with [${num}] secrets...`); | |
const upRes = await localWorkspace.up(); | |
process.stdout.write(` Done.\n`); | |
const start = new Date().getTime(); | |
child_process.execSync("pulumi stack", { cwd: "." }); | |
const end = new Date().getTime(); | |
process.stdout.write(`Calling [pulumi stack] with [${num}] secrets took [${Math.floor((end - start) / 1000)}] seconds.\n`); | |
process.stdout.write(`\n`); | |
} | |
}; | |
run(); |
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
Show hidden characters
{ | |
"compilerOptions": { | |
"strict": true, | |
"outDir": "bin", | |
"target": "es2016", | |
"module": "commonjs", | |
"moduleResolution": "node", | |
"sourceMap": true, | |
"experimentalDecorators": true, | |
"pretty": true, | |
"noFallthroughCasesInSwitch": true, | |
"noImplicitReturns": true, | |
"forceConsistentCasingInFileNames": true | |
}, | |
"files": [ | |
"index.ts" | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment