Skip to content
This repository was archived by the owner on Apr 6, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions .github/ISSUE_TEMPLATE/new_tf_module.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
name: 'New Dev Factory Terraform Module'
about: 'Assign a new Dev Factory tf module implementation task to the GitHub Copilot Coding Agent'
title: 'Implement {module_name}'
labels: 'enhancement'
assignees: 'copilot-swe-agent[bot]'
---

Your goal is to implement the specified terraform module by following the steps below.

## Module to implement
module_name=REPLACE_WITH_MODULE_NAME

## STEPS
1. Read and follow the instructions in `.github/copilot-instructions.md`.
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
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.
2 changes: 1 addition & 1 deletion .vscode/mcp.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"servers": {
"servers": {
"Terraform MCP Server": {
"command": "docker",
"args": [
Expand Down
4 changes: 3 additions & 1 deletion .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,9 @@
"examples/dev_center/dual_identity/configuration.tfvars",
"examples/dev_center_project/configuration.tfvars",
"examples/dev_center_environment_type/simple_case/configuration.tfvars",
"examples/dev_center_environment_type/enhanced_case/configuration.tfvars"
"examples/dev_center_environment_type/enhanced_case/configuration.tfvars",
"examples/dev_center_project_environment_type/simple_case/configuration.tfvars",
"examples/dev_center_project_environment_type/enhanced_case/configuration.tfvars"
],
"default": "examples/dev_center/simple_case/configuration.tfvars"
}
Expand Down
86 changes: 85 additions & 1 deletion CHANGES_SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,91 @@

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.

## Latest Changes (July 28, 2025)
## Latest Changes (August 14, 2025)

### Dev Center Project Environment Type Module - API Schema Compliance Fix

- **Fixed**: Resolved Azure API schema validation errors in dev_center_project_environment_type module for userRoleAssignments
- **Classification**: Bug fix
- **Breaking Change**: YES - User role assignments schema changed to match Azure API requirements
- **Issue**: userRoleAssignments.roles was defined as list(string) but Azure API expects map(object({}))
- **Root Cause**: Mismatch between Terraform variable schema and Azure DevCenter REST API schema
- **Azure API Requirement**:
- userRoleAssignments keys must be user object IDs (GUIDs), not email addresses
- roles property must be a map where keys are role definition IDs (GUIDs) and values are objects
- **Solution Applied**:
- Updated module variable schema: `roles = list(string)` → `roles = map(object({}))`
- Updated root variable schema in `variables.tf` to match module requirements
- Updated all example configurations to use correct API format
- Updated test files to use proper schema structure
- Enhanced README documentation with Azure CLI commands to find required IDs
- **Files Modified**:
- `modules/dev_center_project_environment_type/variables.tf`: Fixed roles type definition
- `modules/dev_center_project_environment_type/README.md`: Added comprehensive documentation for finding user object IDs and role definition IDs
- `variables.tf`: Updated root variable definition to match module schema
- `tests/unit/dev_center_project_environment_type/project_environment_type_test.tftest.hcl`: Updated test to use correct schema
- `examples/dev_center_project_environment_type/enhanced_case/configuration.tfvars`: Updated all user role assignments to use object IDs and role definition IDs
- **Migration Required**:
- Users must update configurations to use Azure AD user object IDs instead of email addresses
- Users must use role definition IDs (GUIDs) instead of role names
- Use `az ad user show --id user@domain.com --query id -o tsv` to get user object IDs
- Use `az role definition list --name "Role Name" --query '[].id' -o tsv` to get role definition IDs
- **Validation**: All unit and integration tests pass (43 total test cases)
- **API Reference**: Based on Azure DevCenter REST API documentation (2025-04-01-preview)

### Dev Center Project Environment Type Module - Critical Fix Applied

- **Fixed**: Resolved API validation errors in dev_center_project_environment_type module
- **Classification**: Bug fix
- **Breaking Change**: NO - Module interface updated but functionality preserved
- **Issue**: DeploymentTargetId was incorrectly using full environment type resource ID instead of subscription ID
- **Root Cause**: Azure DevCenter API requires deploymentTargetId to be subscription ID format `/subscriptions/{guid}`, not full resource ID
- **Solution Applied**:
- Updated `deploymentTargetId` to use subscription ID: `/subscriptions/${data.azapi_client_config.current.subscription_id}`
- Fixed environment type name matching to use actual created environment type names
- Removed unnecessary azurecaf_name resource for project environment types
- Updated module to reference environment type names from parent Dev Center
- **Files Modified**:
- `modules/dev_center_project_environment_type/module.tf`: Fixed deploymentTargetId and name logic
- `modules/dev_center_project_environment_type/variables.tf`: Added environment_type_name variable, updated validation
- `modules/dev_center_project_environment_type/output.tf`: Updated deployment_target_id output description
- `modules/dev_center_project_environment_type/README.md`: Updated usage examples and documentation
- `dev_center_project_environment_types.tf`: Updated module call to pass environment_type_name
- **Validation**: Successfully applied simple case configuration with both development and staging project environment types
- **API Reference**: Based on official Azure DevCenter REST API documentation (2025-04-01-preview)
- **Resources Created**:
- `/subscriptions/.../projects/.../environmentTypes/demo-dcet-development-qgi` (Enabled)
- `/subscriptions/.../projects/.../environmentTypes/demo-dcet-staging-iuo` (Enabled)

### Dev Center Project Environment Type Module - New Implementation

- **Added**: New `dev_center_project_environment_type` module for associating environment types with Dev Center projects
- **Classification**: Feature
- **Breaking Change**: NO - This is a new module that doesn't affect existing functionality
- **Files Added**:
- `modules/dev_center_project_environment_type/module.tf`: Main module implementation using azapi provider
- `modules/dev_center_project_environment_type/variables.tf`: Strong typing with comprehensive validation
- `modules/dev_center_project_environment_type/output.tf`: Output definitions for project environment type properties
- `modules/dev_center_project_environment_type/README.md`: Complete documentation with usage examples
- `dev_center_project_environment_types.tf`: Root orchestration file
- `variables.tf`: Added new variable definition with validation rules
- `examples/dev_center_project_environment_type/simple_case/configuration.tfvars`: Basic example
- `examples/dev_center_project_environment_type/enhanced_case/configuration.tfvars`: Advanced example with user role assignments
- `tests/unit/dev_center_project_environment_type/project_environment_type_test.tftest.hcl`: Unit tests with provider mocking
- **Files Modified**:
- `tests/integration/dev_center_integration_test.tftest.hcl`: Added project environment type integration test
- `.vscode/tasks.json`: Added new example options for VS Code development workflow
- `docs/file_structure.md`: Updated with new module and example locations
- `docs/module_guide.md`: Enhanced with comprehensive usage patterns and configuration options
- **Features**:
- Associates environment types with Dev Center projects using Azure DevCenter 2025-04-01-preview API
- Configurable status (Enabled/Disabled) for project environment types
- User role assignments for granular access control
- Comprehensive validation for all input variables
- Full test coverage with both unit and integration tests
- Complete documentation and examples

## Previous Changes (July 28, 2025)

### Dev Center Network Connection Module - AzAPI Migration
- **Updated**: Migrated `dev_center_network_connection` module from azurerm to azapi provider
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ The project includes comprehensive documentation to help you understand and use
- [Getting Started Guide](docs/getting_started.md) - Instructions for setting up and deploying your first resources
- [Coding Conventions](docs/conventions.md) - Standards and best practices for the codebase
- [Module Guide](docs/module_guide.md) - Detailed information about each module's functionality and usage
- [Vibe Coding Guide](/docs/vibe_coding.md) - This codebase supports vibe coding! Read this document on how.
- [GitHub Coding Agent Guide](docs/coding_agent.md) - Instructions for using the GitHub Coding Agent

## Requirements

Expand Down
10 changes: 10 additions & 0 deletions dev_center_project_environment_types.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Dev Center Project Environment Types module instantiation
module "dev_center_project_environment_types" {
source = "./modules/dev_center_project_environment_type"
for_each = try(var.dev_center_project_environment_types, {})

global_settings = var.global_settings
project_environment_type = each.value
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
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
}
55 changes: 55 additions & 0 deletions docs/coding_agent.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Using the GitHub Coding Agent with Dev Factory

This documents how to use the GitHub Coding Agent to implement terraform modules.

## Configure MCP Servers

Before starting, go to your `https://github.com/org/repo/settings/copilot/coding_agent` and configure the MCP servers.

```json
{
"mcpServers": {
"Terraform-MCP-Server": {
"type": "local",
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"hashicorp/terraform-mcp-server"
],
"tools": ["*"]
},
"Azure-MCP-Server": {
"type": "local",
"command": "npx",
"args": [
"-y",
"@azure/mcp@0.0.21",
"server",
"start"
],
"tools": ["*"]
}
}
}
```

## Assigning Issues to the GitHub Coding Agent

1. Create a new issue using the [New Dev Factory Terraform Module](/.github/ISSUE_TEMPLATE/new_tf_module.md) template.

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`).

3. Assign the issue to Copilot

4. Click Create

5. Monitor or have a break, wait for GitHub Copilot to finish the implementation

6. Review the PR submitted by Copilot by
1. Fetching the PR code change by the coding agent and opening it in VSCode
2. Switching to the `aztf-agent`
3. and running `/3-apply {module_name}`.

7. If everything is in order, approve and merge the PR, close the issue.
1 change: 1 addition & 0 deletions docs/file_structure.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ This section contains specific files/callouts. If the file is not explained here
- **dev_center_catalogs.tf**: Configures catalogs within Dev Centers for organizing DevBox templates.
- **dev_center_dev_box_definitions.tf**: Defines DevBox configurations with VM specifications and images.
- **dev_center_environment_types.tf**: Creates environment types for defining available development environments.
- **dev_center_project_environment_types.tf**: Associates environment types with Dev Center projects, enabling specific environment types within projects.
- **dev_center_network_connections.tf**: Establishes network connectivity between Dev Centers and virtual networks.
- **dev_center_project_pools.tf**: Manages pools of development resources within projects.
- **dev_center_project_pool_schedules.tf**: Configures scheduling for automated pool management and cost optimization.
Expand Down
26 changes: 19 additions & 7 deletions docs/module_guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -231,11 +231,10 @@ module "dev_center_project_environment_types" {
source = "./modules/dev_center_project_environment_type"
for_each = var.dev_center_project_environment_types

global_settings = var.global_settings
project_environment_type = each.value
location = lookup(each.value, "location", null) != null ? each.value.location : module.resource_groups[each.value.resource_group.key].location
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
deployment_target_id = each.value.deployment_target_id
global_settings = var.global_settings
project_environment_type = each.value
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
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
}
```

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

### Project Environment Type Configuration Options
```hcl
dev_center_project_environment_types = {
projenvtype1 = {
name = "terraform-env"
name = "development"
project = {
key = "project1"
}
environment_type = {
key = "envtype1"
}
status = "Enabled"
user_role_assignments = {
"developers@contoso.com" = {
roles = ["Deployment Environments User"]
}
}
tags = {
environment = "demo"
}
}
}
```

### Features
- Associates environment types with Dev Center projects
- Configurable status (Enabled/Disabled)
- User role assignments for access control
- Comprehensive input validation
- Support for resource tags
- Compatible with Azure DevCenter 2025-04-01-preview API

## Dev Center Network Connection Module

### Purpose
Expand Down
Loading