resource "aws_launch_configuration" "fundapp_demo" { name_prefix = "${var.vpc_name}_app" image_id = "${var.image_id}" instance_type = "t2.nano" iam_instance_profile = "${aws_iam_instance_profile.app_profile.id}" key_name = "${aws_key_pair.server_keypair.key_name}" security_groups = [ "${aws_security_group.app_sg.id}", "${aws_security_group.external_ssh_accept_sg.id}", ] user_date = "${data.template_file.app_user_data.rendered}" root_block_device { volume_type = "gp2" volume_size = "30" } lifecycle { create_before_destroy = true } } resource "aws_autoscaling_group" "app_asg" { name = "${var.vpc_name}_app_asg" launch_configuration = "${aws_launch_configuration.fundapp_demo.name}" availability_zones = [ "${var.aws_az_1}", "${var.aws_az_2}", "${var.aws_az_3}", ] vpc_zone_identifier = [ "${aws_subnet.public_1.id}", "${aws_subnet.public_2.id}", "${aws_subnet.public_3.id}", ] min_size = 1 max_size = 3 desired_capacity = 2 health_check_grace_period = 300 enabled_metrics = [ "GroupMinSize", "GroupMazSize", "GroupDesiredCapacity", "GroupInServiceInstances", "GroupPendingInstances", "GroupStandbyInstances", "GroupTerminatingInstances", "GroupTotalInstances", ] load_balancers = ["${aws_elb.app_elb.name}"] health_check_type = "EC2" lifecycle { create_before_destroy = true } } data "template_file" "app_user_data" { template = "${file("${path.module}/files/app_data.tpl")}" }