Control: GCP SQL instance should not be publicly accessible
Description
This control checks whether the GCP SQL instance is publicly accessible.
Usage
Run the control in your terminal:
powerpipe control run terraform_gcp_compliance.control.sql_instance_publicly_accessibleSnapshot and share results via Turbot Pipes:
powerpipe loginpowerpipe control run terraform_gcp_compliance.control.sql_instance_publicly_accessible --shareSQL
This control uses a named query:
select  address as resource,  case    when (attributes_std -> 'settings') is null then 'ok'    when (attributes_std -> 'settings' -> 'ip_configuration' -> 'dynamic' -> 'authorized_networks') is not null then 'alarm'    when (attributes_std -> 'settings' -> 'ip_configuration' -> 'dynamic' -> 'authorized_networks') is not null and (attributes_std -> 'settings' -> 'ip_configuration' -> 'authorized_networks' ->> 'value') is null then 'ok'    when (attributes_std -> 'settings' -> 'ip_configuration' -> 'authorized_networks' ->> 'value') like '%/0' then 'alarm'    else 'ok'  end as status,  split_part(address, '.', 2) || case    when (attributes_std -> 'settings') is null then ' no settings found'    when (attributes_std -> 'settings' -> 'ip_configuration' -> 'dynamic' -> 'authorized_networks') is null then ' authorized network set in dynamic mode'    when (attributes_std -> 'settings' -> 'ip_configuration' -> 'dynamic' -> 'authorized_networks') is not null and (attributes_std -> 'settings' -> 'ip_configuration' -> 'authorized_networks' ->> 'value') is null then ' authorized network not set'    when (attributes_std -> 'settings' -> 'ip_configuration' -> 'authorized_networks' ->> 'value') like '%/0' then ' publicly accessible'    else ' not publicly accessible'  end || '.' reason  , path || ':' || start_linefrom  terraform_resourcewhere  type = 'google_sql_database_instance';