Control: Ensure 'Block Project-wide SSH keys' is enabled for VM instances
Description
It is recommended to use instance specific SSH key(s) instead of using common/shared project-wide SSH key(s) to access instances.
Usage
Run the control in your terminal:
powerpipe control run terraform_gcp_compliance.control.compute_instance_block_project_wide_ssh_enabledSnapshot and share results via Turbot Pipes:
powerpipe loginpowerpipe control run terraform_gcp_compliance.control.compute_instance_block_project_wide_ssh_enabled --shareSQL
This control uses a named query:
select  address as resource,  case    when ((attributes_std ->> 'source_instance_template') is not null and (attributes_std ->> 'metadata') is null) then 'skip'    when ((attributes_std ->> 'source_instance_template') is not null and (attributes_std -> 'metadata' ->> 'block-project-ssh-keys') is null) then 'skip'    when ((attributes_std ->> 'source_instance_template') is null and (attributes_std ->> 'metadata') is null) then 'skip'    when ((attributes_std ->> 'source_instance_template') is null and (attributes_std -> 'metadata' ->> 'block-project-ssh-keys') is null) then 'skip'    when (attributes_std -> 'metadata' ->> 'block-project-ssh-keys')::bool then 'ok'    else 'alarm'  end status,  split_part(address, '.', 2) || case    when ((attributes_std ->> 'source_instance_template') is not null and (attributes_std ->> 'metadata') is null) then ' underlying source template is unknown'    when ((attributes_std ->> 'source_instance_template') is not null and (attributes_std -> 'metadata' ->> 'block-project-ssh-keys') is null) then ' underlying source template is unknown'    when ((attributes_std ->> 'source_instance_template') is null and (attributes_std ->> 'metadata') is null) then ' block project-wide SSH keys not set'    when ((attributes_std ->> 'source_instance_template') is null and (attributes_std -> 'metadata' ->> 'block-project-ssh-keys') is null) then ' block project-wide SSH keys not set'    when (attributes_std -> 'metadata' ->> 'block-project-ssh-keys')::bool then ' block project-wide SSH keys enabled'    else ' block project-wide SSH keys disabled'  end || '.' reason    , path || ':' || start_linefrom  terraform_resourcewhere  type in ('google_compute_instance', 'google_compute_instance_template', 'google_compute_instance_from_template');