forked from pulumi/examples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
__main__.py
43 lines (37 loc) · 1004 Bytes
/
__main__.py
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
import pulumi_digitalocean as do
from pulumi import export, get_stack
droplet_count = 3
region = "nyc3"
user_data = """#!/bin/bash
sudo apt-get update
sudo apt-get install -y nginx
"""
droplet_type = "demo-app-%s" %get_stack()
droplet_type_tag = do.Tag(droplet_type)
for x in range(0, droplet_count):
instance_name = "web-%s" %x
name_tag = do.Tag(instance_name)
droplet = do.Droplet(
instance_name,
image="ubuntu-18-04-x64",
region=region,
size="512mb",
tags=[name_tag.id, droplet_type_tag.id],
user_data=user_data
)
loadbalancer = do.LoadBalancer(
"public",
droplet_tag=droplet_type_tag.name,
forwarding_rules=[do.LoadBalancerForwardingRuleArgs(
entry_port=80,
entry_protocol="http",
target_port=80,
target_protocol="http",
)],
healthcheck=do.LoadBalancerHealthcheckArgs(
port=80,
protocol="tcp",
),
region=region,
)
export("endpoint", loadbalancer.ip)