turbot / steampipe-plugin-gcp

Use SQL to instantly query GCP resources across regions, projects and organizations. Open source CLI. No DB required.
https://hub.steampipe.io/plugins/turbot/gcp
Apache License 2.0
39 stars 25 forks source link

Add table gcp_compute_machine_image Closes #517 #519

Closed ParthaI closed 8 months ago

ParthaI commented 10 months ago

Integration test logs

Logs ``` No env file present for the current environment: staging Falling back to .env config No env file present for the current environment: staging customEnv TURBOT_TEST_EXPECTED_TIMEOUT undefined SETUP: tests/gcp_compute_machine_image [] PRETEST: tests/gcp_compute_machine_image TEST: tests/gcp_compute_machine_image Running terraform data.google_client_config.current: Reading... data.google_client_config.current: Read complete after 0s [id=projects/"dumm-dfd"/regions/"us-east1"/zones/"us-east1-b"] data.null_data_source.resource: Reading... data.null_data_source.resource: Read complete after 0s [id=static] Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols: + create Terraform will perform the following actions: # google_compute_instance.names_test_resource will be created + resource "google_compute_instance" "names_test_resource" { + can_ip_forward = false + cpu_platform = (known after apply) + current_status = (known after apply) + deletion_protection = false + effective_labels = (known after apply) + guest_accelerator = (known after apply) + id = (known after apply) + instance_id = (known after apply) + label_fingerprint = (known after apply) + machine_type = "f1-micro" + metadata_fingerprint = (known after apply) + min_cpu_platform = (known after apply) + name = "turbottest96450" + project = "dumm-dfd" + self_link = (known after apply) + tags_fingerprint = (known after apply) + terraform_labels = (known after apply) + zone = "us-east1-b" + boot_disk { + auto_delete = true + device_name = (known after apply) + disk_encryption_key_sha256 = (known after apply) + kms_key_self_link = (known after apply) + mode = "READ_WRITE" + source = (known after apply) + initialize_params { + image = "debian-cloud/debian-11" + labels = (known after apply) + size = (known after apply) + type = (known after apply) } } + network_interface { + internal_ipv6_prefix_length = (known after apply) + ipv6_access_type = (known after apply) + ipv6_address = (known after apply) + name = (known after apply) + network = "default" + network_attachment = (known after apply) + network_ip = (known after apply) + stack_type = (known after apply) + subnetwork = (known after apply) + subnetwork_project = (known after apply) } } # google_compute_machine_image.names_test_resource will be created + resource "google_compute_machine_image" "names_test_resource" { + id = (known after apply) + name = "turbottest96450" + project = "dumm-dfd" + self_link = (known after apply) + source_instance = (known after apply) + storage_locations = (known after apply) } Plan: 2 to add, 0 to change, 0 to destroy. Changes to Outputs: + machine_type = "f1-micro" + resource_aka = "gcp://compute.googleapis.com/projects/dumm-dfd/machineImages/turbottest96450" + resource_name = "turbottest96450" + self_link = (known after apply) google_compute_instance.names_test_resource: Creating... google_compute_instance.names_test_resource: Still creating... [10s elapsed] google_compute_instance.names_test_resource: Still creating... [20s elapsed] google_compute_instance.names_test_resource: Creation complete after 21s [id=projects/dumm-dfd/zones/us-east1-b/instances/turbottest96450] google_compute_machine_image.names_test_resource: Creating... google_compute_machine_image.names_test_resource: Still creating... [10s elapsed] google_compute_machine_image.names_test_resource: Still creating... [20s elapsed] google_compute_machine_image.names_test_resource: Still creating... [30s elapsed] google_compute_machine_image.names_test_resource: Still creating... [40s elapsed] google_compute_machine_image.names_test_resource: Creation complete after 44s [id=projects/dumm-dfd/global/machineImages/turbottest96450] Warning: Deprecated with data.null_data_source.resource, on variables.tf line 33, in data "null_data_source" "resource": 33: data "null_data_source" "resource" { The null_data_source was historically used to construct intermediate values to re-use elsewhere in configuration, the same can now be achieved using locals or the terraform_data resource type in Terraform 1.4 and later. (and one more similar warning elsewhere) Apply complete! Resources: 2 added, 0 changed, 0 destroyed. Outputs: machine_type = "f1-micro" resource_aka = "gcp://compute.googleapis.com/projects/dumm-dfd/machineImages/turbottest96450" resource_name = "turbottest96450" self_link = "https://www.googleapis.com/compute/v1/projects/dumm-dfd/global/machineImages/turbottest96450" Running SQL query: test-get-query.sql [ { "kind": "compute#machineImage", "name": "turbottest96450", "self_link": "https://www.googleapis.com/compute/v1/projects/dumm-dfd/global/machineImages/turbottest96450", "title": "turbottest96450" } ] ✔ PASSED Running SQL query: test-list-query.sql [ { "akas": [ "gcp://compute.googleapis.com/projects/dumm-dfd/machineImages/turbottest96450" ], "name": "turbottest96450", "title": "turbottest96450" } ] ✔ PASSED Running SQL query: test-notfound-query.sql null ✔ PASSED Running SQL query: test-turbot-query.sql [ { "akas": [ "gcp://compute.googleapis.com/projects/dumm-dfd/machineImages/turbottest96450" ], "title": "turbottest96450" } ] ✔ PASSED POSTTEST: tests/gcp_compute_machine_image TEARDOWN: tests/gcp_compute_machine_image SUMMARY: 1/1 passed. ```

Example query results

Results ``` > select * from gcp_compute_machine_image +---------+---------------------+----------------------------------------------------------------------------------------+---------------------------+-------------+-------------+----------------------+--------------------------------------------------------------------> | name | id | self_link | creation_timestamp | description | guest_flush | kind | source_instance > +---------+---------------------+----------------------------------------------------------------------------------------+---------------------------+-------------+-------------+----------------------+--------------------------------------------------------------------> | test123 | 8019220569218285477 | https://www.googleapis.com/compute/v1/projects/dumm-dfd/global/machineImages/test123 | 2023-12-05T20:57:07+05:30 | test123 | false | compute#machineImage | https://www.googleapis.com/compute/v1/projects/dumm-dfd/zones/us-> | | | | | | | | > +---------+---------------------+----------------------------------------------------------------------------------------+---------------------------+-------------+-------------+----------------------+--------------------------------------------------------------------> Time: 0.6s. Rows fetched: 1. Hydrate calls: 0. > select * from gcp_compute_machine_image where name = 'test123' +---------+---------------------+----------------------------------------------------------------------------------------+---------------------------+-------------+-------------+----------------------+--------------------------------------------------------------------> | name | id | self_link | creation_timestamp | description | guest_flush | kind | source_instance > +---------+---------------------+----------------------------------------------------------------------------------------+---------------------------+-------------+-------------+----------------------+--------------------------------------------------------------------> | test123 | 8019220569218285477 | https://www.googleapis.com/compute/v1/projects/dumm-dfd/global/machineImages/test123 | 2023-12-05T20:57:07+05:30 | test123 | false | compute#machineImage | https://www.googleapis.com/compute/v1/projects/dumm-dfd/zones/us-> | | | | | | | | > +---------+---------------------+----------------------------------------------------------------------------------------+---------------------------+-------------+-------------+----------------------+--------------------------------------------------------------------> ```