diff --git a/bootstrap/aws-public/config-default.sh b/bootstrap/aws-public/config-default.sh index c3fb4d2c..644d5732 100644 --- a/bootstrap/aws-public/config-default.sh +++ b/bootstrap/aws-public/config-default.sh @@ -18,12 +18,12 @@ export ANSIBLE_SSH_ARGS="-F ${APOLLO_ROOT}/terraform/${APOLLO_PROVIDER}/ssh.conf # so no really needed to export them. Exporting for consitency. export TF_VAR_atlas_artifact_master=${TF_VAR_atlas_artifact_master:-capgemini/apollo-ubuntu-14.04-amd64} export TF_VAR_atlas_artifact_slave=${TF_VAR_atlas_artifact_slave:-capgemini/apollo-ubuntu-14.04-amd64} -export TF_VAR_atlas_artifact_version_master=${TF_VAR_atlas_artifact_version_master:-6} -export TF_VAR_atlas_artifact_version_slave=${TF_VAR_atlas_artifact_version_slave:-6} +export TF_VAR_atlas_artifact_version_master=${TF_VAR_atlas_artifact_version_master:-8} +export TF_VAR_atlas_artifact_version_slave=${TF_VAR_atlas_artifact_version_slave:-8} export TF_VAR_region=${TF_VAR_region:-eu-west-1} -export TF_VAR_master_size=${TF_VAR_master_size:-m1.medium} -export TF_VAR_slave_size=${TF_VAR_slave_size:-m1.medium} +export TF_VAR_master_size=${TF_VAR_master_size:-m3.medium} +export TF_VAR_slave_size=${TF_VAR_slave_size:-m3.medium} export TF_VAR_slaves=${TF_VAR_slaves:-1} export TF_VAR_availability_zones=${TF_VAR_availability_zones:-'eu-west-1a,eu-west-1b,eu-west-1c'} diff --git a/terraform/aws-public/mesos-masters.tf b/terraform/aws-public/mesos-masters.tf index 899f97f7..f938f726 100644 --- a/terraform/aws-public/mesos-masters.tf +++ b/terraform/aws-public/mesos-masters.tf @@ -12,8 +12,16 @@ resource "atlas_artifact" "mesos-master" { /* Mesos master instances */ resource "aws_instance" "mesos-master" { + /* + We had to hardcode the amis list in variables.tf file creating amis map because terraform doesn't + support interpolation in the way which could allow us to replaced the region dinamically. + We need to remember to update the map every time when we build a new artifact on atlas. + Similar issue related to metada_full is mentioned here: + https://github.com/hashicorp/terraform/issues/732 + */ + instance_type = "${var.instance_type.master}" - ami = "${replace(atlas_artifact.mesos-master.id, concat(var.region, ":"), "")}" + ami = "${lookup(var.amis, var.region)}" count = "${var.masters}" key_name = "${aws_key_pair.deployer.key_name}" subnet_id = "${element(aws_subnet.public.*.id, count.index)}" diff --git a/terraform/aws-public/mesos-slaves.tf b/terraform/aws-public/mesos-slaves.tf index bf6c1039..d7221626 100644 --- a/terraform/aws-public/mesos-slaves.tf +++ b/terraform/aws-public/mesos-slaves.tf @@ -7,8 +7,16 @@ resource "atlas_artifact" "mesos-slave" { /* Mesos slave instances */ resource "aws_instance" "mesos-slave" { + /* + We had to hardcode the amis list in variables.tf file creating amis map because terraform doesn't + support interpolation in the way which could allow us to replaced the region dinamically. + We need to remember to update the map every time when we build a new artifact on atlas. + Similar issue related to metada_full is mentioned here: + https://github.com/hashicorp/terraform/issues/732 + */ + instance_type = "${var.instance_type.slave}" - ami = "${replace(atlas_artifact.mesos-master.id, concat(var.region, ":"), "")}" + ami = "${lookup(var.amis, var.region)}" count = "${var.slaves}" key_name = "${aws_key_pair.deployer.key_name}" subnet_id = "${element(aws_subnet.public.*.id, count.index)}" diff --git a/terraform/aws-public/variables.tf b/terraform/aws-public/variables.tf index 9a5dce93..ed960073 100644 --- a/terraform/aws-public/variables.tf +++ b/terraform/aws-public/variables.tf @@ -62,8 +62,8 @@ variable "slave_block_device" { variable "instance_type" { default = { - master = "m1.medium" - slave = "m1.medium" + master = "m3.medium" + slave = "m3.medium" } } @@ -76,7 +76,22 @@ variable "atlas_artifact" { variable "atlas_artifact_version" { default = { - master = "6" - slave = "6" + master = "8" + slave = "8" + } +} + +/* Remember to update the list every time when you build a new artifact on atlas */ +variable "amis" { + default = { + ap-northeast-1 = "ami-249e2e24" + ap-southeast-1 = "ami-f20b06a0" + ap-southeast-2 = "ami-7d793847" + eu-central-1 = "ami-f6888deb" + eu-west-1 = "ami-8c6431fb" + sa-east-1 = "ami-158b0508" + us-east-1 = "ami-2f36ee44" + us-west-1 = "ami-1d6d9059" + us-west-2 = "ami-af323d9f" } } diff --git a/terraform/aws/mesos-masters.tf b/terraform/aws/mesos-masters.tf index e571bb7d..f9061fe9 100644 --- a/terraform/aws/mesos-masters.tf +++ b/terraform/aws/mesos-masters.tf @@ -7,8 +7,16 @@ resource "atlas_artifact" "mesos-master" { /* Mesos master instances */ resource "aws_instance" "mesos-master" { + /* + We had to hardcode the amis list in variables.tf file creating amis map because terraform doesn't + support interpolation in the way which could allow us to replaced the region dinamically. + We need to remember to update the map every time when we build a new artifact on atlas. + Similar issue related to metada_full is mentioned here: + https://github.com/hashicorp/terraform/issues/732 + */ + instance_type = "${var.instance_type.master}" - ami = "${replace(atlas_artifact.mesos-master.id, concat(var.region, ":"), "")}" + ami = "${lookup(var.amis, var.region)}" count = "${var.masters}" key_name = "${aws_key_pair.deployer.key_name}" source_dest_check = false diff --git a/terraform/aws/mesos-slaves.tf b/terraform/aws/mesos-slaves.tf index 463b226a..3fd9c0a5 100644 --- a/terraform/aws/mesos-slaves.tf +++ b/terraform/aws/mesos-slaves.tf @@ -7,8 +7,16 @@ resource "atlas_artifact" "mesos-slave" { /* Mesos slave instances */ resource "aws_instance" "mesos-slave" { + /* + We had to hardcode the amis list in variables.tf file creating amis map because terraform doesn't + support interpolation in the way which could allow us to replaced the region dinamically. + We need to remember to update the map every time when we build a new artifact on atlas. + Similar issue related to metada_full is mentioned here: + https://github.com/hashicorp/terraform/issues/732 + */ + instance_type = "${var.instance_type.slave}" - ami = "${replace(atlas_artifact.mesos-slave.id, concat(var.region, ":"), "")}" + ami = "${lookup(var.amis, var.region)}" count = "${var.slaves}" key_name = "${aws_key_pair.deployer.key_name}" source_dest_check = false @@ -54,4 +62,4 @@ resource "aws_elb" "app" { resource "aws_proxy_protocol_policy" "http" { load_balancer = "${aws_elb.app.name}" instance_ports = ["80"] -} \ No newline at end of file +} diff --git a/terraform/aws/variables.tf b/terraform/aws/variables.tf index f606a34f..686c400e 100644 --- a/terraform/aws/variables.tf +++ b/terraform/aws/variables.tf @@ -72,8 +72,8 @@ variable "slave_block_device" { variable "instance_type" { default = { - master = "m1.medium" - slave = "m1.medium" + master = "m3.medium" + slave = "m3.medium" } } @@ -86,16 +86,23 @@ variable "atlas_artifact" { variable "atlas_artifact_version" { default = { - master = "6" - slave = "6" + master = "8" + slave = "8" } } -/* Base Ubuntu 14.04 amis by region */ +/* Remember to update the list every time when you build a new artifact on atlas */ variable "amis" { - description = "Base AMI to launch the instances with" default = { - eu-west-1 = "ami-234ecc54" + ap-northeast-1 = "ami-249e2e24" + ap-southeast-1 = "ami-f20b06a0" + ap-southeast-2 = "ami-7d793847" + eu-central-1 = "ami-f6888deb" + eu-west-1 = "ami-8c6431fb" + sa-east-1 = "ami-158b0508" + us-east-1 = "ami-2f36ee44" + us-west-1 = "ami-1d6d9059" + us-west-2 = "ami-af323d9f" } }