forked from nubisproject/nubis-dpaste
-
Notifications
You must be signed in to change notification settings - Fork 0
/
consul.tf
49 lines (43 loc) · 1.27 KB
/
consul.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
# Discover Consul settings
module "consul" {
source = "github.com/nubisproject/nubis-terraform//consul?ref=master"
region = "${var.region}"
environment = "${var.environment}"
account = "${var.account}"
service_name = "${var.service_name}"
}
# Configure our Consul provider, module can't do it for us
provider "consul" {
address = "${module.consul.address}"
scheme = "${module.consul.scheme}"
datacenter = "${module.consul.datacenter}"
}
# Publish our outputs into Consul for our application to consume
resource "consul_keys" "config" {
# This one, the application generates, we only read it
key {
name = "app_secret_key"
path = "${module.consul.config_prefix}/APP_SECRET_KEY"
}
# The rest, we publish to
key {
name = "db_name"
path = "${module.consul.config_prefix}/DB_NAME"
value = "${module.database.name}"
}
key {
name = "db_server"
path = "${module.consul.config_prefix}/DB_SERVER"
value = "${module.database.address}"
}
key {
name = "db_username"
path = "${module.consul.config_prefix}/DB_USERNAME"
value = "${module.database.username}"
}
key {
name = "db_password"
path = "${module.consul.config_prefix}/DB_PASSWORD"
value = "${module.database.password}"
}
}