resource "aws_batch_compute_environment" "batch_compute_environment" {
  compute_environment_name = "${var.environment}-${var.service_name}-batch"

  compute_resources {
    max_vcpus = 80
    security_group_ids = [
      aws_security_group.batch_security_group.id,
    ]
    subnets = module.vpc_info.default_private_subnet_ids
    type = "FARGATE"
  }
  service_role = aws_iam_role.aws_batch_service_role.arn
  type         = "MANAGED"

  depends_on = [
    aws_iam_role_policy_attachment.aws_batch_service_role
  ]
}

resource "aws_batch_job_queue" "batch_compute_environment" {
  name     = "${var.environment}-${var.service_name}-job-queue"
  state    = "ENABLED"
  priority = "0"
  compute_environments = [
    aws_batch_compute_environment.batch_compute_environment.arn,
  ]
}
