Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions modules/terraform-azure-devops/variable-groups/variable_groups.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
resource "azuredevops_variable_group" "variable_group" {
for_each = var.variable_groups

project_id = each.value.project_id
name = each.value.name
description = each.value.description
allow_access = each.value.allow_access

key_vault {
name = each.value.key_vault_name
service_endpoint_id = each.value.service_endpoint_id
}

dynamic "variable" {
for_each = {
for key, value in each.value : key => value
if startswith(key, "var_")
}

content {
# NOTE depending if the value is secret or not it is set with a complementary attribute
name = substr(variable.key, 4, -1)
value = length(regexall("password", variable.key)) > 0 ? null : variable.value
is_secret = length(regexall("password", variable.key)) > 0 ? true : false
secret_value = length(regexall("password", variable.key)) > 0 ? variable.value : null
}
}

}
3 changes: 3 additions & 0 deletions modules/terraform-azure-devops/variable-groups/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
variable "variable_groups" {

}