Skip to content

azurermCapacityReservation

Manages a Capacity Reservation within a Capacity Reservation Group.

Example Usage

/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as azurerm from "./.gen/providers/azurerm";
/*The following providers are missing schema information and might need manual adjustments to synthesize correctly: azurerm.
For a more precise conversion please use the --provider flag in convert.*/
const azurermResourceGroupExample = new azurerm.resourceGroup.ResourceGroup(
  this,
  "example",
  {
    location: "West Europe",
    name: "example-rg",
  }
);
const azurermCapacityReservationGroupExample =
  new azurerm.capacityReservationGroup.CapacityReservationGroup(
    this,
    "example_1",
    {
      location: azurermResourceGroupExample.location,
      name: "example-capacity-reservation-group",
      resource_group_name: azurermResourceGroupExample.name,
    }
  );
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
azurermCapacityReservationGroupExample.overrideLogicalId("example");
const azurermCapacityReservationExample =
  new azurerm.capacityReservation.CapacityReservation(this, "example_2", {
    capacity_reservation_group_id: azurermCapacityReservationGroupExample.id,
    name: "example-capacity-reservation",
    sku: [
      {
        capacity: 1,
        name: "Standard_D2s_v3",
      },
    ],
  });
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
azurermCapacityReservationExample.overrideLogicalId("example");

Arguments Reference

The following arguments are supported:

  • name - (Required) Specifies the name of this Capacity Reservation. Changing this forces a new resource to be created.

  • capacityReservationGroupId - (Required) The ID of the Capacity Reservation Group where the Capacity Reservation exists. Changing this forces a new resource to be created.

  • sku - (Required) A sku block as defined below.

  • zone - (Optional) Specifies the Availability Zone for this Capacity Reservation. Changing this forces a new resource to be created.

  • tags - (Optional) A mapping of tags to assign to the resource.


An sku block exports the following:

  • name - (Required) Name of the sku, such as standardF2. Changing this forces a new resource to be created.

  • capacity - (Required) Specifies the number of instances to be reserved. It must be a positive integer and not exceed the quota in the subscription.

Attributes Reference

The following Attributes are exported:

  • id - The ID of the Capacity Reservation.

Timeouts

The timeouts block allows you to specify timeouts for certain actions:

  • create - (Defaults to 30 minutes) Used when creating the Capacity Reservation.
  • read - (Defaults to 5 minutes) Used when retrieving the Capacity Reservation.
  • update - (Defaults to 30 minutes) Used when updating the Capacity Reservation.
  • delete - (Defaults to 30 minutes) Used when deleting the Capacity Reservation.

Import

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

terraform import azurerm_capacity_reservation.example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/group1/providers/Microsoft.Compute/capacityReservationGroups/capacityReservationGroup1/capacityReservations/capacityReservation1