Last active
June 26, 2018 17:17
-
-
Save briceburg/af16220f60ea5b2e971801277f30a827 to your computer and use it in GitHub Desktop.
terraform - autoscaling group that updates instances on changes
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
## random LC name is assigned | |
resource "aws_launch_configuration" "main" { | |
image_id = "${var.ami}" | |
instance_type = "${var.instance_type}" | |
key_name = "${var.key_name}" | |
security_group = ["${var.security_group}"] | |
} | |
## name triggers ASG replacement. | |
resource "aws_autoscaling_group" "main" { | |
lifecycle { create_before_destroy = true } | |
name = "someapp - ${aws_launch_configuration.main.name}" | |
launch_configuration = "${aws_launch_configuration.main.name}" | |
desired_capacity = "${var.nodes}" | |
min_size = "${var.nodes}" | |
max_size = "${var.nodes}" | |
min_elb_capacity = "${var.nodes}" | |
availability_zones = ["${split(",", var.azs)}"] | |
vpc_zone_identifier = ["${split(",", var.subnet_ids)}"] | |
load_balancers = ["${aws_elb.someapp.id}"] | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment