Skip to content

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.

The following API scopes are required:

  • Host groups: READ
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 name
data "crowdstrike_host_group_members" "prod" {
name = "Production"
}
# Look up the live membership of a host group by ID
data "crowdstrike_host_group_members" "by_id" {
id = "dbe9c1fabd024fafaf44adf4df5f0f0f"
}
# Only count the Windows hosts in the group
data "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 empty
check "prod_has_members" {
assert {
condition = data.crowdstrike_host_group_members.prod.member_count > 0
error_message = "Host group 'Production' has no attached hosts."
}
}
  • 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.
  • 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 matches filter.
  • member_count (Number) The number of hosts in host_ids.