-
Notifications
You must be signed in to change notification settings - Fork 14
Description
User Story
As a Terraform user, I want to manage Power Platform environment membership within environment groups through Terraform so that I can centrally govern environments, enforce consistent policies, and manage lifecycle at scale.
Use case:
An organization manages dozens of Power Platform environments across development, test, and production. Environment groups are used to apply governance settings (like managed environments, security, and lifecycle controls), but today environments must be manually added to groups after creation. This breaks infrastructure-as-code principles and makes automated provisioning and drift detection impossible. Terraform support would enable fully automated, repeatable, and auditable environment governance.
Resource
- Resource Name:
powerplatform_environment_group_assignment - Service Name:
Power Platform Environment Group Assignment - Documentation Link: https://learn.microsoft.com/en-us/rest/api/power-platform/environmentmanagement/environment-groups
Potential Terraform Configuration
# Associates an existing Power Platform environment with an environment group
resource "powerplatform_environment_group_assignment" "example" {
environment_group_id = "00000000-0000-0000-0000-000000000001" # required
environment_id = "00000000-0000-0000-0000-000000000002" # required
}
Additional Validation Rules
- environment_group_id must be a valid existing environment group ID
- environment_id must be a valid existing Power Platform environment ID
- An environment can belong to only one environment group at a time
- Terraform should detect drift if the environment is manually removed from the group
API documentation
| Action | Verb | URL | Status Codes | Comments |
|---|---|---|---|---|
| Add Environment to Group | POST | https://api.powerplatform.com/environmentmanagement/environmentGroups/{groupId}/addEnvironment/{environmentId}?api-version=2022-03-01-preview |
200,201 | |
| Read Membership | GET | https://api.powerplatform.com/environmentmanagement/environmentGroups/{groupId}?api-version=2022-03-01-preview |
200 | |
| Remove Environment from Group | POST | https://api.powerplatform.com/environmentmanagement/environmentGroups/{groupId}/removeEnvironment/{environmentId}?api-version=2022-03-01-preview |
204 |
JSON
{}Definition of Done
- Data Transfer Objects (dtos) in
dto.go - Resource Model in
model.go - API Client functions in
api_{name}.go - Resource Implementation in
resource_{name}.go - Unit Tests in
resource_{name}_test.gofor Happy Path, Error conditions, boundry cases - Acceptance Tests in
resource_{name}_test.gofor Happy Path - Resource Added to
provider.goandprovider_test.go - Example in the
/examplesfolder - Schema documented using
MarkdownDescription - Change log entry
changie new -k added - Run
make precommitbefore PR
See the contributing guide for more information about what's expected for contributions.