diff --git a/terraform/etcf.tf b/terraform/etcf.tf index e5a6a5e..1d25308 100644 --- a/terraform/etcf.tf +++ b/terraform/etcf.tf @@ -4,7 +4,7 @@ resource "aws_instance" "etcd" { count = 3 - ami = "${var.default_ami}" + ami = "${lookup(var.amis, var.region)}" instance_type = "${var.etcd_instance_type}" subnet_id = "${aws_subnet.kubernetes.id}" diff --git a/terraform/k8s_controllers.tf b/terraform/k8s_controllers.tf index b86482d..dab7137 100644 --- a/terraform/k8s_controllers.tf +++ b/terraform/k8s_controllers.tf @@ -5,7 +5,7 @@ resource "aws_instance" "controller" { count = 3 - ami = "${var.default_ami}" + ami = "${lookup(var.amis, var.region)}" instance_type = "${var.controller_instance_type}" iam_instance_profile = "${aws_iam_instance_profile.kubernetes.id}" diff --git a/terraform/terraform.tfvars.example b/terraform/terraform.tfvars.example new file mode 100644 index 0000000..d6547f0 --- /dev/null +++ b/terraform/terraform.tfvars.example @@ -0,0 +1,20 @@ +/* + DO NOT EDIT terraform.tfvars.example! Copy it instead to + terraform.tfvars and edit that file. +*/ + +/* Required variables */ +default_keypair_public_key = "CONTENTS OF YOUR PUBLIC KEY HERE" +control_cidr = "CIDR OF MACHINE RUNNING TERRAFORM HERE" + +/* Optional. Set as desired */ +/* region = "us-west-2" */ +/* zone = "us-west-2a" */ + +/* + If your chosen region above doesn't have a corresponding ami + in the "amis" variable (found in variables.tf), you can + override the default below. +*/ + +/* amis = { us-west-2 = "ami-123456" } */ diff --git a/terraform/variables.tf b/terraform/variables.tf index 119123b..e36f414 100644 --- a/terraform/variables.tf +++ b/terraform/variables.tf @@ -52,9 +52,20 @@ variable kubernetes_pod_cidr { # Instances Setup -variable default_ami { - description = "Default AMI for all nodes" - default = "ami-1967056a" // Unbuntu 16.04 LTS HVM, EBS-SSD +variable amis { + description = "Default AMIs to use for nodes depending on the region" + type = "map" + default = { + ap-northeast-1 = "ami-0567c164" + ap-southeast-1 = "ami-a1288ec2" + cn-north-1 = "ami-d9f226b4" + eu-central-1 = "ami-8504fdea" + eu-west-1 = "ami-0d77397e" + sa-east-1 = "ami-e93da085" + us-east-1 = "ami-40d28157" + us-west-1 = "ami-6e165d0e" + us-west-2 = "ami-a9d276c9" + } } variable default_instance_user { default = "ubuntu" diff --git a/terraform/workers.tf b/terraform/workers.tf index a579473..045bb0f 100644 --- a/terraform/workers.tf +++ b/terraform/workers.tf @@ -5,7 +5,7 @@ resource "aws_instance" "worker" { count = 3 - ami = "${var.default_ami}" + ami = "${lookup(var.amis, var.region)}" instance_type = "${var.worker_instance_type}" subnet_id = "${aws_subnet.kubernetes.id}"