This repository has been archived by the owner on May 14, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathstellar-core.tf.j2
73 lines (56 loc) · 1.96 KB
/
stellar-core.tf.j2
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
71
72
73
{%for node in stellar.nodes%}
{%set module_name_suffix = '{}_{}'.format(stellar.network_name, node.zone)%}
{%set stellar_core_module = 'stellar_core_{}'.format(module_name_suffix)%}
{%if node.horizon%}
{%set horizon_module = 'horizon_{}'.format(module_name_suffix)%}
{%endif%}
module "{{stellar_core_module}}" {
source = "modules/stellar-core"
providers = {
"aws" = "aws.{{node.region}}"
}
name = "${local.{{stellar_core_module}}_name}"
instance_key_pair_name = "${aws_key_pair.{{node.region}}.key_name}"
ssh_private_key = "{{stellar.ssh.private_key}}"
stellar_network_name = "{{stellar.network_name}}"
tld = "{{stellar.tld}}"
zone = "{{node.zone}}"
instance_type = "{{node.instance_type}}"
rds_password = "{{node.rds.password}}"
rds_instance_class = "{{node.rds.instance_class}}"
{%if node.horizon%}
# walk around "value of 'count' cannot be computed" bug
# https://github.com/hashicorp/terraform/issues/12570
horizon_security_group_id = "${module.{{horizon_module}}.ec2_security_group_id[0]}"
horizon_security_group_id_count = "1"
{%else%}
horizon_security_group_id = ""
horizon_security_group_id_count = "0"
{%endif%}
}
output "ec2_{{stellar_core_module}}" {
description = "EC2 public DNS name"
value = "${module.{{stellar_core_module}}.ec2}"
}
output "s3_bucket_{{stellar_core_module}}" {
description = "S3 bucket name"
value = "${module.{{stellar_core_module}}.s3}"
}
output "rds_{{stellar_core_module}}" {
description = "RDS address"
value = "${module.{{stellar_core_module}}.rds}"
}
locals {
# used to name ec2 and rds instances, security groups, etc.
{{stellar_core_module}}_name = "stellar-core-{{stellar.network_name}}-${random_id.{{stellar_core_module}}_name_suffix.hex}"
}
resource "random_id" "{{stellar_core_module}}_name_suffix" {
byte_length = 2
lifecycle {
create_before_destroy = true
}
}
{%endfor%}
{#
# vi: ft=terraform.jinja2
#}