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 //