turbot/terraform_gcp_compliance

Query: sql_instance_publicly_accessible

Usage

powerpipe query terraform_gcp_compliance.query.sql_instance_publicly_accessible

Steampipe Tables

SQL

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_line
from
terraform_resource
where
type = 'google_sql_database_instance';

Controls

The query is being used by the following controls: