From 7ece688021173663c389c5d36560e5a11ca39d62 Mon Sep 17 00:00:00 2001 From: Jean-Francois Chevrette Date: Mon, 16 Dec 2024 18:50:35 -0500 Subject: [PATCH] add ACR replica in different region --- .../configurations/region.tmpl.bicepparam | 9 ++++++ .../modules/acr/acr-replication.bicep | 23 +++++++++++++ dev-infrastructure/templates/region.bicep | 32 +++++++++++++++++++ 3 files changed, 64 insertions(+) create mode 100644 dev-infrastructure/modules/acr/acr-replication.bicep diff --git a/dev-infrastructure/configurations/region.tmpl.bicepparam b/dev-infrastructure/configurations/region.tmpl.bicepparam index 65ed549df..db9c33144 100644 --- a/dev-infrastructure/configurations/region.tmpl.bicepparam +++ b/dev-infrastructure/configurations/region.tmpl.bicepparam @@ -1,5 +1,14 @@ using '../templates/region.bicep' +// general +param globalRegion = '{{ .global.region }}' +param globalResourceGroup = '{{ .global.rg }}' +param regionalRegion = '{{ .region }}' + +// acr +param ocpAcrName = '{{ .ocpAcrName }}' +param svcAcrName = '{{ .svcAcrName }}' + // dns param baseDNSZoneName = '{{ .baseDnsZoneName }}' param baseDNSZoneResourceGroup = '{{ .baseDnsZoneRG }}' diff --git a/dev-infrastructure/modules/acr/acr-replication.bicep b/dev-infrastructure/modules/acr/acr-replication.bicep new file mode 100644 index 000000000..2b70bc2c2 --- /dev/null +++ b/dev-infrastructure/modules/acr/acr-replication.bicep @@ -0,0 +1,23 @@ +@description('ACR replication resource location') +param acrReplicationLocation string + +@description('Parent ACR resource name') +param acrReplicationParentAcrName string + +@minLength(5) +@maxLength(40) +@description('ACR replication name (must be globally unique)') +param acrReplicationReplicaName string + +resource parentAcr 'Microsoft.ContainerRegistry/registries@2023-11-01-preview' existing = { + name: acrReplicationParentAcrName +} + +resource acrReplication 'Microsoft.ContainerRegistry/registries/replications@2023-11-01-preview' = { + parent: parentAcr + name: acrReplicationReplicaName + location: acrReplicationLocation + properties: { + regionEndpointEnabled: true + } +} diff --git a/dev-infrastructure/templates/region.bicep b/dev-infrastructure/templates/region.bicep index 7c88b7072..6bebb2862 100644 --- a/dev-infrastructure/templates/region.bicep +++ b/dev-infrastructure/templates/region.bicep @@ -21,6 +21,12 @@ param baseDNSZoneResourceGroup string = 'global' param regionalDNSSubdomain string +param globalRegion string +param regionalRegion string +param globalResourceGroup string +param ocpAcrName string +param svcAcrName string + // Tags the resource group resource subscriptionTags 'Microsoft.Resources/tags@2024-03-01' = { name: 'default' @@ -51,6 +57,32 @@ module regionalZoneDelegation '../modules/dns/zone-delegation.bicep' = { } } +// +// R E G I O N A L A C R R E P L I C A T I O N +// + +var ocpAcrReplicationName = '${ocpAcrName}${location}replica' +module ocpAcrReplication '../modules/acr/acr-replication.bicep' = if (globalRegion != regionalRegion) { + name: ocpAcrReplicationName + scope: resourceGroup(globalResourceGroup) + params: { + acrReplicationLocation: location + acrReplicationParentAcrName: ocpAcrName + acrReplicationReplicaName: ocpAcrReplicationName + } +} + +var svcAcrReplicationName = '${svcAcrName}${location}replica' +module svcAcrReplication '../modules/acr/acr-replication.bicep' = if (globalRegion != regionalRegion) { + name: svcAcrReplicationName + scope: resourceGroup(globalResourceGroup) + params: { + acrReplicationLocation: location + acrReplicationParentAcrName: svcAcrName + acrReplicationReplicaName: svcAcrReplicationName + } +} + // // M A E S T R O //