Skip to content

Commit

Permalink
add ACR replica in different region
Browse files Browse the repository at this point in the history
  • Loading branch information
jfchevrette committed Dec 18, 2024
1 parent f26a94a commit 1eec2c8
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 0 deletions.
9 changes: 9 additions & 0 deletions dev-infrastructure/configurations/region.tmpl.bicepparam
Original file line number Diff line number Diff line change
@@ -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 }}'
Expand Down
23 changes: 23 additions & 0 deletions dev-infrastructure/modules/acr/acr-replication.bicep
Original file line number Diff line number Diff line change
@@ -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
}
}
32 changes: 32 additions & 0 deletions dev-infrastructure/templates/region.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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
//
Expand Down

0 comments on commit 1eec2c8

Please sign in to comment.