The Up phase creates, updates and deletes resources. This is the default mode and the most common. It’s how you deploy your app (synchronize resources).
constapp=awaitalchemy("my-app", {
phase: "up"
});
constworker=awaitWorker("my-app", { .. }); // <- will be created or updated
await app.finalize(); // <- will delete orphaned resources
The Read phase runs the program but never creates, updates or deletes any resources. It is useful for building shell scripts that need access to infrastructure properties (e.g. the )
constapp=awaitalchemy("my-app", {
phase: "read"
});
// will reconstruct itself from state and error if it does not exist
constworker=awaitWorker("my-app", { .. });
worker.url; // <- populated from `.alchemy/` state
await app.finalize() // <- will not delete any orphaned resources
./alchemy.run.ts
constapp=awaitalchemy({
phase: process.env.PHASE??"up"
});
// export your infrastructure
exportconstwebsite=awaitWorker(..);
Import the website from your alchemy.run.ts module and execute a shell command. alchemy/os exposes a convenient async exec command that inherits stdio by default, but you can use anything.