[Bug]: ReservationCapacityExceeded error when changing capacity reservation id and instance_type of aws_instance #32458
Labels
bug
Addresses a defect in current functionality.
service/ec2
Issues and PRs that pertain to the ec2 service.
Milestone
Terraform Core Version
1.5.2
AWS Provider Version
5.7.0
Affected Resource(s)
Expected Behavior
Instance should have new instance_type and capacity reservation ID
Actual Behavior
Instance was stopped, instance_type updated, then instance failed to start because of reservation capacity type and instance type mismatch.
I can see that instance type update is not linked to capacity reservation change, and happens earlier:
https://github.com/hashicorp/terraform-provider-aws/blob/v5.7.0/internal/service/ec2/ec2_instance.go#L1662
https://github.com/hashicorp/terraform-provider-aws/blob/v5.7.0/internal/service/ec2/ec2_instance.go#L1936
That explains the behaviour. I suppose when aws_instance has instance_type and capacity reservation ID changes, the provider should perform the changes in stop/start context. I'm willing to implement the fix, but please advise on proper behaviour here.
Relevant Error/Panic Output Snippet
Error: updating EC2 Instance (i-0db1177c4c05dc826) type: starting EC2 Instance (i-0db1177c4c05dc826): ReservationCapacityExceeded: The requested reservation does not have sufficient compatible and available capacity for this request. status code: 400, request id: 21debb5c-604d-4c37-85d5-9cc4ff1cfd30
Terraform Configuration Files
Steps to Reproduce
Debug Output
No response
Panic Output
No response
Important Factoids
No response
References
No response
Would you like to implement a fix?
Yes
The text was updated successfully, but these errors were encountered: