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

dev_center_dev_box_definition implementation#15

Merged
arnaudlh merged 4 commits intomicrosoft:mainfrom
raffertyuy:main
May 27, 2025
Merged

dev_center_dev_box_definition implementation#15
arnaudlh merged 4 commits intomicrosoft:mainfrom
raffertyuy:main

Conversation

@raffertyuy
Copy link
Copy Markdown
Contributor

This pull request introduces a new Terraform module for managing Azure Dev Center Dev Box Definitions, along with updates to documentation, examples, and unit tests. The changes focus on enabling the creation and configuration of Dev Box Definitions with customizable settings and improved modularity.

Important

The current implementation assumes usage of the image gallery included in the dev center by default.
An update to this module is required when azurerm_dev_center_gallery is implemented.

Sample Terraform Output

Executing task: /bin/bash -c 'export ARM_SUBSCRIPTION_ID=$(az account show --query id -o tsv) && terraform apply -auto-approve -var-file=examples/dev_center/simple_case/configuration.tfvars' 

module.resource_groups["rg1"].azurecaf_name.resource_group: Refreshing state... [id=tmbpmioqxkocnklr]
module.dev_centers["devcenter1"].azurecaf_name.dev_center: Refreshing state... [id=msnarwmqobmbwqxw]
module.dev_center_dev_box_definitions["definition1"].azurecaf_name.dev_box_definition: Refreshing state... [id=rcubwtoraihdnjef]
module.resource_groups["rg1"].azurerm_resource_group.resource_group: Refreshing state... [id=/subscriptions/33e81e94-c18c-4d5a-a613-897c92b35411/resourceGroups/dev-rg-devfactory-dc-jfr]
module.dev_centers["devcenter1"].azurerm_dev_center.dev_center: Refreshing state... [id=/subscriptions/33e81e94-c18c-4d5a-a613-897c92b35411/resourceGroups/dev-rg-devfactory-dc-jfr/providers/Microsoft.DevCenter/devCenters/dev-devcenter-npv]

Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
  + create
-/+ destroy and then create replacement

Terraform will perform the following actions:

  # module.dev_center_dev_box_definitions["definition1"].azurecaf_name.dev_box_definition must be replaced
-/+ resource "azurecaf_name" "dev_box_definition" {
      ~ id            = "rcubwtoraihdnjef" -> (known after apply)
      ~ name          = "windows11-dev" -> "win11-dev" # forces replacement
      ~ result        = "dev-windows11-dev-cis" -> (known after apply)
      ~ results       = {} -> (known after apply)
        # (7 unchanged attributes hidden)
    }

  # module.dev_center_dev_box_definitions["definition1"].azurerm_dev_center_dev_box_definition.dev_box_definition will be created
  + resource "azurerm_dev_center_dev_box_definition" "dev_box_definition" {
      + dev_center_id      = "/subscriptions/33e81e94-c18c-4d5a-a613-897c92b35411/resourceGroups/dev-rg-devfactory-dc-jfr/providers/Microsoft.DevCenter/devCenters/dev-devcenter-npv"
      + id                 = (known after apply)
      + image_reference_id = "/subscriptions/33e81e94-c18c-4d5a-a613-897c92b35411/resourceGroups/dev-rg-devfactory-dc-jfr/providers/Microsoft.DevCenter/devCenters/dev-devcenter-npv/galleries/default/images/microsoftwindowsdesktop_windows-ent-cpc_win11-24h2-ent-cpc-m365"
      + location           = "australiaeast"
      + name               = (known after apply)
      + sku_name           = "general_i_8c32gb256ssd_v2"
    }

Plan: 2 to add, 0 to change, 1 to destroy.
module.dev_center_dev_box_definitions["definition1"].azurecaf_name.dev_box_definition: Destroying... [id=rcubwtoraihdnjef]
module.dev_center_dev_box_definitions["definition1"].azurecaf_name.dev_box_definition: Destruction complete after 0s
module.dev_center_dev_box_definitions["definition1"].azurecaf_name.dev_box_definition: Creating...
module.dev_center_dev_box_definitions["definition1"].azurecaf_name.dev_box_definition: Creation complete after 0s [id=ijqjcbabikcrfwoq]
module.dev_center_dev_box_definitions["definition1"].azurerm_dev_center_dev_box_definition.dev_box_definition: Creating...
module.dev_center_dev_box_definitions["definition1"].azurerm_dev_center_dev_box_definition.dev_box_definition: Still creating... [10s elapsed]
module.dev_center_dev_box_definitions["definition1"].azurerm_dev_center_dev_box_definition.dev_box_definition: Still creating... [20s elapsed]
module.dev_center_dev_box_definitions["definition1"].azurerm_dev_center_dev_box_definition.dev_box_definition: Still creating... [30s elapsed]
module.dev_center_dev_box_definitions["definition1"].azurerm_dev_center_dev_box_definition.dev_box_definition: Still creating... [40s elapsed]
module.dev_center_dev_box_definitions["definition1"].azurerm_dev_center_dev_box_definition.dev_box_definition: Still creating... [50s elapsed]
module.dev_center_dev_box_definitions["definition1"].azurerm_dev_center_dev_box_definition.dev_box_definition: Creation complete after 1m0s [id=/subscriptions/33e81e94-c18c-4d5a-a613-897c92b35411/resourceGroups/dev-rg-devfactory-dc-jfr/providers/Microsoft.DevCenter/devCenters/dev-devcenter-npv/devBoxDefinitions/dev-win11-dev-xos]

Apply complete! Resources: 2 added, 0 changed, 1 destroyed.

image

raffertyuy and others added 3 commits May 9, 2025 16:35
Bumps the actions group with 3 updates: [actions/checkout](https://github.com/actions/checkout), [terraform-linters/setup-tflint](https://github.com/terraform-linters/setup-tflint) and [hashicorp/setup-terraform](https://github.com/hashicorp/setup-terraform).


Updates `actions/checkout` from 3 to 4
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](actions/checkout@v3...v4)

Updates `terraform-linters/setup-tflint` from 3 to 4
- [Release notes](https://github.com/terraform-linters/setup-tflint/releases)
- [Commits](terraform-linters/setup-tflint@v3...v4)

Updates `hashicorp/setup-terraform` from 2 to 3
- [Release notes](https://github.com/hashicorp/setup-terraform/releases)
- [Changelog](https://github.com/hashicorp/setup-terraform/blob/main/CHANGELOG.md)
- [Commits](hashicorp/setup-terraform@v2...v3)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-version: '4'
  dependency-type: direct:production
  update-type: version-update:semver-major
  dependency-group: actions
- dependency-name: terraform-linters/setup-tflint
  dependency-version: '4'
  dependency-type: direct:production
  update-type: version-update:semver-major
  dependency-group: actions
- dependency-name: hashicorp/setup-terraform
  dependency-version: '3'
  dependency-type: direct:production
  update-type: version-update:semver-major
  dependency-group: actions
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Arnaud Lheureux <arnaudlh@users.noreply.github.com>
@raffertyuy raffertyuy requested review from arnaudlh and Copilot May 9, 2025 14:20
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds a new Terraform module for creating Azure Dev Center Dev Box Definitions, updates documentation and examples to reflect the new image_reference_id pattern, and introduces unit tests to validate module outputs.

  • Introduce modules/dev_center_dev_box_definition with variable, resource, and output definitions
  • Add HCL-based unit tests under tests/unit/dev_center_dev_box_definition
  • Update examples and module guide to use image_reference_id instead of the old image blocks

Reviewed Changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
tests/unit/dev_center_dev_box_definition/dev_box_definition_test.tftest.hcl New unit tests for module outputs
modules/dev_center_dev_box_definition/variables.tf Define inputs for dev box definition including name, image, sku
modules/dev_center_dev_box_definition/module.tf Create azurecaf_name and azurerm_dev_center_dev_box_definition
modules/dev_center_dev_box_definition/output.tf Output the Dev Box Definition's ID
examples/dev_center_dev_box_definition/configuration.tfvars Example configuration for the new module
examples/dev_center/simple_case/configuration.tfvars Extended simple-case example with dev box definition
docs/module_guide.md Replace old image block with image_reference_id
dev_center_dev_box_definitions.tf Instantiate the new module in the root configuration
Comments suppressed due to low confidence (4)

docs/module_guide.md:132

  • The documentation shows a hibernate_support block, but the module does not accept or forward this setting. Either implement an input for hibernate_support in variables.tf and pass it through, or remove this example from the guide.
hibernate_support = {

tests/unit/dev_center_dev_box_definition/dev_box_definition_test.tftest.hcl:41

  • In the test variables block, var.dev_box_definition is undefined. Replace this with a direct string value for image_reference_id or reference the correct variable path under var.dev_center_dev_box_definitions.
image_reference_id = try(var.dev_box_definition.image_reference_id, null)

tests/unit/dev_center_dev_box_definition/dev_box_definition_test.tftest.hcl:42

  • Similar to the previous assertion, var.dev_box_definition does not exist in this context. Use the defined dev_center_dev_box_definitions.definition1.sku_name value directly.
sku_name           = try(var.dev_box_definition.sku_name, null)

modules/dev_center_dev_box_definition/output.tf:1

  • The module does not currently output the resource name, causing tests that assert on module.dev_center_dev_box_definitions["definition1"].name to fail. Add an output for name (e.g., value = azurecaf_name.dev_box_definition.result).
output "id" {

Comment thread modules/dev_center_dev_box_definition/module.tf Outdated
@arnaudlh arnaudlh requested a review from Copilot May 21, 2025 00:34

This comment was marked as duplicate.

@arnaudlh arnaudlh requested a review from Copilot May 22, 2025 08:28
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds a new Terraform module for Azure Dev Center Dev Box Definitions, complete with input variables, resource implementation, outputs, unit tests, examples, and documentation updates.

  • Introduces dev_center_dev_box_definition module (variables, implementation, output)
  • Adds unit tests and example configuration for the new module
  • Updates documentation and root module instantiation to wire up the new module

Reviewed Changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
modules/dev_center_dev_box_definition/variables.tf Defines the input schema for Dev Box Definition
modules/dev_center_dev_box_definition/module.tf Implements the azurerm_dev_center_dev_box_definition resource
modules/dev_center_dev_box_definition/output.tf Exposes the Dev Box Definition ID as module output
tests/unit/dev_center_dev_box_definition/dev_box_definition_test.tftest.hcl Adds unit tests to validate name, ID, and tags outputs
examples/dev_center_dev_box_definition/configuration.tfvars Provides a sample variable file illustrating how to configure the module
docs/module_guide.md Updates the module guide example to reflect the new image_reference_id input
dev_center_dev_box_definitions.tf Instantiates the new module in the root Terraform configuration
.github/copilot-instructions.md Minor cleanup in Copilot instructions (nonfunctional)
Comments suppressed due to low confidence (3)

docs/module_guide.md:132

  • The example includes 'hibernate_support', but this parameter is not defined in the module's variables. Either remove it from the example or add support in the module.
      hibernate_support = {

tests/unit/dev_center_dev_box_definition/dev_box_definition_test.tftest.hcl:69

  • [nitpick] Consider adding assertions to verify that 'image_reference_id' and 'sku_name' are correctly passed through and available in the module outputs.
  assert {

tests/unit/dev_center_dev_box_definition/dev_box_definition_test.tftest.hcl:41

  • In the test variables block, 'var.dev_box_definition' is not defined in this scope. You should reference the literal value set above (e.g. the string provided to dev_center_dev_box_definitions.definition1.image_reference_id) or define a matching variable.
      image_reference_id = try(var.dev_box_definition.image_reference_id, null)

for_each = try(var.dev_center_dev_box_definitions, {})

global_settings = var.global_settings
dev_box_definition = each.value
Copy link

Copilot AI May 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The module variable 'dev_box_definition' expects an object with only name, image_reference_id, sku_name, and optional tags, but 'each.value' also contains 'dev_center' and 'resource_group' keys. Either adjust the module signature to accept those keys or pass a filtered object matching the expected schema.

Suggested change
dev_box_definition = each.value
dev_box_definition = {
name = each.value.name
image_reference_id = each.value.image_reference_id
sku_name = each.value.sku_name
tags = lookup(each.value, "tags", null)
}

Copilot uses AI. Check for mistakes.
@@ -0,0 +1,35 @@
variable "global_settings" {
description = "Global settings object"
type = object({
Copy link

Copilot AI May 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The 'global_settings' variable here omits fields like 'environment' and 'regions' required by the project's standard global_settings object. Update its type to match the shared global_settings definition for consistency.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Collaborator

@arnaudlh arnaudlh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@arnaudlh arnaudlh merged commit 7f54562 into microsoft:main May 27, 2025
16 checks passed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants