-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.tf
70 lines (56 loc) · 1.72 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
58
59
60
61
62
63
64
65
66
67
68
69
70
#
# Terraform/Providers
#
terraform {
required_version = ">= 0.11.0"
}
provider "triton" {
version = ">= 0.4.1"
}
#
# Data sources
#
data "triton_datacenter" "current" {}
data "triton_account" "current" {}
#
# Locals
#
locals {
redash_address = "${var.cns_service_name_redash}.svc.${data.triton_account.current.id}.${data.triton_datacenter.current.name}.${var.cns_fqdn_base}"
}
#
# Machines
#
resource "triton_machine" "redash" {
name = "${var.name}-redash"
package = "${var.package}"
image = "${var.image}"
firewall_enabled = true
networks = ["${var.networks}"]
cns {
services = ["${var.cns_service_name_redash}"]
}
metadata {
version_redash = "${var.version_redash}"
}
}
#
# Firewall Rules
#
resource "triton_firewall_rule" "ssh" {
rule = "FROM tag \"triton.cns.services\" = \"${var.bastion_cns_service_name}\" TO tag \"triton.cns.services\" = \"${var.cns_service_name_redash}\" ALLOW tcp PORT 22"
enabled = true
description = "${var.name} - Allow access from bastion hosts to Redash servers."
}
resource "triton_firewall_rule" "client_access" {
count = "${length(var.client_access)}"
rule = "FROM ${var.client_access[count.index]} TO tag \"triton.cns.services\" = \"${var.cns_service_name_redash}\" ALLOW tcp PORT 80"
enabled = true
description = "${var.name} - Allow access from clients to Redash servers."
}
resource "triton_firewall_rule" "redash_to_presto_coordinator" {
count = "${length(var.client_access)}"
rule = "FROM ${var.client_access[count.index]} TO tag \"triton.cns.services\" = \"${var.cns_service_name_presto_coordinator}\" ALLOW tcp PORT 8080"
enabled = true
description = "${var.name} - Allow access from Redash to Presto servers."
}