Created
March 29, 2021 20:23
-
-
Save EvanBoyle/ac4d50a5cf9c66ce5302e0c325a18e8b to your computer and use it in GitHub Desktop.
4k dynamic resources leads to resource exhaustion
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"; | |
function timeout(ms: any) { | |
return new Promise(resolve => setTimeout(resolve, ms)); | |
} | |
async function sleep(fn: any, ...args: any) { | |
await timeout(1); | |
return fn(...args); | |
} | |
const myProvider: pulumi.dynamic.ResourceProvider = { | |
async create(inputs) { | |
await sleep(() => { }) | |
return { id: "foo", outs: {} }; | |
}, | |
async diff(inputs) { | |
await sleep(() => { }) | |
return {} | |
}, | |
async check(inputs) { | |
await sleep(() => { }) | |
return { inputs } | |
} | |
} | |
class MyResource extends pulumi.dynamic.Resource { | |
constructor(name: string, props: {}, opts?: pulumi.CustomResourceOptions) { | |
super(myProvider, name, props, opts); | |
} | |
} | |
class Component extends pulumi.ComponentResource { | |
constructor(name: string, args = {}, opts = {}) { | |
super("lotsofdynamics", name, args, opts); | |
let arr = Array.from(Array(2000).keys()) | |
arr.forEach((i) => { | |
new MyResource(name+i.toString(), {}) | |
}) | |
} | |
} | |
export = async () => { | |
["foo", "bar"].forEach(n => { | |
new Component(n) | |
}) | |
return { | |
foo: "abc" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment