microsoft / terraform-provider-power-platform

Power Platform Terraform Provider
https://registry.terraform.io/providers/microsoft/power-platform/latest/docs
MIT License
35 stars 13 forks source link

Allow filtering of `data.powerplatform_environments` data source #479

Open mattdot opened 1 month ago

mattdot commented 1 month ago

Enhance the powerplatform_environments data source to accept a filter to return a more targeted list of environments


data "powerplatform_environments" "get_by_id" {
  filter = "name eq <guid>"
}

data "powerplatform_environments" "get_default" {
  filter = "properties.isDefault eq true"
}

data "powerplatform_environments" "get_coe_envs" {
  filter = "contains(properties.displayName,  'CoE')"
}
webstean commented 1 month ago

This would be great!!! And terribly useful.

mattdot commented 1 month ago

After looking at the limitations of the API I'm considering an alternative syntax

data "powerplatform_environments" "get_by_id" {
  filter = {
    environment_id = "<guid>"
  }
}

data "powerplatform_environments" "get_default" {
  filter = {
     sku = "Default" # Default | Production | Sandbox | Developer
  }
}

data "powerplatform_environments" "get_unprotected" {
  filter = {
     security_group_id = "00000000-0000-0000-0000-000000000000"
  }
}