Skip to content

Commit

Permalink
Use Amazon Linux 2 AMIs (systemd-based)
Browse files Browse the repository at this point in the history
Note that the awslogs service is now called `awslogsd`, with a trailing d.
Many thanks to @jllucas and @suizmain for pointing this out to me.
  • Loading branch information
panchoh committed Feb 22, 2019
1 parent ba86c97 commit 6d23a86
Show file tree
Hide file tree
Showing 6 changed files with 75 additions and 86 deletions.
15 changes: 8 additions & 7 deletions deploy/aws/modules/inmemory_storage/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,21 @@ data "aws_ami" "amazon_linux" {
most_recent = true

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

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

resource "aws_instance" "inmemory-storage" {
count = "1"
ami = "${data.aws_ami.amazon_linux.id}"
instance_type = "${var.instance_type}"
iam_instance_profile = "${var.iam_instance_profile}"
count = "1"
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}"
Expand Down
14 changes: 7 additions & 7 deletions deploy/aws/modules/prometheus/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,21 @@ data "aws_ami" "amazon_linux" {
most_recent = true

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

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

resource "aws_instance" "prometheus" {
count = "1"
ami = "${data.aws_ami.amazon_linux.id}"
instance_type = "${var.instance_type}"
iam_instance_profile = "${var.iam_instance_profile}"
count = "1"
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}"
Expand Down
14 changes: 7 additions & 7 deletions deploy/aws/modules/qed/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,21 @@ data "aws_ami" "amazon_linux" {
most_recent = true

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

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

resource "aws_instance" "qed-server" {
count = "${var.count}"
ami = "${data.aws_ami.amazon_linux.id}"
instance_type = "${var.instance_type}"
iam_instance_profile = "${var.iam_instance_profile}"
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}"
Expand Down
15 changes: 8 additions & 7 deletions deploy/aws/modules/riot/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,21 @@ data "aws_ami" "amazon_linux" {
most_recent = true

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

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

resource "aws_instance" "riot" {
count = "1"
ami = "${data.aws_ami.amazon_linux.id}"
instance_type = "${var.instance_type}"
iam_instance_profile = "${var.iam_instance_profile}"
count = "1"
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}"
Expand Down
2 changes: 1 addition & 1 deletion deploy/aws/provision/tasks/common/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@

- name: Restart AWS CloudWatch service
service:
name: awslogs
name: awslogsd
state: restarted
when: aws_logs.changed

Expand Down
101 changes: 44 additions & 57 deletions tests/cloud/aws/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/

provider "aws" {
region = "${var.region}"
region = "${var.region}"
profile = "${var.profile}"
}

Expand All @@ -39,7 +39,7 @@ data "aws_ami" "amazon_linux" {
name = "name"

values = [
"amzn-ami-hvm-*-x86_64-gp2",
"amzn2-ami-hvm-*-x86_64-gp2",
]
}

Expand All @@ -64,26 +64,26 @@ module "security_group" {
vpc_id = "${data.aws_vpc.default.id}"

ingress_cidr_blocks = ["${chomp(data.http.ip.body)}/32"]
ingress_rules = ["http-8800-tcp", "all-icmp", "ssh-tcp" ]
ingress_rules = ["http-8800-tcp", "all-icmp", "ssh-tcp"]
egress_rules = ["all-all"]
}

resource "aws_security_group_rule" "allow_profiling" {
type = "ingress"
from_port = 6060
to_port = 6060
protocol = "tcp"
cidr_blocks = ["${chomp(data.http.ip.body)}/32"]
type = "ingress"
from_port = 6060
to_port = 6060
protocol = "tcp"
cidr_blocks = ["${chomp(data.http.ip.body)}/32"]

security_group_id = "${module.security_group.this_security_group_id}"
}

resource "aws_security_group_rule" "allow_cluster_comm" {
type = "ingress"
from_port = 0
to_port = 65535
protocol = "tcp"
source_security_group_id = "${module.security_group.this_security_group_id}"
type = "ingress"
from_port = 0
to_port = 65535
protocol = "tcp"
source_security_group_id = "${module.security_group.this_security_group_id}"

security_group_id = "${module.security_group.this_security_group_id}"
}
Expand All @@ -101,11 +101,10 @@ module "ec2" {
key_name = "${aws_key_pair.qed-benchmark.key_name}"

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

}

// Bring up the stress instance.
Expand All @@ -121,11 +120,10 @@ module "ec2-spartan" {
key_name = "${aws_key_pair.qed-benchmark.key_name}"

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

}

// Build qed and outputs a single binary file
Expand All @@ -135,49 +133,48 @@ resource "null_resource" "build-qed" {
}

depends_on = ["module.ec2"]

}

# Template for initial configuration bash script
resource "template_dir" "gen-single-node-config" {
count = "${var.cluster_size == 1 ? 1:0}"
resource "template_dir" "gen-single-node-config" {
count = "${var.cluster_size == 1 ? 1:0}"

source_dir = "templates"
destination_dir = "to_upload/rendered"
source_dir = "templates"
destination_dir = "to_upload/rendered"

vars {
master_address = "${module.ec2.private_ip[0]}"
slave01_address = ""
slave02_address = ""
}
vars {
master_address = "${module.ec2.private_ip[0]}"
slave01_address = ""
slave02_address = ""
}

depends_on = ["module.ec2", "null_resource.build-qed"]
}
depends_on = ["module.ec2", "null_resource.build-qed"]
}

# Template for initial configuration bash script
resource "template_dir" "gen-multi-node-config" {
count = "${var.cluster_size > 1 ? 1:0}"
resource "template_dir" "gen-multi-node-config" {
count = "${var.cluster_size > 1 ? 1:0}"

source_dir = "templates"
destination_dir = "to_upload/rendered"
source_dir = "templates"
destination_dir = "to_upload/rendered"

vars {
master_address = "${module.ec2.private_ip[0]}"
slave01_address = "${module.ec2.private_ip[1]}"
slave02_address = "${module.ec2.private_ip[2]}"
}
vars {
master_address = "${module.ec2.private_ip[0]}"
slave01_address = "${module.ec2.private_ip[1]}"
slave02_address = "${module.ec2.private_ip[2]}"
}

depends_on = ["module.ec2", "null_resource.build-qed"]
}
depends_on = ["module.ec2", "null_resource.build-qed"]
}

// Copies qed binary and bench tools to out EC2 instance using SSH
resource "null_resource" "copy-qed-to-nodes" {
count = "${var.cluster_size}"
count = "${var.cluster_size}"

provisioner "file" {
source = "to_upload"
destination = "/tmp"

connection {
host = "${element(module.ec2.public_ip, count.index)}"
type = "ssh"
Expand All @@ -188,16 +185,14 @@ resource "null_resource" "copy-qed-to-nodes" {
}

depends_on = ["null_resource.build-qed", "module.ec2", "template_dir.gen-single-node-config", "template_dir.gen-multi-node-config"]

}

// Copies qed binary and bench tools to out EC2 instance using SSH
resource "null_resource" "copy-qed-to-spartan" {

provisioner "file" {
source = "to_upload"
destination = "/tmp"

connection {
host = "${module.ec2-spartan.public_ip[0]}"
type = "ssh"
Expand All @@ -208,7 +203,6 @@ resource "null_resource" "copy-qed-to-spartan" {
}

depends_on = ["null_resource.build-qed", "module.ec2", "template_dir.gen-single-node-config", "template_dir.gen-multi-node-config"]

}

resource "null_resource" "install-tools-to-spartan" {
Expand All @@ -217,23 +211,20 @@ resource "null_resource" "install-tools-to-spartan" {
"chmod +x /tmp/to_upload/install-tools /tmp/to_upload/rendered/stress-throughput-60s /tmp/to_upload/qed",
"/tmp/to_upload/install-tools",
]

connection {
host = "${module.ec2-spartan.public_ip}"
type = "ssh"
private_key = "${file("~/.ssh/id_rsa")}"
user = "ec2-user"
timeout = "5m"
}

}

depends_on = ["null_resource.copy-qed-to-spartan"]

}

resource "null_resource" "start-master" {

provisioner "remote-exec" {
inline = [
"find /tmp/to_upload -type f -exec chmod a+x {} \\;",
Expand All @@ -250,11 +241,9 @@ resource "null_resource" "start-master" {
}

depends_on = ["null_resource.copy-qed-to-nodes"]

}

resource "null_resource" "start-slave" {

count = "${var.cluster_size > 1 ? var.cluster_size - 1 : 0}"

provisioner "remote-exec" {
Expand All @@ -273,7 +262,6 @@ resource "null_resource" "start-slave" {
}

depends_on = ["null_resource.start-master"]

}

resource "null_resource" "run-benchmarks" {
Expand All @@ -291,6 +279,5 @@ resource "null_resource" "run-benchmarks" {
}
}

depends_on = ["null_resource.install-tools-to-spartan", "null_resource.start-master", "null_resource.start-slave"]

depends_on = ["null_resource.install-tools-to-spartan", "null_resource.start-master", "null_resource.start-slave"]
}

0 comments on commit 6d23a86

Please sign in to comment.