This repository was archived by the owner on Apr 6, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
dev_center_dev_box_definition implementation #15
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| # Dev Center Dev Box Definitions module instantiation | ||
| module "dev_center_dev_box_definitions" { | ||
| source = "./modules/dev_center_dev_box_definition" | ||
| for_each = try(var.dev_center_dev_box_definitions, {}) | ||
|
|
||
| global_settings = var.global_settings | ||
| dev_box_definition = each.value | ||
| dev_center_id = lookup(each.value, "dev_center_id", null) != null ? each.value.dev_center_id : module.dev_centers[each.value.dev_center.key].id | ||
| location = lookup(each.value, "region", null) != null ? each.value.region : module.resource_groups[each.value.resource_group.key].location | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,4 +23,4 @@ dev_centers = { | |
| module = "dev_center" | ||
| } | ||
| } | ||
| } | ||
| } | ||
53 changes: 53 additions & 0 deletions
53
examples/dev_center_dev_box_definition/configuration.tfvars
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| global_settings = { | ||
| prefixes = ["dev"] | ||
| random_length = 3 | ||
| passthrough = false | ||
| use_slug = true | ||
| } | ||
|
|
||
| resource_groups = { | ||
| rg1 = { | ||
| name = "devfactory-dc" | ||
| region = "eastus" | ||
| tags = { | ||
| environment = "development" | ||
| workload = "devbox-example" | ||
| } | ||
| } | ||
| } | ||
|
|
||
| dev_centers = { | ||
| devcenter1 = { | ||
| name = "devcenter" | ||
| resource_group = { | ||
| key = "rg1" | ||
| } | ||
| identity = { | ||
| type = "SystemAssigned" | ||
| } | ||
| tags = { | ||
| environment = "demo" | ||
| module = "dev_center" | ||
| } | ||
| } | ||
| } | ||
|
|
||
| dev_center_dev_box_definitions = { | ||
| definition1 = { | ||
| name = "win11-dev" | ||
| dev_center = { | ||
| key = "devcenter1" | ||
| } | ||
| resource_group = { | ||
| key = "rg1" | ||
| } | ||
| # Currently assumes that image definition is one of that's available in the default gallery | ||
| # Format: /galleries/{gallery}/images/{image-definition} | ||
| image_reference_id = "/galleries/default/images/microsoftwindowsdesktop_windows-ent-cpc_win11-24h2-ent-cpc-m365" | ||
| sku_name = "general_i_8c32gb256ssd_v2" | ||
| tags = { | ||
| environment = "demo" | ||
| module = "dev_center_dev_box_definition" | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| terraform { | ||
| required_version = ">= 1.9.0" | ||
| required_providers { | ||
| azurecaf = { | ||
| source = "aztfmod/azurecaf" | ||
| version = "~> 1.2.0" | ||
| } | ||
| azurerm = { | ||
| source = "hashicorp/azurerm" | ||
| version = "~> 4.26.0" | ||
| } | ||
| } | ||
| } | ||
|
|
||
| locals {} | ||
|
|
||
| resource "azurecaf_name" "dev_box_definition" { | ||
| name = var.dev_box_definition.name | ||
| resource_type = "general" | ||
| prefixes = var.global_settings.prefixes | ||
| random_length = var.global_settings.random_length | ||
| clean_input = true | ||
| passthrough = var.global_settings.passthrough | ||
| use_slug = var.global_settings.use_slug | ||
| } | ||
|
|
||
| resource "azurerm_dev_center_dev_box_definition" "dev_box_definition" { | ||
| name = azurecaf_name.dev_box_definition.result | ||
| location = var.location | ||
| dev_center_id = var.dev_center_id | ||
| image_reference_id = var.dev_box_definition.image_reference_id != null ? "${var.dev_center_id}${var.dev_box_definition.image_reference_id}" : null | ||
| sku_name = try(var.dev_box_definition.sku_name, null) | ||
| tags = try(var.tags, null) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| output "id" { | ||
| description = "The ID of the Dev Center Dev Box Definition" | ||
| value = azurerm_dev_center_dev_box_definition.dev_box_definition.id | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| variable "global_settings" { | ||
| description = "Global settings object" | ||
| type = object({ | ||
|
||
| prefixes = optional(list(string)) | ||
| random_length = optional(number) | ||
| passthrough = optional(bool) | ||
| use_slug = optional(bool) | ||
| }) | ||
| } | ||
|
|
||
| variable "dev_center_id" { | ||
| description = "The ID of the Dev Center in which to create the project" | ||
| type = string | ||
| } | ||
|
|
||
| variable "location" { | ||
| description = "The location/region where the Dev Center Project is created" | ||
| type = string | ||
| } | ||
|
|
||
| variable "tags" { | ||
| description = "A mapping of tags to assign to the resource" | ||
| type = map(string) | ||
| default = {} | ||
| } | ||
|
|
||
| variable "dev_box_definition" { | ||
| description = "Configuration object for the Dev Box Definition" | ||
| type = object({ | ||
| name = string | ||
| image_reference_id = string | ||
| sku_name = string | ||
| tags = optional(map(string)) | ||
| }) | ||
| } | ||
88 changes: 88 additions & 0 deletions
88
tests/unit/dev_center_dev_box_definition/dev_box_definition_test.tftest.hcl
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,88 @@ | ||
| variables { | ||
| global_settings = { | ||
| prefixes = ["dev"] | ||
| random_length = 3 | ||
| passthrough = false | ||
| use_slug = true | ||
| } | ||
|
|
||
| resource_groups = { | ||
| rg1 = { | ||
| name = "test-resource-group" | ||
| region = "eastus" | ||
| tags = { | ||
| environment = "test" | ||
| } | ||
| } | ||
| } | ||
|
|
||
| dev_centers = { | ||
| devcenter1 = { | ||
| name = "test-dev-center" | ||
| resource_group = { | ||
| key = "rg1" | ||
| } | ||
| tags = { | ||
| environment = "test" | ||
| module = "dev_center" | ||
| } | ||
| } | ||
| } | ||
|
|
||
| dev_center_dev_box_definitions = { | ||
| definition1 = { | ||
| name = "test-dev-box-definition" | ||
| dev_center = { | ||
| key = "devcenter1" | ||
| } | ||
| resource_group = { | ||
| key = "rg1" | ||
| } | ||
| image_reference_id = try(var.dev_box_definition.image_reference_id, null) | ||
| sku_name = try(var.dev_box_definition.sku_name, null) | ||
| tags = { | ||
| environment = "test" | ||
| module = "dev_center_dev_box_definition" | ||
| } | ||
| } | ||
| } | ||
|
|
||
| // Empty variables required by the root module | ||
| dev_center_galleries = {} | ||
| dev_center_projects = {} | ||
| dev_center_environment_types = {} | ||
| dev_center_project_environment_types = {} | ||
| dev_center_network_connections = {} | ||
| dev_center_catalogs = {} | ||
| shared_image_galleries = {} | ||
| } | ||
|
|
||
| mock_provider "azurerm" {} | ||
|
|
||
| run "dev_box_definition_creation" { | ||
| command = plan | ||
|
|
||
| module { | ||
| source = "../../../" | ||
| } | ||
|
|
||
| assert { | ||
| condition = module.dev_center_dev_box_definitions["definition1"].name != "" | ||
| error_message = "Dev Box Definition name should not be empty" | ||
| } | ||
|
|
||
| assert { | ||
| condition = contains(keys(module.dev_center_dev_box_definitions["definition1"]), "id") | ||
| error_message = "Dev Box Definition ID should be present in module outputs" | ||
| } | ||
|
|
||
| assert { | ||
| condition = contains(keys(module.dev_center_dev_box_definitions["definition1"].tags), "environment") | ||
| error_message = "Dev Box Definition tags did not contain environment tag" | ||
| } | ||
|
|
||
| assert { | ||
| condition = contains(keys(module.dev_center_dev_box_definitions["definition1"].tags), "module") | ||
| error_message = "Dev Box Definition tags did not contain module tag" | ||
| } | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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.