-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmain.ts
More file actions
59 lines (53 loc) · 1.49 KB
/
main.ts
File metadata and controls
59 lines (53 loc) · 1.49 KB
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import { App } from "./lib/core/app";
import { HetznerStack } from "./lib/hetzner-stack";
import * as path from "path";
import { DigitalOceanStack } from "./lib/digitalocean-stack";
const app = new App();
const props = {
/*
---
REQUIRED
---
*/
provider: app.mustContext("provider"),
sshKeyPath: app.mustContext(
"sshKeyPath",
path.join(process.env.HOME as string, ".ssh", "id_ecdsa.pub")
),
vpnServerPrivateKey: app.mustContext("vpnServerPrivateKey"),
vpnClientPublicKey: app.mustContext("vpnClientPublicKey"),
/*
---
OPTIONAL
---
*/
sshUser: app.context("sshUser"),
vpnServerAddress: app.context("vpnServerAddress"),
vpnServerPort: app.context("vpnServerPort"),
vpnClientAddress: app.context("vpnClientAddress"),
};
switch (props.provider) {
case "hetzner":
new HetznerStack(app, "VpnStack", {
hcloudToken: app.mustContext("hcloudToken"),
serverImage: app.context("serverImage"),
serverType: app.context("serverType"),
serverLocation: app.context("serverLocation"),
...props,
});
break;
case "digitalocean":
new DigitalOceanStack(app, "VpnStack", {
digitalOceanToken: app.mustContext("digitalOceanToken"),
serverImage: app.context("serverImage"),
serverSize: app.context("serverSize"),
serverRegion: app.context("serverRegion"),
...props,
});
break;
default:
throw new Error(
`Unsupported provider ${props.provider}. Use hetzner or digitalocean`
);
}
app.synth();