diff options
author | Spike <avlampson+git@gmail.com> | 2019-04-07 22:03:31 +0100 |
---|---|---|
committer | Spike <avlampson+git@gmail.com> | 2019-04-07 22:03:31 +0100 |
commit | bb81085619769aca861ab5d5bbff86f71c9435d2 (patch) | |
tree | 80b45de34d9f0647c10e6d6fae5b408c21c190c5 /asg.tf | |
download | fundapp_demo-master.zip fundapp_demo-master.tar.gz fundapp_demo-master.tar.bz2 |
Diffstat (limited to 'asg.tf')
-rw-r--r-- | asg.tf | 67 |
1 files changed, 67 insertions, 0 deletions
@@ -0,0 +1,67 @@ +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")}" +} |