host_group_members
This data source provides the live membership of a host group in Falcon. Use this to see which hosts are currently attached to a host group, regardless of whether membership comes from a dynamic assignment rule or a static list. Membership is resolved by Falcon at query time, so for static groups the result reflects the hosts Falcon currently considers members rather than the hostnames or IDs declared on the crowdstrike_host_group resource. All pages of members are retrieved automatically.
API Scopes
Section titled “API Scopes”The following API scopes are required:
- Host groups: READ
Example Usage
Section titled “Example Usage”terraform { required_providers { crowdstrike = { source = "registry.terraform.io/crowdstrike/crowdstrike" } }}
provider "crowdstrike" { cloud = "us-2"}
# Look up the live membership of a host group by namedata "crowdstrike_host_group_members" "prod" { name = "Production"}
# Look up the live membership of a host group by IDdata "crowdstrike_host_group_members" "by_id" { id = "dbe9c1fabd024fafaf44adf4df5f0f0f"}
# Only count the Windows hosts in the groupdata "crowdstrike_host_group_members" "prod_windows" { name = "Production" filter = "platform_name:'Windows'"}
output "prod_member_count" { value = data.crowdstrike_host_group_members.prod.member_count}
output "prod_host_ids" { value = data.crowdstrike_host_group_members.prod.host_ids}
# Fail the run when a host group that policies target is emptycheck "prod_has_members" { assert { condition = data.crowdstrike_host_group_members.prod.member_count > 0 error_message = "Host group 'Production' has no attached hosts." }}Schema
Section titled “Schema”Optional
Section titled “Optional”filter(String) FQL filter applied to the group members query. When set, only members matching the filter are returned. Example:platform_name:'Windows'id(String) The host group ID. Exactly one of ‘id’ or ‘name’ must be provided.name(String) The host group name. Exactly one of ‘id’ or ‘name’ must be provided.
Read-Only
Section titled “Read-Only”host_ids(Set of String) The agent IDs of the hosts currently in the host group. Empty when the group has no members or when no member matchesfilter.member_count(Number) The number of hosts inhost_ids.