-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from data-platform-hq/feat/add-devops-pool-and-…
…dev-center feat: add managed devops pool and dev center
- Loading branch information
Showing
7 changed files
with
219 additions
and
2 deletions.
There are no files selected for viewing
This file contains 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 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,14 @@ | ||
data "azuredevops_client_config" "this" {} | ||
|
||
data "azurerm_subscription" "current" {} | ||
|
||
data "azuredevops_project" "this" { | ||
name = var.ado_project_name | ||
} | ||
|
||
data "azuredevops_agent_queue" "this" { | ||
project_id = data.azuredevops_project.this.project_id | ||
name = module.managed_devops_pool.name | ||
|
||
depends_on = [module.managed_devops_pool] | ||
} |
This file contains 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 @@ | ||
locals { | ||
ado_organization_name = split("/", | ||
data.azuredevops_client_config.this.organization_url)[3] | ||
} |
This file contains 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,55 @@ | ||
resource "azurerm_dev_center" "this" { | ||
location = var.location | ||
name = var.dev_center_name | ||
resource_group_name = var.resource_group | ||
} | ||
|
||
resource "azurerm_dev_center_project" "this" { | ||
dev_center_id = azurerm_dev_center.this.id | ||
location = var.location | ||
name = var.dev_center_project_name | ||
resource_group_name = var.resource_group | ||
} | ||
|
||
resource "azurerm_role_assignment" "net_contrib" { | ||
scope = data.azurerm_subscription.current.id | ||
role_definition_name = "Network Contributor" | ||
principal_id = var.aad_sp_devopsinfrastructure_id | ||
} | ||
|
||
resource "azurerm_role_assignment" "reader" { | ||
scope = data.azurerm_subscription.current.id | ||
role_definition_name = "Reader" | ||
principal_id = var.aad_sp_devopsinfrastructure_id | ||
} | ||
|
||
resource "azuredevops_pipeline_authorization" "this" { | ||
project_id = data.azuredevops_project.this.project_id | ||
resource_id = data.azuredevops_agent_queue.this.id | ||
type = "queue" | ||
|
||
depends_on = [module.managed_devops_pool] | ||
} | ||
|
||
module "managed_devops_pool" { | ||
source = "Azure/avm-res-devopsinfrastructure-pool/azurerm" | ||
|
||
resource_group_name = var.resource_group | ||
location = var.location | ||
name = var.devops_pool_name | ||
dev_center_project_resource_id = azurerm_dev_center_project.this.id | ||
subnet_id = var.subnet_id | ||
organization_profile = { | ||
organizations = [{ | ||
name = local.ado_organization_name | ||
projects = [var.ado_project_name] | ||
}] | ||
permission_profile = { | ||
kind = "Inherit" | ||
} | ||
} | ||
maximum_concurrency = var.devops_pool_max_concurrency | ||
enable_telemetry = var.enable_telemetry | ||
|
||
depends_on = [azurerm_role_assignment.reader, azurerm_role_assignment.net_contrib] | ||
} |
This file contains 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" { | ||
value = module.managed_devops_pool.resource_id | ||
description = "Resource ID of managed DevOps pool" | ||
} |
This file contains 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,52 @@ | ||
variable "resource_group" { | ||
description = "The name of the resource group." | ||
type = string | ||
} | ||
|
||
variable "location" { | ||
description = "The Azure Region in which all resources in this example should be created." | ||
type = string | ||
} | ||
|
||
variable "ado_project_name" { | ||
description = "Target Azure DevOps Project name where VMSS agent pool would be provisioned" | ||
type = string | ||
} | ||
|
||
variable "dev_center_name" { | ||
description = "Name of DevCenter in which managed DevOps pool will be created" | ||
type = string | ||
} | ||
|
||
variable "dev_center_project_name" { | ||
description = "Name of DevCenter project where managed DevOps pool will be created" | ||
type = string | ||
} | ||
|
||
variable "aad_sp_devopsinfrastructure_id" { | ||
description = "Object ID of Entra ID service principal named DevOpsInfrastructure" | ||
type = string | ||
default = "72055c5c-4353-4d6d-8838-bacee04b729d" | ||
} | ||
|
||
variable "devops_pool_name" { | ||
description = "Name of managed DevOps pool" | ||
type = string | ||
} | ||
|
||
variable "devops_pool_max_concurrency" { | ||
description = "Maximum number of nodes in DevOps pool's VMSS" | ||
type = number | ||
default = 2 | ||
} | ||
|
||
variable "subnet_id" { | ||
description = "Subnet where VM Scale Sets would be provisioned" | ||
type = string | ||
} | ||
|
||
variable "enable_telemetry" { | ||
description = "Boolean flag that determines whether telemetry should be enabled" | ||
type = bool | ||
default = false | ||
} |
This file contains 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,30 @@ | ||
terraform { | ||
required_version = ">= 1.0.0" | ||
|
||
required_providers { | ||
azurerm = { | ||
source = "hashicorp/azurerm" | ||
version = "~> 4.0" | ||
} | ||
azuredevops = { | ||
source = "microsoft/azuredevops" | ||
version = "~> 1.1" | ||
} | ||
tls = { | ||
source = "hashicorp/tls" | ||
version = "~> 4.0" | ||
} | ||
random = { | ||
source = "hashicorp/random" | ||
version = "~> 3.6" | ||
} | ||
azapi = { | ||
source = "Azure/azapi" | ||
version = "~> 1.15" | ||
} | ||
azuread = { | ||
source = "hashicorp/azuread" | ||
version = "~> 3.0" | ||
} | ||
} | ||
} |