resource "aws_autoscaling_group" "catherine_fc_asg" {
    name = "${var.basename}-${terraform.workspace}"

    availability_zones = ["ap-northeast-1a", "ap-northeast-1c", "ap-northeast-1d"]
    vpc_zone_identifier = var.internal_subnet_ids

    desired_capacity = var.asg_caps.desired
    max_size = var.asg_caps.max
    min_size = var.asg_caps.min

    launch_configuration = aws_launch_configuration.catherine_fc_conf.name
    target_group_arns = [aws_lb_target_group.target_group_web.id]
    tags = concat(var.asg_tags, [
        {
            key = "STAGE_ENVIRONMENT",
            value = "${terraform.workspace}",
            propagate_at_launch = true
        },
        {
            key = "Name",
            value = "${var.basename}-${terraform.workspace}",
            propagate_at_launch = true
        }
    ])

    enabled_metrics = [
        "GroupMinSize",
        "GroupMaxSize",
        "GroupDesiredCapacity",
        "GroupInServiceInstances",
        "GroupPendingInstances",
        "GroupTerminatingInstances",
        "GroupStandbyInstances",
        "GroupTotalInstances"
    ]
}
