|
| 1 | +# Table: gcp_compute_machine_image |
| 2 | + |
| 3 | +A machine image is a Compute Engine resource that stores all the configuration, metadata, permissions, and data from multiple disks of a virtual machine (VM) instance. You can use a machine image in many system maintenance, backup and recovery, and instance cloning scenarios. |
| 4 | + |
| 5 | +## Examples |
| 6 | + |
| 7 | +### Basic info |
| 8 | + |
| 9 | +```sql |
| 10 | +select |
| 11 | + name, |
| 12 | + id, |
| 13 | + description, |
| 14 | + creation_timestamp, |
| 15 | + guest_flush, |
| 16 | + source_instance |
| 17 | +from |
| 18 | + gcp_compute_machine_image; |
| 19 | +``` |
| 20 | + |
| 21 | +### List machine images that are available |
| 22 | + |
| 23 | +```sql |
| 24 | +select |
| 25 | + name, |
| 26 | + id, |
| 27 | + description, |
| 28 | + creation_timestamp, |
| 29 | + status |
| 30 | +from |
| 31 | + gcp_compute_machine_image |
| 32 | +where |
| 33 | + status = 'READY'; |
| 34 | +``` |
| 35 | + |
| 36 | +### List the top 5 machine images that consume highest storage |
| 37 | + |
| 38 | +```sql |
| 39 | +select |
| 40 | + name, |
| 41 | + id, |
| 42 | + self_link, |
| 43 | + status, |
| 44 | + total_storage_bytes |
| 45 | +from |
| 46 | + gcp_compute_machine_image |
| 47 | +order by |
| 48 | + total_storage_bytes asc; |
| 49 | +``` |
| 50 | + |
| 51 | +### Get instance properties of the machine images |
| 52 | + |
| 53 | +```sql |
| 54 | +select |
| 55 | + name, |
| 56 | + id, |
| 57 | + instance_properties -> 'AdvancedMachineFeatures' as advanced_machine_features, |
| 58 | + instance_properties ->> 'CanIpForward' as can_ip_forward, |
| 59 | + instance_properties -> 'ConfidentialInstanceConfig' as confidential_instance_config, |
| 60 | + instance_properties ->> 'Description' as description, |
| 61 | + instance_properties -> 'Disks' as disks, |
| 62 | + instance_properties -> 'GuestAccelerators' as guest_accelerators, |
| 63 | + instance_properties ->> 'KeyRevocationActionType' as key_revocation_action_type, |
| 64 | + instance_properties -> 'Labels' as labels, |
| 65 | + instance_properties ->> 'MachineType' as machine_type, |
| 66 | + instance_properties -> 'Metadata' as metadata, |
| 67 | + instance_properties -> 'MinCpuPlatform' as min_cpu_platform, |
| 68 | + instance_properties -> 'NetworkInterfaces' as network_interfaces, |
| 69 | + instance_properties -> 'NetworkPerformanceConfig' as network_performance_config, |
| 70 | + instance_properties -> 'PrivateIpv6GoogleAccess' as private_ipv6_google_access, |
| 71 | + instance_properties ->> 'ReservationAffinity' as reservation_affinity, |
| 72 | + instance_properties -> 'ResourceManagerTags' as resource_manager_tags, |
| 73 | + instance_properties -> 'ResourcePolicies' as resource_policies, |
| 74 | + instance_properties -> 'Scheduling' as scheduling, |
| 75 | + instance_properties -> 'ServiceAccounts' as service_accounts, |
| 76 | + instance_properties -> 'ShieldedInstanceConfig' as shielded_instance_config, |
| 77 | + instance_properties -> 'Tags' as tags |
| 78 | +from |
| 79 | + gcp_compute_machine_image; |
| 80 | +``` |
| 81 | + |
| 82 | +### Get encryption details of the machine image |
| 83 | + |
| 84 | +```sql |
| 85 | +select |
| 86 | + name, |
| 87 | + machine_image_encryption_key ->> 'KmsKeyName' as kms_key_name, |
| 88 | + machine_image_encryption_key ->> 'KmsKeyServiceAccount' as kms_key_service_account, |
| 89 | + machine_image_encryption_key ->> 'RawKey' as raw_key, |
| 90 | + machine_image_encryption_key ->> 'RsaEncryptedKey' as rsa_encrypted_key, |
| 91 | + machine_image_encryption_key ->> 'Sha256' as sha256, |
| 92 | +from |
| 93 | + gcp_compute_machine_image; |
| 94 | +``` |
0 commit comments