-
Notifications
You must be signed in to change notification settings - Fork 56
/
automation.ts
42 lines (31 loc) · 1.02 KB
/
automation.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import {
LocalProgramArgs,
LocalWorkspace,
OutputMap
} from "@pulumi/pulumi/automation";
import * as upath from "upath";
const args: LocalProgramArgs = {
stackName: "dev",
workDir: upath.joinSafe(__dirname, ".", "infrastructure"),
};
export async function deploy(): Promise<OutputMap> {
console.log("Initialising stack...");
const stack = await LocalWorkspace.createOrSelectStack(args);
console.log("Setting region...");
await stack.setConfig("aws:region", {value: "us-west-1"});
console.log("Run update...");
const up = await stack.up({ onOutput: console.log });
return up.outputs;
}
export async function destroy() {
console.log("Selecting stack...");
const stack = await LocalWorkspace.createOrSelectStack(args);
console.log("Destroying stack");
await stack.destroy({onOutput: console.log});
}
export async function getOuputs(): Promise<OutputMap> {
const stack = await LocalWorkspace.createOrSelectStack(args);
var outputs = stack.outputs();
return outputs;
}
export default {deploy, getOuputs};