Skip to content

Commit

Permalink
add azdo service endpoints for Azure container registry
Browse files Browse the repository at this point in the history
  • Loading branch information
Simon Schneider committed Nov 25, 2021
1 parent 86930a5 commit 8a3adfd
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 0 deletions.
26 changes: 26 additions & 0 deletions caf_solution/add-ons/azure_devops_v1/azdo_service_endpoints_acr.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
data "azurerm_container_registry" "acr" {
for_each = var.service_endpoints_acr
name = local.remote.azure_container_registries[each.value.azure_container_registry.lz_key][each.value.azure_container_registry.key].name
resource_group_name = local.remote.azure_container_registries[each.value.azure_container_registry.lz_key][each.value.azure_container_registry.key].resource_group_name
}

resource "azuredevops_serviceendpoint_dockerregistry" "acr" {
for_each = var.service_endpoints_acr

project_id = data.azuredevops_project.project[each.value.project_key].id
service_endpoint_name = each.value.endpoint_name

docker_registry = format("https://%s", data.azurerm_container_registry.acr[each.key].login_server)
docker_username = data.azurerm_container_registry.acr[each.key].admin_username
docker_password = data.azurerm_container_registry.acr[each.key].admin_password
registry_type = "Others"
}

resource "azuredevops_resource_authorization" "registry_endpoint" {
for_each = var.service_endpoints_acr

project_id = data.azuredevops_project.project[each.value.project_key].id
resource_id = azuredevops_serviceendpoint_dockerregistry.acr[each.key].id
type = "endpoint"
authorized = try(each.value.authorized, false)
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ locals {
azuread_groups = {
for key, value in try(var.landingzone.tfstates, {}) : key => merge(try(data.terraform_remote_state.remote[key].outputs.objects[key].azuread_groups, {}))
}
azure_container_registries = {
for key, value in try(var.landingzone.tfstates, {}) : key => merge(try(data.terraform_remote_state.remote[key].outputs.objects[key].azure_container_registries, {}))
}
keyvaults = {
for key, value in try(var.landingzone.tfstates, {}) : key => merge(try(data.terraform_remote_state.remote[key].outputs.objects[key].keyvaults, {}))
}
Expand Down
3 changes: 3 additions & 0 deletions caf_solution/add-ons/azure_devops_v1/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ variable "project_agent_pools" {
variable "service_endpoints" {
default = {}
}
variable "service_endpoints_acr" {
default = {}
}
variable "variable_groups" {
default = {}
}
Expand Down

0 comments on commit 8a3adfd

Please sign in to comment.