Skip to content

Commit

Permalink
Merge pull request #1 from relaxdiego/changes
Browse files Browse the repository at this point in the history
Multi-Region AMIs and  terraform.tvars example file
  • Loading branch information
Lorenzo Nicora authored Nov 4, 2016
2 parents 3f91235 + 64333b0 commit f47062d
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 6 deletions.
2 changes: 1 addition & 1 deletion terraform/etcf.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down
2 changes: 1 addition & 1 deletion terraform/k8s_controllers.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down
20 changes: 20 additions & 0 deletions terraform/terraform.tfvars.example
Original file line number Diff line number Diff line change
@@ -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" } */
17 changes: 14 additions & 3 deletions terraform/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion terraform/workers.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down

0 comments on commit f47062d

Please sign in to comment.