terraform-aws-modules / terraform-aws-batch

Terraform module to create AWS Batch resources 🇺🇦
https://registry.terraform.io/modules/terraform-aws-modules/batch/aws
Apache License 2.0
35 stars 40 forks source link

Unable to update compute environments that have associated job queues #9

Closed flowinh2o closed 1 year ago

flowinh2o commented 1 year ago

Description

When trying to update a compute environment that has an associated queue I am getting the following error:

Error: error deleting Batch Compute Environment (ec2_spot-20221103182652341500000006): : Cannot delete, found existing JobQueue relationship

As a workaround I am having to to a destroy and then re-apply.

Versions

Reproduction Code [Required]

I am running this in terragrunt but the inputs to terraform are similar to this

inputs = {

  instance_iam_role_name = "INSTANCE_ROLE"
  service_iam_role_name  = "SERVICE_ROLE"

  compute_environments = {
    a_ec2_spot = {
      name_prefix = "test"

      compute_resources = {
        type                = "SPOT"
        allocation_strategy = "BEST_FIT_PROGRESSIVE"
        min_vcpus      = 0
        max_vcpus      = 512
        desired_vcpus  = 0
        instance_types = ["c5.large", "c6i.large", "c5.xlarge", "c6i.xlarge", "m5.large", "m6i.large", "m5.xlarge", "m6i.xlarge", "r5.large", "r6i.large", "r5.xlarge", "r6i.xlarge"]

        security_group_ids = ["${dependency.security_group.outputs.security_group_id}"]
        subnets            = dependency.vpc.outputs.private_subnets
      }
    }
  }

  job_queues = {
    test = {
      name     = "test"
      state    = "ENABLED"
      priority = 0
    }

  }

  job_definitions = {

    test = {
      name                  = "test"
      propagate_tags        = true
      platform_capabilities = ["EC2"]
      priority              = 1

      container_properties = jsonencode({
        command = ["ls", "-la"]
        image   = "SOME_ECR_IMAGE"
        resourceRequirements = [
          { type = "VCPU", value = "4" },
          { type = "MEMORY", value = "1024" }
        ]
        jobRoleArn = dependency.role_job.outputs.iam_role_arn
      })

      attempt_duration_seconds = 900
      retry_strategy = {
        attempts = 5
        evaluate_on_exit = {
          retry_error = {
            action           = "RETRY"
            on_status_reason = "Host EC2*"
          }
          exit_success = {
            action    = "EXIT"
            on_reason = "*"
          }
        }
      }
    }
  }
}
bryantbiggs commented 1 year ago

Reference: https://github.com/hashicorp/terraform-provider-aws/issues/13221

mrdrprofuroboros commented 1 year ago

https://stackoverflow.com/questions/61669156/terraform-how-to-enable-deletion-of-batch-service-compute-environment could you add lifecycle option/variable as a workaround?

github-actions[bot] commented 1 year ago

This issue has been automatically marked as stale because it has been open 30 days with no activity. Remove stale label or comment or this issue will be closed in 10 days

github-actions[bot] commented 1 year ago

This issue was automatically closed because of stale in 10 days

github-actions[bot] commented 1 year ago

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.