hashicorp / terraform-provider-aws

The AWS Provider enables Terraform to manage AWS resources.
https://registry.terraform.io/providers/hashicorp/aws
Mozilla Public License 2.0
9.74k stars 9.1k forks source link

[Bug]: aws_batch_compute_environment in place updates do not work with SPOT_PRICE_CAPACITY_OPTIMIZED allocation_strategy #38695

Open chrischappell-rgare opened 1 month ago

chrischappell-rgare commented 1 month ago

Terraform Core Version

1.6.6

AWS Provider Version

5.61.0

Affected Resource(s)

aws_batch_compute_environment

Expected Behavior

When aws_batch_compute_environment properties such as image_id or instances_types is changed an in-place update of the compute environment should occur. This is not working when allocation_strategy is SPOT_PRICE_CAPACITY_OPTIMIZED. It does work for SPOT_CAPACITY_OPTIMIZED.

Actual Behavior

The plan indicates that the aws_batch_compute_environment must be replaced, which will destroy the compute environment instead.

Relevant Error/Panic Output Snippet

No response

Terraform Configuration Files

resource "aws_batch_compute_environment" "compute_environment" {
    compute_environment_name = var.compute_environment_name
    type = "MANAGED"
    service_role = var.batch_service_role

    compute_resources {
        type = "SPOT"
        spot_iam_fleet_role = var.spot_iam_fleet_role
        allocation_strategy = "SPOT_PRICE_CAPACITY_OPTIMIZED"
        bid_percentage = 100
        max_vcpus = 100
        instance_role = var.ecs_instance_role
        instance_type = var.instance_types
        image_id = var.image_id
        security_group_ids = var.security_groups
        subnets = var.subnets
    }

    update_policy {
        job_execution_timeout_minutes = 30
        terminate_jobs_on_update = false
    }
}

Steps to Reproduce

  1. Create an aws_batch_compute_environment with Terraform. compute_resources type should be SPOT and allocation_strategy should be SPOT_PRICE_CAPACITY_OPTIMIZED. Include an instance_type value, such as ["m7i"].
  2. Plan and apply the Terraform.
  3. Change the instance type to a different value, such as ["r7i"].
  4. Run terraform plan.

Debug Output

No response

Panic Output

No response

Important Factoids

No response

References

No response

Would you like to implement a fix?

None

github-actions[bot] commented 1 month ago

Community Note

Voting for Prioritization

Volunteering to Work on This Issue