Table: aws_ec2_capacity_reservation - Query AWS EC2 Capacity Reservations using SQL
An AWS EC2 Capacity Reservation ensures that you have reserved capacity for your Amazon EC2 instances in a specific Availability Zone for any duration. This capacity reservation helps to reduce the risks of insufficient capacity for launching instances into an Availability Zone, providing predictable instance launch times. It's a useful tool for capacity planning and managing costs, particularly for applications with predictable peaks in demand.
Table Usage Guide
The aws_ec2_capacity_reservation
table in Steampipe provides you with information about Capacity Reservations within AWS Elastic Compute Cloud (EC2). This table allows you, as a DevOps engineer, to query reservation-specific details, including reservation ID, reservation ARN, state, instance type, and associated metadata. You can utilize this table to gather insights on reservations, such as reservations per availability zone, reservations per instance type, and more. The schema outlines for you the various attributes of the EC2 Capacity Reservation, including the reservation ID, creation date, instance count, and associated tags.
Examples
Basic info
Identify instances where Amazon EC2 capacity reservations are made, gaining insights into the type of instances reserved and their current state. This can help in efficiently managing resources and understanding reservation patterns.
select capacity_reservation_id, capacity_reservation_arn, instance_type, statefrom aws_ec2_capacity_reservation;
select capacity_reservation_id, capacity_reservation_arn, instance_type, statefrom aws_ec2_capacity_reservation;
List EC2 expired capacity reservations
Identify instances where Amazon EC2 capacity reservations have expired. This information can be useful in managing resources and potentially freeing up unused capacity.
select capacity_reservation_id, capacity_reservation_arn, instance_type, statefrom aws_ec2_capacity_reservationwhere state = 'expired';
select capacity_reservation_id, capacity_reservation_arn, instance_type, statefrom aws_ec2_capacity_reservationwhere state = 'expired';
Get EC2 capacity reservation by ID
Determine the status and type of a specific EC2 capacity reservation in AWS, which can be useful for managing and optimizing resource allocation.
select capacity_reservation_id, capacity_reservation_arn, instance_type, statefrom aws_ec2_capacity_reservationwhere capacity_reservation_id = 'cr-0b30935e9fc2da81e';
select capacity_reservation_id, capacity_reservation_arn, instance_type, statefrom aws_ec2_capacity_reservationwhere capacity_reservation_id = 'cr-0b30935e9fc2da81e';
Schema for aws_ec2_capacity_reservation
Name | Type | Operators | Description |
---|---|---|---|
_ctx | jsonb | Steampipe context in JSON form. | |
account_id | text | =, !=, ~~, ~~*, !~~, !~~* | The AWS Account ID in which the resource is located. |
akas | jsonb | Array of globally unique identifier strings (also known as) for the resource. | |
availability_zone | text | = | The availability zone in which the capacity is reserved. |
availability_zone_id | text | = | The availability zone ID of the capacity reservation. |
available_instance_count | bigint | The remaining capacity. Indicates the number of instances that can be launched in the capacity reservation. | |
capacity_allocations | jsonb | Information about instance capacity usage. | |
capacity_reservation_arn | text | The Amazon Resource Name (ARN) of the capacity reservation. | |
capacity_reservation_fleet_id | text | The ID of the Capacity Reservation Fleet to which the Capacity Reservation belongs. Only valid for Capacity Reservations that were created by a Capacity Reservation Fleet. | |
capacity_reservation_id | text | = | The ID of the capacity reservation. |
create_date | timestamp with time zone | The date and time at which the capacity reservation was created. | |
ebs_optimized | boolean | Indicates whether the capacity reservation supports EBS-optimized instances. | |
end_date | timestamp with time zone | = | The date and time at which the capacity reservation expires. |
end_date_type | text | = | Indicates the way in which the capacity reservation ends. A capacity reservation can have one of the following end types: 'unlimited', 'limited'. |
ephemeral_storage | boolean | Indicates whether the capacity reservation supports instances with temporary, block-level storage. | |
instance_match_criteria | text | = | Indicates the type of instance launches that the capacity reservation accepts. The options include: 'open', 'targeted'. |
instance_platform | text | = | The type of operating system for which the capacity reservation reserves capacity. |
instance_type | text | = | The type of instance for which the capacity reservation reserves capacity. |
outpost_arn | text | The Amazon Resource Name (ARN) of the Outpost on which the Capacity Reservation was created. | |
owner_id | text | = | The ID of the AWS account that owns the capacity reservation. |
partition | text | The AWS partition in which the resource is located (aws, aws-cn, or aws-us-gov). | |
placement_group_arn | text | The Amazon Resource Name (ARN) of the cluster placement group in which the Capacity Reservation was created. | |
region | text | The AWS Region in which the resource is located. | |
reservation_type | text | The type of Capacity Reservation. | |
sp_connection_name | text | =, !=, ~~, ~~*, !~~, !~~* | Steampipe connection name. |
sp_ctx | jsonb | Steampipe context in JSON form. | |
start_date | timestamp with time zone | = | The date and time at which the capacity reservation was started. |
state | text | = | The current state of the capacity reservation. A capacity reservation can be in one of the following states: 'active', 'expired', 'cancelled', 'pending', 'failed'. |
tag_src | jsonb | Any tags assigned to the capacity reservation. | |
tags | jsonb | A map of tags for the resource. | |
tenancy | text | = | Indicates the tenancy of the capacity reservation. A capacity reservation can have one of the following tenancy settings: 'default', 'dedicated'. |
title | text | Title of the resource. | |
total_instance_count | bigint | The total number of instances for which the capacity reservation reserves capacity. |
Export
This table is available as a standalone Exporter CLI. Steampipe exporters are stand-alone binaries that allow you to extract data using Steampipe plugins without a database.
You can download the tarball for your platform from the Releases page, but it is simplest to install them with the steampipe_export_installer.sh
script:
/bin/sh -c "$(curl -fsSL https://steampipe.io/install/export.sh)" -- aws
You can pass the configuration to the command with the --config
argument:
steampipe_export_aws --config '<your_config>' aws_ec2_capacity_reservation