Skip to content

Resource: awsEc2CapacityReservation

Provides an EC2 Capacity Reservation. This allows you to reserve capacity for your Amazon EC2 instances in a specific Availability Zone for any duration.

Example Usage

/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as aws from "./.gen/providers/aws";
new aws.ec2CapacityReservation.Ec2CapacityReservation(this, "default", {
  availabilityZone: "eu-west-1a",
  instanceCount: 1,
  instancePlatform: "Linux/UNIX",
  instanceType: "t2.micro",
});

Argument Reference

The following arguments are supported:

  • availabilityZone - (Required) The Availability Zone in which to create the Capacity Reservation.
  • ebsOptimized - (Optional) Indicates whether the Capacity Reservation supports EBS-optimized instances.
  • endDate - (Optional) The date and time at which the Capacity Reservation expires. When a Capacity Reservation expires, the reserved capacity is released and you can no longer launch instances into it. Valid values: RFC3339 time string (yyyyMmDdthh:mm:ssz)
  • endDateType - (Optional) Indicates the way in which the Capacity Reservation ends. Specify either unlimited or limited.
  • ephemeralStorage - (Optional) Indicates whether the Capacity Reservation supports instances with temporary, block-level storage.
  • instanceCount - (Required) The number of instances for which to reserve capacity.
  • instanceMatchCriteria - (Optional) Indicates the type of instance launches that the Capacity Reservation accepts. Specify either open or targeted.
  • instancePlatform - (Required) The type of operating system for which to reserve capacity. Valid options are linux/unix, redHatEnterpriseLinux, suseLinux, windows, windowsWithSqlServer, windowsWithSqlServerEnterprise, windowsWithSqlServerStandard or windowsWithSqlServerWeb.
  • instanceType - (Required) The instance type for which to reserve capacity.
  • outpostArn - (Optional) The Amazon Resource Name (ARN) of the Outpost on which to create the Capacity Reservation.
  • placementGroupArn - (Optional) The Amazon Resource Name (ARN) of the cluster placement group in which to create the Capacity Reservation.
  • tags - (Optional) A map of tags to assign to the resource. If configured with a provider defaultTags configuration block present, tags with matching keys will overwrite those defined at the provider-level.
  • tenancy - (Optional) Indicates the tenancy of the Capacity Reservation. Specify either default or dedicated.

Attributes Reference

In addition to all arguments above, the following attributes are exported:

  • id - The Capacity Reservation ID.
  • ownerId - The ID of the AWS account that owns the Capacity Reservation.
  • arn - The ARN of the Capacity Reservation.
  • tagsAll - A map of tags assigned to the resource, including those inherited from the provider defaultTags configuration block

Import

Capacity Reservations can be imported using the id, e.g.,

$ terraform import aws_ec2_capacity_reservation.web cr-0123456789abcdef0