Last active
December 12, 2016 23:41
-
-
Save katesclau/e77b31a0a12e2b03a116469dda593387 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Auto Scaling Pool | |
resource "aws_autoscaling_group" "asg" { | |
name = "${var.cluster_name}-asg" | |
availability_zones = ["${var.availability_zone}"] | |
min_size = "${var.cluster_min_size}" | |
max_size = "${var.cluster_max_size}" | |
desired_capacity = "${var.cluster_size}" | |
load_balancers = ["${var.load_balancer}"] | |
# here we link the launch configuration below | |
launch_configuration = "${aws_launch_configuration.asg_pool.name}" | |
} | |
# Instances Launch Configuration | |
resource "aws_launch_configuration" "asg_pool" { | |
# use system generated name to allow changes of launch_configuration | |
name_prefix = "${var.cluster_name}-asg-" | |
# From our base instance configuration | |
image_id = "${var.ami}" | |
instance_type = "${var.instance_type}" | |
key_name = "${var.key_pair_name}" | |
lifecycle { create_before_destroy = true } | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
variable "region" {} | |
variable "availability_zone" { } | |
variable "cluster_name" {} | |
variable "load_balancer" {} | |
variable "ami" {} | |
variable "instance_type" { default = "t2.micro" } | |
variable "key_pair_name" {} | |
variable "cluster_min_size" { default = 1 } | |
variable "cluster_max_size" { default = 4 } | |
variable "cluster_size" { default = 2 } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#.... | |
module "cluster" { | |
source = "./ec2" | |
region = "${var.region}" | |
availability_zone = "${var.availability_zone}" | |
cluster_name = "${var.cluster_name}" | |
ami = "${var.ami}" | |
instance_type = "${var.instance_type}" | |
# From keys module | |
key_pair_name = "${module.keys.key_name}" | |
# From load balancer module | |
load_balancer = "${module.load_balancer.elb_name}" | |
} | |
#.... | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#.... | |
# ASG Pool and Launch Configuration========================= | |
variable "ami" { default = "ami-a9d276c9" } # Ubuntu Server 16.04 LTS (HVM) | |
variable "instance_type" { default = "t2.micro" } # Free tier | |
variable "availability_zone" { default = "us-west-2a" } | |
#.... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment