-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Description
All CDK apps today have this boilerplate.
JavaScript:
const app = new App(process.argv);
// add stack here
process.stdout.write(app.run());Java:
public static void main(final String argv[]) {
App app = new App(Arrays.asList(argv));
// add stack here
System.out.writeln(app.run());
}The reason we need this boilerplate is due to how the toolkit and CDK apps interact, and the fact that the toolkit is language-agnostic. As far as the toolkit is concerned, CDK apps are executables that adhere to the "cx-api" interface, which is using ARGV to accept inputs and STDOUT as outputs. This is the lowest common denominator across languages (any language out there allows you to write programs that accept ARGV and emit STDOUT).
This is all good an fine, but there's no value in exposing this to users if we can provide a better experience (understanding this protocol is not something that most users will benefit from).
Let's modify the protocol such that instead of ARGV/STDOUT it will pass in the toolkit request via environment variables and the output will be emitted to a temporary working directory. This will make the app boilerplate code look like this:
const app = new cdk.App();
new MyStack(app, 'stack1');
new YourStack(app, 'stack2');
app.run();Much cleaner.