Table: gcp_compute_instance_template - Query Google Cloud Compute Engine Instance Templates using SQL
An Instance Template in Google Cloud Compute Engine is a resource that provides a way to create instances based on a template. This allows for the uniform deployment of multiple instances that have the same configurations. Instance Templates define the machine type, boot disk image or container image, labels, and other instance properties.
Table Usage Guide
The gcp_compute_instance_template
table provides insights into Instance Templates within Google Cloud Compute Engine. As a DevOps engineer, explore template-specific details through this table, including machine type, boot disk image, labels, and other instance properties. Utilize it to uncover information about templates, such as those with specific configurations, the uniform deployment of multiple instances, and the verification of instance properties.
Examples
List of c2-standard-4 machine type instance template
Discover the segments that utilize the 'c2-standard-4' machine type within Google Cloud Platform's compute instances. This is particularly useful for assessing resource allocation and planning for future infrastructure needs.
select name, id, instance_machine_typefrom gcp_compute_instance_templatewhere instance_machine_type = 'c2-standard-4';
select name, id, instance_machine_typefrom gcp_compute_instance_templatewhere instance_machine_type = 'c2-standard-4';
Boot Disk info of each instance template
Determine the characteristics of each instance template's boot disk in a GCP compute environment. This can be useful to assess the disk type, size, and source image, which can aid in capacity planning and performance optimization.
select name, id, disk ->> 'deviceName' as disk_device_name, disk -> 'initializeParams' ->> 'diskType' as disk_type, disk -> 'initializeParams' ->> 'diskSizeGb' as disk_size_gb, split_part(disk -> 'initializeParams' ->> 'sourceImage', '/', 5) as source_image, disk ->> 'mode' as modefrom gcp_compute_instance_template, jsonb_array_elements(instance_disks) as disk;
Error: SQLite does not support split functions.
List of SPECIFIC_RESERVATION Instance type instance template
Analyze the settings to understand which instance templates in the Google Cloud Platform are specifically set to consume reservations. This can help optimize resource allocation and cost management in cloud environments.
select name, id, instance_reservation_affinity ->> 'consumeReservationType' as consume_reservation_typefrom gcp_compute_instance_templatewhere instance_reservation_affinity ->> 'consumeReservationType' = 'SPECIFIC_RESERVATION';
select name, id, json_extract( instance_reservation_affinity, '$.consumeReservationType' ) as consume_reservation_typefrom gcp_compute_instance_templatewhere json_extract( instance_reservation_affinity, '$.consumeReservationType' ) = 'SPECIFIC_RESERVATION';
Network interface info of each instance template
Determine the network interface details of each instance template in your GCP Compute Engine to understand the network configuration and access settings in each instance. This will help in identifying any irregularities or inconsistencies in the network setup.
select name, id, i ->> 'name' as name, split_part(i ->> 'network', '/', 10) as network_name, p ->> 'name' as access_config_name, p ->> 'networkTier' as access_config_network_tier, p ->> 'type' as access_config_typefrom gcp_compute_instance_template, jsonb_array_elements(instance_network_interfaces) as i, jsonb_array_elements(i -> 'accessConfigs') as p;
Error: SQLite does not support splitor string_to_array functions.
List of instance templates where instance_can_ip_forward is true
Discover the segments that have the ability to forward IP, a useful feature for routing network traffic effectively and securely. This can be particularly beneficial in scenarios where you need to manage traffic flow across different network interfaces.
select name, id, instance_can_ip_forwardfrom gcp_compute_instance_templatewhere instance_can_ip_forward;
select name, id, instance_can_ip_forwardfrom gcp_compute_instance_templatewhere instance_can_ip_forward = 1;
Query examples
Schema for gcp_compute_instance_template
Name | Type | Operators | Description |
---|---|---|---|
_ctx | jsonb | Steampipe context in JSON form. | |
akas | jsonb | Array of globally unique identifier strings (also known as) for the resource. | |
creation_timestamp | timestamp with time zone | The creation timestamp for this instance template. | |
description | text | An optional description of this resource. | |
id | bigint | A unique identifier for this instance template. The server defines this identifier. | |
instance_can_ip_forward | boolean | Enables instances created based on these properties to send packets with source IP addresses other than their own and receive packets with destination IP addresses other than their own. | |
instance_description | text | An optional text description for the instances that are created from these properties. | |
instance_disks | jsonb | An array of disks that are associated with the instances that are created from these properties. | |
instance_guest_accelerators | jsonb | A list of guest accelerator cards' type and count to use for instances created from these properties. | |
instance_machine_type | text | The machine type to use for instances that are created from these properties. | |
instance_metadata | jsonb | The metadata key/value pairs to assign to instances that are created from these properties. These pairs can consist of custom metadata or predefined keys. | |
instance_min_cpu_platform | text | Minimum cpu/platform to be used by instances. The instance may be scheduled on the specified or newer cpu/platform. Applicable values are the friendly names of CPU platforms, such as minCpuPlatform: "Intel Haswell" or minCpuPlatform: "Intel Sandy Bridge". For more information, read Specifying a Minimum CPU Platform. | |
instance_network_interfaces | jsonb | An array of network access configurations for this interface. | |
instance_private_ipv6_google_access | text | The private IPv6 google access type for VMs. If not specified, use INHERIT_FROM_SUBNETWORK as default. Possible values: "ENABLE_BIDIRECTIONAL_ACCESS_TO_GOOGLE", "ENABLE_OUTBOUND_VM_ACCESS_TO_GOOGLE", "INHERIT_FROM_SUBNETWORK" | |
instance_reservation_affinity | jsonb | Specifies the reservations that instances can consume from. | |
instance_resource_policies | jsonb | Resource policies (names, not URLs) applied to instances created from these properties. | |
instance_scheduling | jsonb | Specifies the scheduling options for the instances that are created from these properties. | |
instance_service_accounts | jsonb | A list of service accounts with specified scopes. Access tokens for these service accounts are available to the instances that are created from these properties. | |
instance_shielded_instance_config | jsonb | A set of Shielded Instance options. | |
instance_tags | jsonb | A list of tags to apply to the instances that are created from these properties. The tags identify valid sources or targets for network firewalls. | |
kind | text | The resource type, which is always compute#instanceTemplate for instance templates. | |
labels | jsonb | Labels to apply to instances that are created from these properties. | |
location | text | The GCP multi-region, region, or zone in which the resource is located. | |
name | text | = | A friendly name that identifies the resource. |
project | text | =, !=, ~~, ~~*, !~~, !~~* | The GCP Project in which the resource is located. |
self_link | text | The server-defined URL for this instance template. | |
source_instance | text | The URL of the source instance used to create the template. | |
source_instance_name | text | The URL of the source instance used to create the template. | |
sp_connection_name | text | =, !=, ~~, ~~*, !~~, !~~* | Steampipe connection name. |
sp_ctx | jsonb | Steampipe context in JSON form. | |
tags | jsonb | A map of tags for the resource. | |
title | text | Title of the resource. |
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)" -- gcp
You can pass the configuration to the command with the --config
argument:
steampipe_export_gcp --config '<your_config>' gcp_compute_instance_template