https://github.com/libre-devops/terraform-azapi-managed-devops-pool
A module used to deploy Managed DevOps pools for Azure & Azure DevOps 🚀
https://github.com/libre-devops/terraform-azapi-managed-devops-pool
Last synced: about 1 month ago
JSON representation
A module used to deploy Managed DevOps pools for Azure & Azure DevOps 🚀
- Host: GitHub
- URL: https://github.com/libre-devops/terraform-azapi-managed-devops-pool
- Owner: libre-devops
- License: mit
- Created: 2025-02-25T20:43:04.000Z (about 2 months ago)
- Default Branch: main
- Last Pushed: 2025-03-08T22:36:32.000Z (about 2 months ago)
- Last Synced: 2025-03-08T23:24:12.456Z (about 2 months ago)
- Language: PowerShell
- Size: 20.5 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
```hcl
resource "azapi_resource" "managed_devops_pool" {
type = var.managed_pool_api_version
body = {
properties = {
devCenterProjectResourceId = var.dev_center_project_resource_id
maximumConcurrency = var.maximum_concurrency
organizationProfile = {
kind = local.version_control_system_type
organizations = local.organization_profile.organizations
permissionProfile = local.organization_profile.permission_profile
}agentProfile = local.agent_profile
fabricProfile = {
sku = {
name = var.fabric_profile_sku_name
}
images = [for image in var.fabric_profile_images : {
wellKnownImageName = image.well_known_image_name
aliases = image.aliases
buffer = image.buffer
resourceId = image.resource_id
}]networkProfile = var.subnet_id != null ? {
subnetId = var.subnet_id
} : null
osProfile = {
logonType = var.fabric_profile_os_profile_logon_type
}
storageProfile = {
osDiskStorageAccountType = var.fabric_profile_os_disk_storage_account_type
dataDisks = [for data_disk in var.fabric_profile_data_disks : {
diskSizeGiB = data_disk.disk_size_gigabytes
caching = data_disk.caching
driveLetter = data_disk.drive_letter
storageAccountType = data_disk.storage_account_type
}]
}
kind = "Vmss"
}
}
}
location = var.location
name = var.name
parent_id = var.rg_id
schema_validation_enabled = false
tags = var.tagsdynamic "identity" {
for_each = length(var.identity_ids) == 0 && var.identity_type == "SystemAssigned" ? [var.identity_type] : []
content {
type = var.identity_type
}
}dynamic "identity" {
for_each = var.identity_type == "UserAssigned" ? [var.identity_type] : []
content {
type = var.identity_type
identity_ids = length(var.identity_ids) > 0 ? var.identity_ids : []
}
}dynamic "identity" {
for_each = var.identity_type == "SystemAssigned, UserAssigned" ? [var.identity_type] : []
content {
type = var.identity_type
identity_ids = length(var.identity_ids) > 0 ? var.identity_ids : []
}
}}
```
## RequirementsNo requirements.
## Providers
| Name | Version |
|------|---------|
| [azapi](#provider\_azapi) | n/a |## Modules
No modules.
## Resources
| Name | Type |
|------|------|
| [azapi_resource.managed_devops_pool](https://registry.terraform.io/providers/Azure/azapi/latest/docs/resources/resource) | resource |## Inputs
| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| [agent\_profile\_grace\_period\_time\_span](#input\_agent\_profile\_grace\_period\_time\_span) | How long should the stateful machines be kept around. Maximum value is 7 days and the format must be in `d:hh:mm:ss`. | `string` | `null` | no |
| [agent\_profile\_kind](#input\_agent\_profile\_kind) | The kind of agent profile. | `string` | `"Stateless"` | no |
| [agent\_profile\_max\_agent\_lifetime](#input\_agent\_profile\_max\_agent\_lifetime) | The maximum lifetime of the agent. Maximum value is 7 days and the format must be in `d:hh:mm:ss`. | `string` | `null` | no |
| [agent\_profile\_resource\_prediction\_profile](#input\_agent\_profile\_resource\_prediction\_profile) | The resource prediction profile for the agent, a.k.a `Stand by agent mode`, supported values are 'Off', 'Manual', 'Automatic', defaults to 'Off'. | `string` | `"Off"` | no |
| [agent\_profile\_resource\_prediction\_profile\_automatic](#input\_agent\_profile\_resource\_prediction\_profile\_automatic) | The automatic resource prediction profile for the agent.
The object can have the following attributes:
- `kind` - (Required) The kind of prediction profile. Default is "Automatic".
- `prediction_preference` - (Required) The preference for resource prediction. Supported values are `Balanced`, `MostCostEffective`, `MoreCostEffective`, `MorePerformance`, and `BestPerformance`. |object({|
kind = optional(string, "Automatic")
prediction_preference = optional(string, "Balanced")
}){| no |
"kind": "Automatic",
"prediction_preference": "Balanced"
}
| [agent\_profile\_resource\_prediction\_profile\_manual](#input\_agent\_profile\_resource\_prediction\_profile\_manual) | The manual resource prediction profile for the agent. |object({|
kind = string
}){| no |
"kind": "Manual"
}
| [agent\_profile\_resource\_predictions\_manual](#input\_agent\_profile\_resource\_predictions\_manual) | An object representing manual resource predictions for agent profiles, including time zone and optional daily schedules.
- `time_zone` - (Optional) The time zone for the agent profile. E.g. "Eastern Standard Time". Defaults to `UTC`. To see valid values for this run this command in PowerShell: `[System.TimeZoneInfo]::GetSystemTimeZones() | Select Id, BaseUtcOffSet`
- `days_data` - (Optional) A list representing the manual schedules. Defaults to a single standby agent constantly running.
The `days_data` list should contain one or seven maps. Supply one to apply the same schedule each day. Supply seven for a different schedule each day.
Examples:
- To set always having 1 agent available, you would use the following configuration:hcl- To set the schedule for every day to scale to one agent at 8:00 AM and scale down to zero agents at 5:00 PM, you would use the following configuration:
agent_profile_resource_predictions_manual = {
days_data = [
{
"00:00:00" = 1
}
]
}hcl- To set a different schedule for each day, you would use the following configuration:
agent_profile_resource_predictions_manual = {
time_zone = "Eastern Standard Time"
days_data = [
{
"08:00:00" = 1
"17:00:00" = 0
}
]
}hcl|
agent_profile_resource_predictions_manual = {
time_zone = "Eastern Standard Time"
days_data = [
# Sunday
{}, # Empty map to skip Sunday
# Monday
{
"03:00:00" = 2 # Scale to 2 agents at 3:00 AM
"08:00:00" = 4 # Scale to 4 agents at 8:00 AM
"17:00:00" = 2 # Scale to 2 agents at 5:00 PM
"22:00:00" = 0 # Scale to 0 agents at 10:00 PM
},
# Tuesday
{
"08:00:00" = 2
"17:00:00" = 0
},
# Wednesday
{
"08:00:00" = 2
"17:00:00" = 0
},
# Thursday
{
"08:00:00" = 2
"17:00:00" = 0
},
# Friday
{
"08:00:00" = 2
"17:00:00" = 0
},
# Saturday
{} # Empty map to skip Saturday
]
}object({|
time_zone = optional(string, "UTC")
days_data = optional(list(map(number)))
}){| no |
"days_data": [
{
"00:00:00": 1
}
]
}
| [dev\_center\_project\_resource\_id](#input\_dev\_center\_project\_resource\_id) | (Required) The resource ID of the Dev Center project. | `string` | n/a | yes |
| [fabric\_profile\_data\_disks](#input\_fabric\_profile\_data\_disks) | A list of objects representing the configuration for fabric profile data disks.
- `caching` - (Optional) The caching setting for the data disk. Valid values are `None`, `ReadOnly`, and `ReadWrite`. Defaults to `ReadWrite`.
- `disk_size_gigabytes` - (Optional) The size of the data disk in GiB. Defaults to 100GB.
- `drive_letter` - (Optional) The drive letter for the data disk, If you have any Windows agent images in your pool, choose a drive letter for your disk. If you don't specify a drive letter, `F` is used for VM sizes with a temporary disk; otherwise `E` is used. The drive letter must be a single letter except A, C, D, or E. If you are using a VM size without a temporary disk and want `E` as your drive letter, leave Drive Letter empty to get the default value of `E`.
- `storage_account_type` - (Optional) The storage account type for the data disk. Defaults to "Premium\_ZRS".
Valid values for `storage_account_type` are:
- `Premium_LRS`
- `Premium_ZRS`
- `StandardSSD_LRS`
- `Standard_LRS` |list(object({| `[]` | no |
caching = optional(string, "ReadWrite")
disk_size_gigabytes = optional(number, 100)
drive_letter = optional(string, null)
storage_account_type = optional(string, "Premium_ZRS")
}))
| [fabric\_profile\_images](#input\_fabric\_profile\_images) | The list of images to use for the fabric profile.
Each object in the list can have the following attributes:
- `resource_id` - (Optional) The resource ID of the image, this can either be resource ID of a Standard Azure VM Image or a Image that is hosted within Azure Image Gallery.
- `well_known_image_name` - (Optional) The well-known name of the image, thid is used to reference the well-known images that are available on Microsoft Hosted Agents, supported images are `ubuntu-22.04/latest`, `ubuntu-20.04/latest`, `windows-2022/latest`, and `windows-2019/latest`.
- `buffer` - (Optional) The buffer associated with the image.
- `aliases` - (Required) A list of aliases for the image. |list(object({|
resource_id = optional(string)
well_known_image_name = optional(string)
buffer = optional(string, "*")
aliases = optional(list(string))
}))[| no |
{
"aliases": [
"ubuntu-22.04/latest"
],
"well_known_image_name": "ubuntu-22.04/latest"
}
]
| [fabric\_profile\_os\_disk\_storage\_account\_type](#input\_fabric\_profile\_os\_disk\_storage\_account\_type) | The storage account type for the OS disk, possible values are 'Standard', 'Premium' and 'StandardSSD', defaults to 'Premium'. | `string` | `"Premium"` | no |
| [fabric\_profile\_os\_profile\_logon\_type](#input\_fabric\_profile\_os\_profile\_logon\_type) | The logon type for the OS profile, possible values are 'Interactive' and 'Service', defaults to 'Service'. | `string` | `"Service"` | no |
| [fabric\_profile\_sku\_name](#input\_fabric\_profile\_sku\_name) | The SKU name of the fabric profile, make sure you have enough quota for the SKU, the CPUs are multiplied by the `maximum_concurrency` value, make sure you request enough quota, defaults to 'Standard\_D2ads\_v5' which has 2 vCPU Cores. so if maximum\_concurrency is 2, you will need quota for 4 vCPU Cores and so on. | `string` | `"Standard_D2ads_v5"` | no |
| [identity\_ids](#input\_identity\_ids) | Specifies a list of user managed identity ids to be assigned to the VM. | `list(string)` | `[]` | no |
| [identity\_type](#input\_identity\_type) | The Managed Service Identity Type of this Virtual Machine. | `string` | `""` | no |
| [location](#input\_location) | Azure region where the resource should be deployed. | `string` | n/a | yes |
| [managed\_pool\_api\_version](#input\_managed\_pool\_api\_version) | The API version to use for the Managed Pool resource. | `string` | `"Microsoft.DevOpsInfrastructure/pools@2024-10-19"` | no |
| [maximum\_concurrency](#input\_maximum\_concurrency) | The maximum number of agents that can run concurrently, must be between 1 and 10000, defaults to 1. | `number` | `1` | no |
| [name](#input\_name) | Name of the pool. It needs to be globally unique for each Azure DevOps Organization. | `string` | n/a | yes |
| [organization\_profile](#input\_organization\_profile) | An object representing the configuration for an organization profile, including organizations and permission profiles.
This is for advanced use cases where you need to specify permissions and multiple organization.
If not suppled, then `version_control_system_organization_name` and optionally `version_control_system_project_names` must be supplied.
- `organizations` - (Required) A list of objects representing the organizations.
- `name` - (Required) The name of the organization, without the `https://dev.azure.com/` prefix.
- `projects` - (Optional) A list of project names this agent should run on. If empty, it will run on all projects. Defaults to `[]`.
- `parallelism` - (Optional) The parallelism value. If multiple organizations are specified, this value needs to be set and cannot exceed the total value of `maximum_concurrency`; otherwise, it will use the `maximum_concurrency` value as default or the value you define for single Organization.
- `permission_profile` - (Required) An object representing the permission profile.
- `kind` - (Required) The kind of permission profile, possible values are `CreatorOnly`, `Inherit`, and `SpecificAccounts`, if `SpecificAccounts` is chosen, you must provide a list of users and/or groups.
- `users` - (Optional) A list of users for the permission profile, supported value is the `ObjectID` or `UserPrincipalName`. Defaults to `null`.
- `groups` - (Optional) A list of groups for the permission profile, supported value is the `ObjectID` of the group. Defaults to `null`. |object({| `null` | no |
kind = optional(string, "AzureDevOps")
organizations = list(object({
name = string
projects = optional(list(string), []) # List of all Projects names this agent should run on, if empty, it will run on all projects.
parallelism = optional(number) # If multiple organizations are specified, this value needs to be set, otherwise it will use the maximum_concurrency value.
}))
permission_profile = optional(object({
kind = optional(string, "CreatorOnly")
users = optional(list(string), null)
groups = optional(list(string), null)
}), {
kind = "CreatorOnly"
})
})
| [rg\_id](#input\_rg\_id) | The resource group where the resources will be deployed. | `string` | n/a | yes |
| [subnet\_id](#input\_subnet\_id) | The virtual network subnet resource id to use for private networking. | `string` | `null` | no |
| [tags](#input\_tags) | (Optional) Tags of the resource. | `map(string)` | `null` | no |
| [version\_control\_system\_organization\_name](#input\_version\_control\_system\_organization\_name) | The name of the version control system organization. This is required if `organization_profile` is not supplied. | `string` | `null` | no |
| [version\_control\_system\_project\_names](#input\_version\_control\_system\_project\_names) | The name of the version control system project. This is optional if `organization_profile` is not supplied. | `set(string)` | `[]` | no |
| [version\_control\_system\_type](#input\_version\_control\_system\_type) | The type of version control system. This is shortcut alternative to `organization_profile.kind`. Possible values are 'azuredevops' or 'github'. | `string` | `"azuredevops"` | no |## Outputs
| Name | Description |
|------|-------------|
| [devops\_pool\_id](#output\_devops\_pool\_id) | The resource if of the Managed DevOps Pool. |
| [devops\_pool\_name](#output\_devops\_pool\_name) | The name of the Managed DevOps Pool. |
| [devops\_pool\_tags](#output\_devops\_pool\_tags) | The tags of the Managed DevOps Pool. |
| [resource](#output\_resource) | This is the full output for the Managed DevOps Pool. |