-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.tf
57 lines (43 loc) · 1.29 KB
/
main.tf
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
module "container-server" {
source = "../.."
domain = "app.${var.domain}"
email = var.email
container = {
image = "nginxdemos/hello"
}
}
/* Instance ----------------------------------------------------------------- */
resource "digitalocean_droplet" "app" {
name = "app"
image = "docker-18-04"
region = "lon1"
size = "s-1vcpu-1gb"
user_data = module.container-server.cloud_config
}
resource "digitalocean_floating_ip" "app" {
region = digitalocean_droplet.app.region
}
resource "digitalocean_floating_ip_assignment" "app" {
ip_address = digitalocean_floating_ip.app.ip_address
droplet_id = digitalocean_droplet.app.id
}
/* DNS ---------------------------------------------------------------------- */
resource "digitalocean_domain" "default" {
name = "app.${var.domain}"
ip_address = digitalocean_droplet.app.ipv4_address
}
/* Firewall ----------------------------------------------------------------- */
resource "digitalocean_firewall" "app" {
name = "app-ingress"
droplet_ids = [digitalocean_droplet.app.id]
inbound_rule {
protocol = "tcp"
port_range = "80"
source_addresses = ["0.0.0.0/0", "::/0"]
}
inbound_rule {
protocol = "tcp"
port_range = "443"
source_addresses = ["0.0.0.0/0", "::/0"]
}
}