-
-
Save komalali/73cd83c2270cd77f50283a06b6a36083 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 secretsProvider = `awskms://${process.env.KMS_KEY}?region=${process.env.AWS_REGION}`; | |
const localWorkspace = await LocalWorkspace.createOrSelectStack({ | |
stackName: "dev", | |
workDir: ".", | |
}, { | |
projectSettings: { | |
name: "kms", | |
runtime: "nodejs", | |
backend: { | |
url: "file://~/.pulumi-local" | |
} | |
}, | |
secretsProvider, | |
stackSettings: { | |
dev: { | |
secretsProvider | |
} | |
} | |
}); | |
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 startUp = new Date().getTime(); | |
const upRes = await localWorkspace.up(); | |
const endUp = new Date().getTime(); | |
process.stdout.write(` took [${((endUp - startUp) / 1000).toFixed(2)}] seconds.\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 [${((end - start) / 1000).toFixed(2)}] 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