Skip to content

Add Environment Group assignment resource #1026

@Jvekka

Description

@Jvekka

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

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.go for Happy Path, Error conditions, boundry cases
  • Acceptance Tests in resource_{name}_test.go for Happy Path
  • Resource Added to provider.go and provider_test.go
  • Example in the /examples folder
  • Schema documented using MarkdownDescription
  • Change log entry changie new -k added
  • Run make precommit before PR

See the contributing guide for more information about what's expected for contributions.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or requestresourceterraform resource

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions