forked from pulumi/examples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.ts
42 lines (37 loc) · 1.2 KB
/
index.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
// Copyright 2016-2019, Pulumi Corporation. All rights reserved.
import * as digitalocean from "@pulumi/digitalocean";
import * as pulumi from "@pulumi/pulumi";
const dropletCount = 3;
const region = digitalocean.Regions.NYC3;
const dropletTypeTag = new digitalocean.Tag(`demo-app-${pulumi.getStack()}`);
const userData =
`#!/bin/bash
sudo apt-get update
sudo apt-get install -y nginx`;
const droplets = [];
for (let i = 0; i < dropletCount; i++) {
const nameTag = new digitalocean.Tag(`web-${i}`);
droplets.push(new digitalocean.Droplet(`web-${i}`, {
image: "ubuntu-18-04-x64",
region: region,
privateNetworking: true,
size: digitalocean.DropletSlugs.Droplet512mb,
tags: [nameTag.id, dropletTypeTag.id],
userData: userData,
}));
}
const lb = new digitalocean.LoadBalancer("public", {
dropletTag: dropletTypeTag.name,
forwardingRules: [{
entryPort: 80,
entryProtocol: digitalocean.Protocols.HTTP,
targetPort: 80,
targetProtocol: digitalocean.Protocols.HTTP,
}],
healthcheck: {
port: 80,
protocol: digitalocean.Protocols.TCP,
},
region: region,
});
export const endpoint = lb.ip;