steampipe plugin install gcp

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_type
from
gcp_compute_instance_template
where
instance_machine_type = 'c2-standard-4';
select
name,
id,
instance_machine_type
from
gcp_compute_instance_template
where
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 mode
from
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_type
from
gcp_compute_instance_template
where
instance_reservation_affinity ->> 'consumeReservationType' = 'SPECIFIC_RESERVATION';
select
name,
id,
json_extract(
instance_reservation_affinity,
'$.consumeReservationType'
) as consume_reservation_type
from
gcp_compute_instance_template
where
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_type
from
gcp_compute_instance_template,
jsonb_array_elements(instance_network_interfaces) as i,
jsonb_array_elements(i -> 'accessConfigs') as p;
Error: SQLite does not support split
or 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_forward
from
gcp_compute_instance_template
where
instance_can_ip_forward;
select
name,
id,
instance_can_ip_forward
from
gcp_compute_instance_template
where
instance_can_ip_forward = 1;

Schema for gcp_compute_instance_template

NameTypeOperatorsDescription
_ctxjsonbSteampipe context in JSON form.
akasjsonbArray of globally unique identifier strings (also known as) for the resource.
creation_timestamptimestamp with time zoneThe creation timestamp for this instance template.
descriptiontextAn optional description of this resource.
idbigintA unique identifier for this instance template. The server defines this identifier.
instance_can_ip_forwardbooleanEnables 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_descriptiontextAn optional text description for the instances that are created from these properties.
instance_disksjsonbAn array of disks that are associated with the instances that are created from these properties.
instance_guest_acceleratorsjsonbA list of guest accelerator cards' type and count to use for instances created from these properties.
instance_machine_typetextThe machine type to use for instances that are created from these properties.
instance_metadatajsonbThe 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_platformtextMinimum 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_interfacesjsonbAn array of network access configurations for this interface.
instance_private_ipv6_google_accesstextThe 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_affinityjsonbSpecifies the reservations that instances can consume from.
instance_resource_policiesjsonbResource policies (names, not URLs) applied to instances created from these properties.
instance_schedulingjsonbSpecifies the scheduling options for the instances that are created from these properties.
instance_service_accountsjsonbA 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_configjsonbA set of Shielded Instance options.
instance_tagsjsonbA list of tags to apply to the instances that are created from these properties. The tags identify valid sources or targets for network firewalls.
kindtextThe resource type, which is always compute#instanceTemplate for instance templates.
labelsjsonbLabels to apply to instances that are created from these properties.
locationtextThe GCP multi-region, region, or zone in which the resource is located.
nametext=A friendly name that identifies the resource.
projecttext=, !=, ~~, ~~*, !~~, !~~*The GCP Project in which the resource is located.
self_linktextThe server-defined URL for this instance template.
source_instancetextThe URL of the source instance used to create the template.
source_instance_nametextThe URL of the source instance used to create the template.
sp_connection_nametext=, !=, ~~, ~~*, !~~, !~~*Steampipe connection name.
sp_ctxjsonbSteampipe context in JSON form.
tagsjsonbA map of tags for the resource.
titletextTitle 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