Skip to content
This repository was archived by the owner on Apr 6, 2026. It is now read-only.

Commit 2b448a0

Browse files
authored
Merge pull request #31 from raffertyuy/main
Implement dev_center_project_environment_type using GitHub Coding Agent with a new GH Issue Template
2 parents 6dad2a5 + 9d8e94c commit 2b448a0

File tree

23 files changed

+1269
-18
lines changed

23 files changed

+1269
-18
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
name: 'New Dev Factory Terraform Module'
3+
about: 'Assign a new Dev Factory tf module implementation task to the GitHub Copilot Coding Agent'
4+
title: 'Implement {module_name}'
5+
labels: 'enhancement'
6+
assignees: 'copilot-swe-agent[bot]'
7+
---
8+
9+
Your goal is to implement the specified terraform module by following the steps below.
10+
11+
## Module to implement
12+
module_name=REPLACE_WITH_MODULE_NAME
13+
14+
## STEPS
15+
1. Read and follow the instructions in `.github/copilot-instructions.md`.
16+
2. Create an implementation plan by running `/1-plan {module_name}`. This follows the prompt in `.github/prompts/1-plan.prompt.md` and outputs a new file: {module_name}.plan.md
17+
3. Implement the created implementation plan by running `/2-implement #file:docs/plans/{module_name}.plan.md`. This follows the prompt in `.github/prompts/2-implement.prompt.md` for the plan created in step 2.

.vscode/mcp.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"servers": {
2+
"servers": {
33
"Terraform MCP Server": {
44
"command": "docker",
55
"args": [

.vscode/tasks.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,9 @@
121121
"examples/dev_center/dual_identity/configuration.tfvars",
122122
"examples/dev_center_project/configuration.tfvars",
123123
"examples/dev_center_environment_type/simple_case/configuration.tfvars",
124-
"examples/dev_center_environment_type/enhanced_case/configuration.tfvars"
124+
"examples/dev_center_environment_type/enhanced_case/configuration.tfvars",
125+
"examples/dev_center_project_environment_type/simple_case/configuration.tfvars",
126+
"examples/dev_center_project_environment_type/enhanced_case/configuration.tfvars"
125127
],
126128
"default": "examples/dev_center/simple_case/configuration.tfvars"
127129
}

CHANGES_SUMMARY.md

Lines changed: 85 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,91 @@
44

55
This document summarizes the updates made to the Azure DevCenter module to implement the 2025-04-01-preview API version and fix the identity block placement.
66

7-
## Latest Changes (July 28, 2025)
7+
## Latest Changes (August 14, 2025)
8+
9+
### Dev Center Project Environment Type Module - API Schema Compliance Fix
10+
11+
- **Fixed**: Resolved Azure API schema validation errors in dev_center_project_environment_type module for userRoleAssignments
12+
- **Classification**: Bug fix
13+
- **Breaking Change**: YES - User role assignments schema changed to match Azure API requirements
14+
- **Issue**: userRoleAssignments.roles was defined as list(string) but Azure API expects map(object({}))
15+
- **Root Cause**: Mismatch between Terraform variable schema and Azure DevCenter REST API schema
16+
- **Azure API Requirement**:
17+
- userRoleAssignments keys must be user object IDs (GUIDs), not email addresses
18+
- roles property must be a map where keys are role definition IDs (GUIDs) and values are objects
19+
- **Solution Applied**:
20+
- Updated module variable schema: `roles = list(string)``roles = map(object({}))`
21+
- Updated root variable schema in `variables.tf` to match module requirements
22+
- Updated all example configurations to use correct API format
23+
- Updated test files to use proper schema structure
24+
- Enhanced README documentation with Azure CLI commands to find required IDs
25+
- **Files Modified**:
26+
- `modules/dev_center_project_environment_type/variables.tf`: Fixed roles type definition
27+
- `modules/dev_center_project_environment_type/README.md`: Added comprehensive documentation for finding user object IDs and role definition IDs
28+
- `variables.tf`: Updated root variable definition to match module schema
29+
- `tests/unit/dev_center_project_environment_type/project_environment_type_test.tftest.hcl`: Updated test to use correct schema
30+
- `examples/dev_center_project_environment_type/enhanced_case/configuration.tfvars`: Updated all user role assignments to use object IDs and role definition IDs
31+
- **Migration Required**:
32+
- Users must update configurations to use Azure AD user object IDs instead of email addresses
33+
- Users must use role definition IDs (GUIDs) instead of role names
34+
- Use `az ad user show --id user@domain.com --query id -o tsv` to get user object IDs
35+
- Use `az role definition list --name "Role Name" --query '[].id' -o tsv` to get role definition IDs
36+
- **Validation**: All unit and integration tests pass (43 total test cases)
37+
- **API Reference**: Based on Azure DevCenter REST API documentation (2025-04-01-preview)
38+
39+
### Dev Center Project Environment Type Module - Critical Fix Applied
40+
41+
- **Fixed**: Resolved API validation errors in dev_center_project_environment_type module
42+
- **Classification**: Bug fix
43+
- **Breaking Change**: NO - Module interface updated but functionality preserved
44+
- **Issue**: DeploymentTargetId was incorrectly using full environment type resource ID instead of subscription ID
45+
- **Root Cause**: Azure DevCenter API requires deploymentTargetId to be subscription ID format `/subscriptions/{guid}`, not full resource ID
46+
- **Solution Applied**:
47+
- Updated `deploymentTargetId` to use subscription ID: `/subscriptions/${data.azapi_client_config.current.subscription_id}`
48+
- Fixed environment type name matching to use actual created environment type names
49+
- Removed unnecessary azurecaf_name resource for project environment types
50+
- Updated module to reference environment type names from parent Dev Center
51+
- **Files Modified**:
52+
- `modules/dev_center_project_environment_type/module.tf`: Fixed deploymentTargetId and name logic
53+
- `modules/dev_center_project_environment_type/variables.tf`: Added environment_type_name variable, updated validation
54+
- `modules/dev_center_project_environment_type/output.tf`: Updated deployment_target_id output description
55+
- `modules/dev_center_project_environment_type/README.md`: Updated usage examples and documentation
56+
- `dev_center_project_environment_types.tf`: Updated module call to pass environment_type_name
57+
- **Validation**: Successfully applied simple case configuration with both development and staging project environment types
58+
- **API Reference**: Based on official Azure DevCenter REST API documentation (2025-04-01-preview)
59+
- **Resources Created**:
60+
- `/subscriptions/.../projects/.../environmentTypes/demo-dcet-development-qgi` (Enabled)
61+
- `/subscriptions/.../projects/.../environmentTypes/demo-dcet-staging-iuo` (Enabled)
62+
63+
### Dev Center Project Environment Type Module - New Implementation
64+
65+
- **Added**: New `dev_center_project_environment_type` module for associating environment types with Dev Center projects
66+
- **Classification**: Feature
67+
- **Breaking Change**: NO - This is a new module that doesn't affect existing functionality
68+
- **Files Added**:
69+
- `modules/dev_center_project_environment_type/module.tf`: Main module implementation using azapi provider
70+
- `modules/dev_center_project_environment_type/variables.tf`: Strong typing with comprehensive validation
71+
- `modules/dev_center_project_environment_type/output.tf`: Output definitions for project environment type properties
72+
- `modules/dev_center_project_environment_type/README.md`: Complete documentation with usage examples
73+
- `dev_center_project_environment_types.tf`: Root orchestration file
74+
- `variables.tf`: Added new variable definition with validation rules
75+
- `examples/dev_center_project_environment_type/simple_case/configuration.tfvars`: Basic example
76+
- `examples/dev_center_project_environment_type/enhanced_case/configuration.tfvars`: Advanced example with user role assignments
77+
- `tests/unit/dev_center_project_environment_type/project_environment_type_test.tftest.hcl`: Unit tests with provider mocking
78+
- **Files Modified**:
79+
- `tests/integration/dev_center_integration_test.tftest.hcl`: Added project environment type integration test
80+
- `.vscode/tasks.json`: Added new example options for VS Code development workflow
81+
- `docs/file_structure.md`: Updated with new module and example locations
82+
- `docs/module_guide.md`: Enhanced with comprehensive usage patterns and configuration options
83+
- **Features**:
84+
- Associates environment types with Dev Center projects using Azure DevCenter 2025-04-01-preview API
85+
- Configurable status (Enabled/Disabled) for project environment types
86+
- User role assignments for granular access control
87+
- Comprehensive validation for all input variables
88+
- Full test coverage with both unit and integration tests
89+
- Complete documentation and examples
90+
91+
## Previous Changes (July 28, 2025)
892

993
### Dev Center Network Connection Module - AzAPI Migration
1094
- **Updated**: Migrated `dev_center_network_connection` module from azurerm to azapi provider

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ The project includes comprehensive documentation to help you understand and use
7878
- [Getting Started Guide](docs/getting_started.md) - Instructions for setting up and deploying your first resources
7979
- [Coding Conventions](docs/conventions.md) - Standards and best practices for the codebase
8080
- [Module Guide](docs/module_guide.md) - Detailed information about each module's functionality and usage
81+
- [Vibe Coding Guide](/docs/vibe_coding.md) - This codebase supports vibe coding! Read this document on how.
82+
- [GitHub Coding Agent Guide](docs/coding_agent.md) - Instructions for using the GitHub Coding Agent
8183

8284
## Requirements
8385

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Dev Center Project Environment Types module instantiation
2+
module "dev_center_project_environment_types" {
3+
source = "./modules/dev_center_project_environment_type"
4+
for_each = try(var.dev_center_project_environment_types, {})
5+
6+
global_settings = var.global_settings
7+
project_environment_type = each.value
8+
dev_center_project_id = lookup(each.value, "dev_center_project_id", null) != null ? each.value.dev_center_project_id : module.dev_center_projects[each.value.project.key].id
9+
environment_type_name = lookup(each.value, "environment_type_name", null) != null ? each.value.environment_type_name : module.dev_center_environment_types[each.value.environment_type.key].name
10+
}

docs/coding_agent.md

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# Using the GitHub Coding Agent with Dev Factory
2+
3+
This documents how to use the GitHub Coding Agent to implement terraform modules.
4+
5+
## Configure MCP Servers
6+
7+
Before starting, go to your `https://github.com/org/repo/settings/copilot/coding_agent` and configure the MCP servers.
8+
9+
```json
10+
{
11+
"mcpServers": {
12+
"Terraform-MCP-Server": {
13+
"type": "local",
14+
"command": "docker",
15+
"args": [
16+
"run",
17+
"-i",
18+
"--rm",
19+
"hashicorp/terraform-mcp-server"
20+
],
21+
"tools": ["*"]
22+
},
23+
"Azure-MCP-Server": {
24+
"type": "local",
25+
"command": "npx",
26+
"args": [
27+
"-y",
28+
"@azure/mcp@0.0.21",
29+
"server",
30+
"start"
31+
],
32+
"tools": ["*"]
33+
}
34+
}
35+
}
36+
```
37+
38+
## Assigning Issues to the GitHub Coding Agent
39+
40+
1. Create a new issue using the [New Dev Factory Terraform Module](/.github/ISSUE_TEMPLATE/new_tf_module.md) template.
41+
42+
2. Replace REPLACE_WITH_MODULE_NAME with the module name that you want to implement. For example `dev_center_project_environment_type`. (Note: This template should automatically assign the issue to `Copilot` with label `enhancement`).
43+
44+
3. Assign the issue to Copilot
45+
46+
4. Click Create
47+
48+
5. Monitor or have a break, wait for GitHub Copilot to finish the implementation
49+
50+
6. Review the PR submitted by Copilot by
51+
1. Fetching the PR code change by the coding agent and opening it in VSCode
52+
2. Switching to the `aztf-agent`
53+
3. and running `/3-apply {module_name}`.
54+
55+
7. If everything is in order, approve and merge the PR, close the issue.

docs/file_structure.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ This section contains specific files/callouts. If the file is not explained here
4949
- **dev_center_catalogs.tf**: Configures catalogs within Dev Centers for organizing DevBox templates.
5050
- **dev_center_dev_box_definitions.tf**: Defines DevBox configurations with VM specifications and images.
5151
- **dev_center_environment_types.tf**: Creates environment types for defining available development environments.
52+
- **dev_center_project_environment_types.tf**: Associates environment types with Dev Center projects, enabling specific environment types within projects.
5253
- **dev_center_network_connections.tf**: Establishes network connectivity between Dev Centers and virtual networks.
5354
- **dev_center_project_pools.tf**: Manages pools of development resources within projects.
5455
- **dev_center_project_pool_schedules.tf**: Configures scheduling for automated pool management and cost optimization.

docs/module_guide.md

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -231,11 +231,10 @@ module "dev_center_project_environment_types" {
231231
source = "./modules/dev_center_project_environment_type"
232232
for_each = var.dev_center_project_environment_types
233233
234-
global_settings = var.global_settings
235-
project_environment_type = each.value
236-
location = lookup(each.value, "location", null) != null ? each.value.location : module.resource_groups[each.value.resource_group.key].location
237-
dev_center_project_id = lookup(each.value, "dev_center_project_id", null) != null ? each.value.dev_center_project_id : module.dev_center_projects[each.value.project.key].id
238-
deployment_target_id = each.value.deployment_target_id
234+
global_settings = var.global_settings
235+
project_environment_type = each.value
236+
dev_center_project_id = lookup(each.value, "dev_center_project_id", null) != null ? each.value.dev_center_project_id : module.dev_center_projects[each.value.project.key].id
237+
deployment_target_id = lookup(each.value, "deployment_target_id", null) != null ? each.value.deployment_target_id : module.dev_center_environment_types[each.value.environment_type.key].id
239238
}
240239
```
241240

@@ -244,28 +243,41 @@ module "dev_center_project_environment_types" {
244243
|----------|------|----------|-------------|
245244
| `global_settings` | `object` | Yes | Global settings for naming and prefixing |
246245
| `project_environment_type` | `object` | Yes | Project environment type configuration object |
247-
| `location` | `string` | Yes | Azure region for deployment |
248246
| `dev_center_project_id` | `string` | Yes | The ID of the project |
249247
| `deployment_target_id` | `string` | Yes | The ID of the deployment target |
250248

251249
### Project Environment Type Configuration Options
252250
```hcl
253251
dev_center_project_environment_types = {
254252
projenvtype1 = {
255-
name = "terraform-env"
253+
name = "development"
256254
project = {
257255
key = "project1"
258256
}
259257
environment_type = {
260258
key = "envtype1"
261259
}
260+
status = "Enabled"
261+
user_role_assignments = {
262+
"developers@contoso.com" = {
263+
roles = ["Deployment Environments User"]
264+
}
265+
}
262266
tags = {
263267
environment = "demo"
264268
}
265269
}
266270
}
267271
```
268272

273+
### Features
274+
- Associates environment types with Dev Center projects
275+
- Configurable status (Enabled/Disabled)
276+
- User role assignments for access control
277+
- Comprehensive input validation
278+
- Support for resource tags
279+
- Compatible with Azure DevCenter 2025-04-01-preview API
280+
269281
## Dev Center Network Connection Module
270282

271283
### Purpose

0 commit comments

Comments
 (0)