- EC2 Image Builder: Build your golden VM images on AWS - Wed, Jan 19 2022
- Configuring DFS Namespaces for Amazon FSx for Windows file servers - Fri, Jan 7 2022
- AWS Systems Manager Session Manager: Securely connect EC2 instances - Wed, Dec 22 2021
Amazon EC2 on-demand Capacity Reservations enable you to create and manage reserved capacity on Amazon EC2 without any long-term commitment or fixed terms. This can be very beneficial if you regularly face InsufficientInstanceCapacity errors when AWS doesn't have enough available on-demand capacity while starting or launching an EC2 instance.
Using the on-demand Capacity Reservation feature ensures that the compute capacity you want to consume for a certain instance type in a certain availability zone is available when you start it for a defined or undefined period.
Notes:
- You are charged at the selected instance type's on-demand rate for the specified number of EC2 instances as of creating the capacity reservation, regardless of whether you've consumed the capacity.
- You might get InsufficientInstanceCapacity errors while creating a capacity reservation if no capacity is available. Therefore, ensure that you're requesting the capacity some time earlier than you need to actually consume it to avoid this issue.
Create a Capacity Reservation
Navigate to the Amazon EC2 console
Under Instances, choose Capacity Reservations.
Click Create Capacity Reservation.
You are redirected to a new screen where you can specify the instance details, including the following:
- Instance Type: If the selected instance type is EBS-optimized by default, you cannot clear the EBS-optimized option. In addition, you can specify whether the instance will use temporary block-level storage.
- Platform: The instance's operating system.
- Availability Zone: The availability zone in which you will reserve capacity.
- Tenancy: Specify whether the tenancy is default (running a shared hardware instance) or dedicated (running a dedicated hardware instance).
- Quantity: The number of instances you would like to reserve.
Then configure the reservation details by specifying the following:
- Reservation ends: Specify whether to end the reservation manually or at a specific time.
- Instance eligibility: Specify the criteria for the instances that can fulfill this reservation. Select one of the following:
- Any instance with matching details, such as instance type, platform, or availability zone
- Only instances that specify this reservation when launching the instances
Afterward, you can specify the tags you would like to assign to this resource.
Finally, click Create. You are asked for confirmation before the creation proceeds.
Once it is confirmed and created, you can view the newly created capacity reservation in the Capacity Reservations console.
Test Capacity Reservation assignment
To test whether the EC2 instance will consume the reserved capacity, you can try to create an EC2 instance that matches the details you specified while creating the reservation capacity (instance type, platform, and availability zone) if you selected Any instance with matching details for Instance eligibility. You can then use the instance details under the Capacity reservation section to verify that the instance is assigned to the correct capacity reservation.
Or you can try to specify the capacity reservation you want while creating the EC2 instance in Step 3 by setting Capacity Reservation to Target by ID. You can then specify the Capacity Reservation ID.
Conclusion
In this article, we've gone through how to create and configure AWS EC2 on-demand Capacity Reservations. If you've got any further questions, please mention them in the comments.
DISCLAIMER: This article represents my own viewpoints, not those of my employer, Amazon Web Services.