Control: Ensure legacy networks do not exist for a project
Description
Legacy networks have a single network IPv4 prefix range and a single gateway IP address for the whole network. The network is global in scope and spans all cloud regions. Subnetworks cannot be created in a legacy network and are unable to switch from legacy to auto or custom subnet networks. Legacy networks can have an impact for high network traffic projects and are subjected to a single point of contention or failure.
Usage
Run the control in your terminal:
powerpipe control run terraform_gcp_compliance.control.compute_network_contains_no_legacy_network
Snapshot and share results via Turbot Pipes:
powerpipe loginpowerpipe control run terraform_gcp_compliance.control.compute_network_contains_no_legacy_network --share
SQL
This control uses a named query:
select address as resource, case when (attributes_std -> 'auto_create_subnetworks') is null then 'ok' when (attributes_std -> 'auto_create_subnetworks')::bool then 'ok' else 'alarm' end status, split_part(address, '.', 2) || case when (attributes_std -> 'auto_create_subnetworks') is null then ' is not a legacy network' when (attributes_std -> 'auto_create_subnetworks')::bool then ' is not a legacy network' else ' is a legacy network' end || '.' reason , path || ':' || start_linefrom terraform_resourcewhere type = 'google_compute_network';