Skip to content

Commit

Permalink
AWS deploy: split qed terraform module in two (qed, agent)
Browse files Browse the repository at this point in the history
This is to prepare the qed module to configure an EBS volume.
  • Loading branch information
panchoh committed Feb 28, 2019
1 parent 93f58ad commit 79f1d25
Show file tree
Hide file tree
Showing 5 changed files with 107 additions and 4 deletions.
6 changes: 3 additions & 3 deletions deploy/aws/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ module "inmemory-storage" {
}

module "agent-publisher" {
source = "./modules/qed"
source = "./modules/agent"

name = "agent-publisher"
instance_type = "t3.small"
Expand All @@ -80,7 +80,7 @@ module "agent-publisher" {
}

module "agent-monitor" {
source = "./modules/qed"
source = "./modules/agent"

name = "agent-monitor"
count = 1
Expand All @@ -95,7 +95,7 @@ module "agent-monitor" {
}

module "agent-auditor" {
source = "./modules/qed"
source = "./modules/agent"

name = "agent-auditor"
instance_type = "t3.small"
Expand Down
49 changes: 49 additions & 0 deletions deploy/aws/modules/agent/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Copyright 2018 Banco Bilbao Vizcaya Argentaria, S.A.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

data "aws_ami" "amazon_linux" {
most_recent = true

filter {
name = "name"
values = ["amzn2-ami-hvm-*-x86_64-gp2"]
}

filter {
name = "owner-alias"
values = ["amazon"]
}
}

resource "aws_instance" "qed-agent" {
count = "${var.count}"
ami = "${data.aws_ami.amazon_linux.id}"
instance_type = "${var.instance_type}"
iam_instance_profile = "${var.iam_instance_profile}"

vpc_security_group_ids = ["${var.vpc_security_group_ids}"]
subnet_id = "${var.subnet_id}"
associate_public_ip_address = true
key_name = "${var.key_name}"

root_block_device = [{
volume_type = "gp2"
volume_size = "${var.volume_size}"
}]

tags {
Name = "${format("${var.name}-%01d", count.index)}"
Role = "${var.role}"
}
}
7 changes: 7 additions & 0 deletions deploy/aws/modules/agent/outputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
output "private_ip" {
value = "${aws_instance.qed-agent.*.private_ip}"
}

output "public_ip" {
value = "${aws_instance.qed-agent.*.public_ip}"
}
47 changes: 47 additions & 0 deletions deploy/aws/modules/agent/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
Copyright 2018 Banco Bilbao Vizcaya Argentaria, S.A.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

variable "instance_type" {}

variable "iam_instance_profile" {}

variable "volume_size" {}

variable "vpc_security_group_ids" {}

variable "subnet_id" {}

variable "key_name" {}

variable "key_path" {}

variable "name" {}

variable "role" {
default = "agent"
}

variable "path" {
default = "/var/tmp/qed"
}

variable "count" {
default = 1
}

variable "command" {
default = "start"
}
2 changes: 1 addition & 1 deletion deploy/aws/provision/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
- include: tasks/common/main.yml


- hosts: qed-server
- hosts: qed-server:qed-agent
remote_user: ec2-user
become: true
vars_files:
Expand Down

0 comments on commit 79f1d25

Please sign in to comment.