Skip to content

Commit bb08bf1

Browse files
authored
Merge pull request #5 from data-platform-hq/feature/switch-to-create-pool-on-ado
feat: optional ado resources creation
2 parents 735c82f + d0891cf commit bb08bf1

File tree

2 files changed

+19
-8
lines changed

2 files changed

+19
-8
lines changed

main.tf

+13-8
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,21 @@ module "vmss" {
1616
}
1717

1818
data "azuredevops_project" "this" {
19-
name = var.ado_project_name
19+
count = var.create_ado_resources ? 1 : 0
20+
name = var.ado_project_name
2021
}
2122

2223
data "azuredevops_serviceendpoint_azurerm" "this" {
23-
project_id = data.azuredevops_project.this.id
24+
count = var.create_ado_resources ? 1 : 0
25+
project_id = data.azuredevops_project.this[0].id
2426
service_endpoint_name = var.ado_service_connection_azurerm_name
2527
}
2628

2729
resource "azuredevops_elastic_pool" "this" {
30+
count = var.create_ado_resources ? 1 : 0
2831
name = var.ado_vmss_pool_name
29-
service_endpoint_id = data.azuredevops_serviceendpoint_azurerm.this.id
30-
service_endpoint_scope = data.azuredevops_project.this.id
32+
service_endpoint_id = data.azuredevops_serviceendpoint_azurerm.this[0].id
33+
service_endpoint_scope = data.azuredevops_project.this[0].id
3134
azure_resource_id = module.vmss.id
3235
desired_idle = var.ado_vmss_pool_configuration.desired_idle
3336
max_capacity = var.ado_vmss_pool_configuration.max_capacity
@@ -36,12 +39,14 @@ resource "azuredevops_elastic_pool" "this" {
3639
}
3740

3841
resource "azuredevops_agent_queue" "this" {
39-
project_id = data.azuredevops_project.this.id
40-
agent_pool_id = azuredevops_elastic_pool.this.id
42+
count = var.create_ado_resources ? 1 : 0
43+
project_id = data.azuredevops_project.this[0].id
44+
agent_pool_id = azuredevops_elastic_pool.this[0].id
4145
}
4246

4347
resource "azuredevops_pipeline_authorization" "this" {
44-
project_id = data.azuredevops_project.this.id
45-
resource_id = azuredevops_agent_queue.this.id
48+
count = var.create_ado_resources ? 1 : 0
49+
project_id = data.azuredevops_project.this[0].id
50+
resource_id = azuredevops_agent_queue.this[0].id
4651
type = "queue"
4752
}

variables.tf

+6
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,9 @@ variable "ado_vmss_public_ip_prefix_enabled" {
4949
type = bool
5050
default = true
5151
}
52+
53+
variable "create_ado_resources" {
54+
description = "Boolean flag that determines whether ADO resources will be created"
55+
type = bool
56+
default = true
57+
}

0 commit comments

Comments
 (0)