resource "aws_efs_file_system" "nexus_efs_file_system" {
  creation_token = "${local.name_prefix}-nexus"

  tags = merge(
    local.common_tags,
    {
      Name                     = "${local.name_prefix}-nexus"
      project                  = "Autotest",
      service                  = "EFS",
      plat_env_project_service = "${local.aggregated_tag}_WP_EFS"
    }
  )
}

resource "aws_efs_mount_target" "nexus_mount_target" {
  for_each = toset(data.aws_subnets.private_subnets.ids)

  file_system_id = aws_efs_file_system.nexus_efs_file_system.id
  subnet_id      = each.value
  security_groups = [
    data.aws_security_group.efs.id,
  ]
}

moved {
  from = aws_efs_mount_target.nexus_mount_target[0]
  to   = aws_efs_mount_target.nexus_mount_target["subnet-07fa468785840a8a2"]
}

moved {
  from = aws_efs_mount_target.nexus_mount_target[1]
  to   = aws_efs_mount_target.nexus_mount_target["subnet-0acc294da80ab6175"]
}

moved {
  from = aws_efs_mount_target.nexus_mount_target[2]
  to   = aws_efs_mount_target.nexus_mount_target["subnet-0b12f8e71dc839033"]
}
