Skip to content

Commit

Permalink
Save changes
Browse files Browse the repository at this point in the history
  • Loading branch information
jaredfholgate committed Jul 29, 2024
1 parent b5874e5 commit 2d27c3a
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 11 deletions.
10 changes: 8 additions & 2 deletions examples/default/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,13 @@ resource "random_integer" "region_index" {
## End of section to provide a random Azure region for the resource group

# This ensures we have unique CAF compliant names for our resources.
resource "random_string" "name" {
length = 4
special = false
numeric = true
upper = false
}

module "naming" {
source = "Azure/naming/azurerm"
version = ">= 0.3.0"
Expand All @@ -91,11 +98,10 @@ resource "azuredevops_agent_queue" "alz" {
module "azure_devops_agents" {
source = "../.."

postfix = module.naming.unique-seed
postfix = random_string.name.result
location = module.regions.regions[random_integer.region_index.result].name
version_control_system_type = "azuredevops"
version_control_system_personal_access_token = var.azure_devops_agents_personal_access_token
version_control_system_organization = local.azure_devops_organization_url
subnet_address_prefix = "10.0.2.0/23"
virtual_network_address_space = "10.0.0.0/16"
}
7 changes: 7 additions & 0 deletions local.virtual.network.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
locals {
virtual_network_address_space_cidr_size = var.create_virtual_network ? tonumber(split("/", var.virtual_network_address_space)[1]) : 24

subnet_address_prefixes = cidrsubnets(var.virtual_network_address_space, 23 - local.virtual_network_address_space_cidr_size, 29 - local.virtual_network_address_space_cidr_size)
container_app_subnet_address_prefix = var.container_app_subnet_address_prefix == null ? element(local.subnet_address_prefixes, 0) : var.container_app_subnet_address_prefix
container_registry_private_endpoint_subnet_address_prefix = var.container_registry_private_endpoint_subnet_address_prefix == null ? element(local.subnet_address_prefixes, 1) : var.container_registry_private_endpoint_subnet_address_prefix
}
2 changes: 1 addition & 1 deletion locals.tf
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ locals {

locals {
container_app_environment_name = var.container_app_environment_name != null ? var.container_app_environment_name : "cae-${var.postfix}"
container_registry_name = var.container_registry_name != null ? var.container_registry_name : "acr-${var.postfix}"
container_registry_name = var.container_registry_name != null ? var.container_registry_name : "acr${var.postfix}"
log_analytics_workspace_name = var.log_analytics_workspace_name != null ? var.log_analytics_workspace_name : "laws-${var.postfix}"
virtual_network_name = var.virtual_network_name != null ? var.virtual_network_name : "vnet-${var.postfix}"
container_app_subnet_name = var.container_app_subnet_name != null ? var.container_app_subnet_name : "subnet-container-app-${var.postfix}"
Expand Down
10 changes: 5 additions & 5 deletions main.virtual.network.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@ module "virtual_network" {
source = "Azure/avm-res-network-virtualnetwork/azurerm"
version = "~> 0.4"

name = var.virtual_network_name
name = local.virtual_network_name
resource_group_name = local.resource_group_name
location = var.location
address_space = [var.virtual_network_address_space]

subnets = {
container_app = {
name = var.container_app_subnet_name
address_prefix = var.container_app_subnet_address_prefix
name = local.container_app_subnet_name
address_prefix = local.container_app_subnet_address_prefix
}
container_registry_private_endpoint = {
name = var.container_registry_private_endpoint_subnet_name
address_prefix = var.container_registry_private_endpoint_subnet_address_prefix
name = local.container_registry_private_endpoint_subnet_name
address_prefix = local.container_registry_private_endpoint_subnet_address_prefix
}
}
}
2 changes: 1 addition & 1 deletion modules/container-registry/locals.tf
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
locals {
private_dns_zone_id = var.create_private_dns_zone ? azurerm_private_dns_zone.this.id : var.private_dns_zone_id
private_dns_zone_id = var.create_private_dns_zone ? azurerm_private_dns_zone.this[0].id : var.private_dns_zone_id
}
4 changes: 2 additions & 2 deletions modules/container-registry/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ resource "azurerm_private_dns_zone" "this" {

module "container_registry" {
source = "Azure/avm-res-containerregistry-registry/azurerm"
version = "0.1.0"
version = "~> 0.2"
name = var.name
resource_group_name = var.resource_group_name
location = var.location
Expand Down Expand Up @@ -52,7 +52,7 @@ resource "azurerm_container_registry_task_schedule_run_now" "this" {
for_each = var.images
container_registry_task_id = azurerm_container_registry_task.this[each.key].id
lifecycle {
replace_triggered_by = [azurerm_container_registry_task.alz]
replace_triggered_by = [azurerm_container_registry_task.this]
}
depends_on = [azurerm_role_assignment.container_registry_push_for_task]
}
Expand Down

0 comments on commit 2d27c3a

Please sign in to comment.