module "indexer0" {
  source = "../../../submodules/splunk/splunk_indexer_asg"
  name                       = var.prefix
  asg_number                 = 0
  asg_name                   = "${local.asg_name}-0"
  launch_conf_name           = "${local.launch_config_name}-0"
  volume_sizes               = var.splunk_volume_sizes["indexer"]
  idx_instance_type          = var.instance_type
  user_data                  = data.template_cloudinit_config.cloud-init.rendered
  indexer_security_group_ids = [ data.aws_security_group.typical-host.id, aws_security_group.indexer_security_group.id ]
  vpc_zone_identifier        = [ var.private_subnets[0] ]
  key_name                   = "msoc-build"
  min_size                   = var.splunk_asg_sizes[0]
  max_size                   = var.splunk_asg_sizes[0]
  iam_instance_profile       = aws_iam_instance_profile.indexer_instance_profile.name
  common_services_account    = var.common_services_account
  tags = merge(var.standard_tags, var.tags, { Name = "${local.asg_name}-0" } )
}

module "indexer1" {
  source = "../../../submodules/splunk/splunk_indexer_asg"
  name                       = var.prefix
  asg_number                 = 1
  asg_name                   = "${local.asg_name}-1"
  launch_conf_name           = "${local.launch_config_name}-1"
  volume_sizes               = var.splunk_volume_sizes["indexer"]
  idx_instance_type          = var.instance_type
  user_data                  = data.template_cloudinit_config.cloud-init.rendered
  indexer_security_group_ids = [ data.aws_security_group.typical-host.id, aws_security_group.indexer_security_group.id ]
  vpc_zone_identifier        = [ var.private_subnets[1] ]
  key_name                   = "msoc-build"
  min_size                   = var.splunk_asg_sizes[1]
  max_size                   = var.splunk_asg_sizes[1]
  iam_instance_profile       = aws_iam_instance_profile.indexer_instance_profile.name
  common_services_account    = var.common_services_account
  tags = merge(var.standard_tags, var.tags, { Name = "${local.asg_name}-1" } )
}

module "indexer2" {
  source = "../../../submodules/splunk/splunk_indexer_asg"
  name                       = var.prefix
  asg_number                 = 2
  asg_name                   = "${local.asg_name}-2"
  launch_conf_name           = "${local.launch_config_name}-2"
  volume_sizes               = var.splunk_volume_sizes["indexer"]
  idx_instance_type          = var.instance_type
  user_data                  = data.template_cloudinit_config.cloud-init.rendered
  indexer_security_group_ids = [ data.aws_security_group.typical-host.id, aws_security_group.indexer_security_group.id ]
  vpc_zone_identifier        = [ var.private_subnets[2] ]
  key_name                   = "msoc-build"
  min_size                   = var.splunk_asg_sizes[2]
  max_size                   = var.splunk_asg_sizes[2]
  iam_instance_profile       = aws_iam_instance_profile.indexer_instance_profile.name
  common_services_account    = var.common_services_account
  tags = merge(var.standard_tags, var.tags, { Name = "${local.asg_name}-2" } )
}
