For AI agents: A markdown version of this page is available at https://docs.datadoghq.com/security/code_security/iac_security/iac_rules/ansible-azure-cosmosdb-account-ip-range-filter-not-set.md.
A documentation index is available at /llms.txt.
Cosmos DB accounts should have an IP range filter configured to restrict which client IP addresses can connect. Without one, the account may accept connections from unintended networks, increasing the risk of unauthorized data access.
In Ansible, the azure.azcollection.azure_rm_cosmosdbaccount (and legacy azure_rm_cosmosdbaccount) resource must include the ip_range_filter property set to the allowed IP addresses or CIDR ranges. Resources missing ip_range_filter or with it empty are flagged, as they indicate no network-level IP restrictions. Provide a comma-separated list of IPs/CIDRs to enforce access control.
Secure example with IP restrictions:
- name:Create Cosmos DB account with IP restrictionsazure.azcollection.azure_rm_cosmosdbaccount:resource_group:my-rgname:my-cosmosdblocation:eastusoffer_type:Standardip_range_filter:"10.0.0.0/24,203.0.113.5"
Compliant Code Examples
- name:Create Cosmos DB Account - maxazure_rm_cosmosdbaccount:resource_group:myResourceGroupname:myDatabaseAccountlocation:westuskind:mongo_dbgeo_rep_locations:- name:southcentralusfailover_priority:0database_account_offer_type:Standardip_range_filter:10.10.10.10enable_multiple_write_locations:yesvirtual_network_rules:- subnet:/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/myVirtualNetwork/subnets/mySubnetconsistency_policy:default_consistency_level:bounded_stalenessmax_staleness_prefix:10max_interval_in_seconds:1000
Non-Compliant Code Examples
- name:Create Cosmos DB Account - maxazure_rm_cosmosdbaccount:resource_group:myResourceGroupname:myDatabaseAccountlocation:westuskind:mongo_dbgeo_rep_locations:- name:southcentralusfailover_priority:0database_account_offer_type:Standardenable_multiple_write_locations:yesvirtual_network_rules:- subnet:"/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/myVi
rtualNetwork/subnets/mySubnet"consistency_policy:default_consistency_level:bounded_stalenessmax_staleness_prefix:10max_interval_in_seconds:1000
1
2
rulesets:- Ansible / Azure # Rules to enforce / Azure.
Request a personalized demo
Get Started with Datadog
Ask AI
AI-generated responses may be inaccurate. Verify important info.