turbot/steampipe-mod-alicloud-compliance

Query: vpc_and_vswitch_flow_log_integrated_with_log_service

Usage

powerpipe query alicloud_compliance.query.vpc_and_vswitch_flow_log_integrated_with_log_service

SQL

with compliant_flow_logs as (
select
resource_id,
resource_type,
project_name,
log_store_name,
region,
account_id,
name as flow_log_name
from
alicloud_vpc_flow_log
where
resource_type in ('VPC', 'VSwitch')
and status = 'Active'
and project_name is not null
and project_name != ''
and log_store_name is not null
and log_store_name != ''
)
select
arn as resource,
case
when fl.resource_id is not null then 'ok'
else 'alarm'
end as status,
case
when fl.resource_id is not null then v.title || ' has active flow log "' || fl.flow_log_name || '" integrated with log service (project: ' || fl.project_name || ', logstore: ' || fl.log_store_name || ').'
else v.title || ' does not have an active flow log integrated with log service'
end as reason
, v.account_id as account_id, v.region as region
from
alicloud_vpc v
left join compliant_flow_logs fl on v.vpc_id = fl.resource_id and v.region = fl.region and v.account_id = fl.account_id and fl.resource_type = 'VPC'
union all
select
'acs:vpc:' || vs.region || ':' || vs.account_id || ':vswitch/' || vs.vswitch_id as resource,
case
when fl.resource_id is not null then 'ok'
else 'alarm'
end as status,
case
when fl.resource_id is not null then vs.title || ' has active flow log "' || fl.flow_log_name || '" integrated with log service (project: ' || fl.project_name || ', logstore: ' || fl.log_store_name || ').'
else vs.title || ' does not have an active flow log integrated with log service.'
end as reason
, vs.account_id as account_id, vs.region as region
from
alicloud_vpc_vswitch vs
left join compliant_flow_logs fl on vs.vswitch_id = fl.resource_id and vs.region = fl.region and vs.account_id = fl.account_id and fl.resource_type = 'VSwitch';

Controls

The query is being used by the following controls: