I have an AWS auto-scaling group, startup configuration, and auto-scaling group policy defined in Terraform as follows:
resource "aws_autoscaling_group" "default" { name = "..." health_check_type = "EC2" vpc_zone_identifier = ["${...}"] min_size = "${var.asg_capacity}" max_size = "${var.asg_capacity * 2}" desired_capacity = "${var.asg_capacity}" launch_configuration = "${aws_launch_configuration.default.id}" termination_policies = ["OldestInstance"] } resource "aws_autoscaling_policy" "default" { name = "..." autoscaling_group_name = "${aws_autoscaling_group.default.name}" scaling_adjustment = "${var.asg_capacity}" adjustment_type = "ChangeInCapacity" cooldown = 300 } resource "aws_launch_configuration" "default" { name_prefix = "..._" image_id = "${var.coreos_ami_id}" instance_type = "${var.ec2_instance_type}" iam_instance_profile = "${aws_iam_instance_profile.default.arn}" key_name = "..." security_groups = ["${aws_security_group.default.id}"] user_data = "${data.template_file.cloud_init.rendered}" lifecycle { create_before_destroy = true } }
When I change my user data, a new launch configuration is created and then joined to the autoscale group. I would suggest that this would cause the var.asg_capacity group to grow by var.asg_capacity instances, wait 300 seconds, and then demolish the old values ββby OldestInstance .
When I did similar things in CloudFormation, I used the following configuration options :
ASG: Type: AWS::AutoScaling::AutoScalingGroup UpdatePolicy: AutoScaleRollingUpdate:
Is there an analogue for this in Terraform? I would really like my autoscale groups to change when the launch configuration changes.
source share