Control: Cosmos DB accounts should have restricted access
Description
Ensure that Azure Cosmos DB accounts have restricted access.
Usage
Run the control in your terminal:
powerpipe control run terraform_azure_compliance.control.cosmodb_account_restrict_public_access
Snapshot and share results via Turbot Pipes:
powerpipe loginpowerpipe control run terraform_azure_compliance.control.cosmodb_account_restrict_public_access --share
SQL
This control uses a named query:
select address as resource, case when (attributes_std ->> 'public_network_access_enabled') = 'false' then 'ok' when (attributes_std ->> 'public_network_access_enabled')::boolean and (attributes_std ->> 'is_virtual_network_filter_enabled')::boolean and ((attributes_std ->> 'virtual_network_rule') is not null or (attributes_std ->> 'ip_range_filter') is not null) then 'ok' else 'alarm' end status, split_part(address, '.', 2) || case when (attributes_std ->> 'public_network_access_enabled') = 'false' then 'ok' when (attributes_std ->> 'public_network_access_enabled')::boolean and (attributes_std ->> 'is_virtual_network_filter_enabled')::boolean and ((attributes_std ->> 'virtual_network_rule') is not null or (attributes_std ->> 'ip_range_filter') is not null) then ' with restricted access' else ' without restricted access' end || '.' reason , path || ':' || start_linefrom terraform_resourcewhere type = 'azurerm_cosmosdb_account';