Skip to content

Commit

Permalink
Add count support qed terraform module
Browse files Browse the repository at this point in the history
  • Loading branch information
suizman authored and iknite committed Feb 19, 2019
1 parent f7d7681 commit 02d6b39
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 25 deletions.
47 changes: 26 additions & 21 deletions deploy/aws/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@ module "follower-1" {
raft: "MYIP:8500"
gossip: "MYIP:8400"
raft_join:
- "${module.leader.private_ip}:8700"
- "${module.leader.private_ip[0]}:8700"
gossip_join:
- "${module.leader.private_ip}:8400"
- "${module.leader.private_ip[0]}:8400"
CONFIG

}
Expand Down Expand Up @@ -97,9 +97,9 @@ module "follower-2" {
raft: "MYIP:8500"
gossip: "MYIP:8400"
raft_join:
- "${module.leader.private_ip}:8700"
- "${module.leader.private_ip[0]}:8700"
gossip_join:
- "${module.leader.private_ip}:8400"
- "${module.leader.private_ip[0]}:8400"
CONFIG
}

Expand Down Expand Up @@ -136,9 +136,9 @@ module "agent-publisher" {
bind: "MYIP:8300"
advertise: ""
join:
- "${module.leader.private_ip}:8400"
- "${module.leader.private_ip[0]}:8400"
server_urls:
- "${module.leader.private_ip}:8800"
- "${module.leader.private_ip[0]}:8800"
alert_urls:
- "${module.inmemory-storage.private_ip}:8888"
snapshots_store_urls:
Expand All @@ -150,6 +150,7 @@ module "agent-monitor" {
source = "./modules/qed"

name = "agent-monitor"
count = 2
instance_type = "t3.small"
volume_size = "20"
vpc_security_group_ids = "${module.security_group.this_security_group_id}"
Expand All @@ -167,9 +168,9 @@ module "agent-monitor" {
bind: "MYIP:8200"
advertise: ""
join:
- "${module.leader.private_ip}:8400"
- "${module.leader.private_ip[0]}:8400"
server_urls:
- "${module.leader.private_ip}:8800"
- "${module.leader.private_ip[0]}:8800"
alert_urls:
- "${module.inmemory-storage.private_ip}:8888"
snapshots_store_urls:
Expand Down Expand Up @@ -198,9 +199,9 @@ module "agent-auditor" {
bind: "MYIP:8100"
advertise: ""
join:
- "${module.leader.private_ip}:8400"
- "${module.leader.private_ip[0]}:8400"
server_urls:
- "${module.leader.private_ip}:8800"
- "${module.leader.private_ip[0]}:8800"
alert_urls:
- "${module.inmemory-storage.private_ip}:8888"
snapshots_store_urls:
Expand Down Expand Up @@ -230,39 +231,43 @@ module "prometheus" {
- job_name: 'Qed0-HostMetrics'
scrape_interval: 10s
static_configs:
- targets: ['${module.leader.private_ip}:9100']
- targets: ['${module.leader.private_ip[0]}:9100']
- job_name: 'Qed0-QedMetrics'
scrape_interval: 10s
static_configs:
- targets: ['${module.leader.private_ip}:8600']
- targets: ['${module.leader.private_ip[0]}:8600']
- job_name: 'Qed1-HostMetrics'
scrape_interval: 10s
static_configs:
- targets: ['${module.follower-1.private_ip}:9100']
- targets: ['${module.follower-1.private_ip[0]}:9100']
- job_name: 'Qed1-QedMetrics'
scrape_interval: 10s
static_configs:
- targets: ['${module.follower-1.private_ip}:8600']
- targets: ['${module.follower-1.private_ip[0]}:8600']
- job_name: 'Qed2-HostMetrics'
scrape_interval: 10s
static_configs:
- targets: ['${module.follower-2.private_ip}:9100']
- targets: ['${module.follower-2.private_ip[0]}:9100']
- job_name: 'Qed2-QedMetrics'
scrape_interval: 10s
static_configs:
- targets: ['${module.follower-2.private_ip}:8600']
- targets: ['${module.follower-2.private_ip[0]}:8600']
- job_name: 'Agent-Publisher-Metrics'
scrape_interval: 10s
static_configs:
- targets: ['${module.agent-publisher.private_ip}:18300']
- job_name: 'Agent-Monitor-Metrics'
- targets: ['${module.agent-publisher.private_ip[0]}:18300']
- job_name: 'Agent-Monitor-0-Metrics'
scrape_interval: 10s
static_configs:
- targets: ['${module.agent-monitor.private_ip}:18200']
- targets: ['${module.agent-monitor.private_ip[0]}:18200']
- job_name: 'Agent-Monitor-1-Metrics'
scrape_interval: 10s
static_configs:
- targets: ['${module.agent-monitor.private_ip[1]}:18200']
- job_name: 'Agent-Auditor-Metrics'
scrape_interval: 10s
static_configs:
- targets: ['${module.agent-auditor.private_ip}:18100']
- targets: ['${module.agent-auditor.private_ip[0]}:18100']
- job_name: 'riot'
scrape_interval: 10s
static_configs:
Expand All @@ -283,7 +288,7 @@ module "riot" {
subnet_id = "${element(data.aws_subnet_ids.all.ids, 0)}"
key_name = "${aws_key_pair.qed.key_name}"
key_path = "${var.keypath}"
endpoint = "${module.leader.private_ip}"
endpoint = "${module.leader.private_ip[0]}"
num_requests = 10000000

}
10 changes: 8 additions & 2 deletions deploy/aws/modules/qed/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,10 @@ data "aws_ami" "amazon_linux" {
}

resource "aws_instance" "qed-server" {
count = "1"
count = "${var.count}"
ami = "${data.aws_ami.amazon_linux.id}"
instance_type = "${var.instance_type}"
iam_instance_profile = "${aws_iam_instance_profile.iam-profile.name}"

vpc_security_group_ids = ["${var.vpc_security_group_ids}"]
subnet_id = "${var.subnet_id}"
Expand All @@ -42,7 +43,7 @@ resource "aws_instance" "qed-server" {
}]

tags {
Name = "${var.name}"
Name = "${format("${var.name}-%01d", count.index)}"
}


Expand All @@ -69,6 +70,11 @@ resource "aws_instance" "qed-server" {
user_data = <<-DATA
#!/bin/bash
echo "Install and enable AWS CloudWatch"
aws configure set region eu-west-1
sudo yum install -y awslogs
sudo service awslogs start
while [ ! -f ${var.path}/qed ]; do
sleep 1 # INFO: wait until binary exists
done
Expand Down
4 changes: 2 additions & 2 deletions deploy/aws/modules/qed/outputs.tf
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
output "private_ip" {
value = "${aws_instance.qed-server.private_ip}"
value = "${aws_instance.qed-server.*.private_ip}"
}

output "public_ip" {
value = "${aws_instance.qed-server.public_ip}"
value = "${aws_instance.qed-server.*.public_ip}"
}

4 changes: 4 additions & 0 deletions deploy/aws/modules/qed/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ variable "path" {
default = "/var/tmp/qed"
}

variable "count" {
default = 1
}

variable "command" {
default = "start"
}
Expand Down

0 comments on commit 02d6b39

Please sign in to comment.