Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 21 additions & 10 deletions infrastructure/afd-apim-pe/main.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,15 @@ module appInsightsModule '../../shared/bicep/modules/monitor/v1/appinsights.bice
var appInsightsId = appInsightsModule.outputs.id
var appInsightsInstrumentationKey = appInsightsModule.outputs.instrumentationKey

// 3. Virtual Network and Subnets
// 3. Network Watcher (required for NSG flow logs)
module networkWatcherModule '../../shared/bicep/modules/network-watcher/v1/network-watcher.bicep' = {
name: 'networkWatcherModule'
params: {
location: location
}
}

// 4. Virtual Network and Subnets

// We are using a standard NSG for our subnets here. Production workloads should use a relevant, custom NSG for each subnet.
// We also do not presently use a custom route table for the subnets, which is a best practice for production workloads.
Expand All @@ -81,6 +89,9 @@ var appInsightsInstrumentationKey = appInsightsModule.outputs.instrumentationKey
resource nsg 'Microsoft.Network/networkSecurityGroups@2025-01-01' = {
name: 'nsg-default'
location: location
dependsOn: [
networkWatcherModule
]
}

module vnetModule '../../shared/bicep/modules/vnet/v1/vnet.bicep' = {
Expand Down Expand Up @@ -150,7 +161,7 @@ resource acaSubnetResource 'Microsoft.Network/virtualNetworks/subnets@2024-05-01
var apimSubnetResourceId = apimSubnetResource.id
var acaSubnetResourceId = acaSubnetResource.id

// 4. Azure Container App Environment (ACAE)
// 5. Azure Container App Environment (ACAE)
module acaEnvModule '../../shared/bicep/modules/aca/v1/environment.bicep' = if (useACA) {
name: 'acaEnvModule'
params: {
Expand All @@ -161,7 +172,7 @@ module acaEnvModule '../../shared/bicep/modules/aca/v1/environment.bicep' = if (
}
}

// 5. Azure Container Apps (ACA) for Mock Web API
// 6. Azure Container Apps (ACA) for Mock Web API
module acaModule1 '../../shared/bicep/modules/aca/v1/containerapp.bicep' = if (useACA) {
name: 'acaModule-1'
params: {
Expand All @@ -180,7 +191,7 @@ module acaModule2 '../../shared/bicep/modules/aca/v1/containerapp.bicep' = if (u
}
}

// 6. API Management
// 7. API Management
module apimModule '../../shared/bicep/modules/apim/v1/apim.bicep' = {
name: 'apimModule'
params: {
Expand All @@ -193,7 +204,7 @@ module apimModule '../../shared/bicep/modules/apim/v1/apim.bicep' = {
}
}

// 7. APIM Policy Fragments
// 8. APIM Policy Fragments
module policyFragmentModule '../../shared/bicep/modules/apim/v1/policy-fragment.bicep' = [for pf in policyFragments: {
name: 'pf-${pf.name}'
params:{
Expand All @@ -207,7 +218,7 @@ module policyFragmentModule '../../shared/bicep/modules/apim/v1/policy-fragment.
]
}]

// 8. APIM Backends for ACA
// 9. APIM Backends for ACA
module backendModule1 '../../shared/bicep/modules/apim/v1/backend.bicep' = if (useACA) {
name: 'aca-backend-1'
params: {
Expand Down Expand Up @@ -256,7 +267,7 @@ module backendPoolModule '../../shared/bicep/modules/apim/v1/backend-pool.bicep'
]
}

// 9. APIM APIs
// 10. APIM APIs
module apisModule '../../shared/bicep/modules/apim/v1/api.bicep' = [for api in apis: if(length(apis) > 0) {
name: 'api-${api.name}'
params: {
Expand All @@ -275,7 +286,7 @@ module apisModule '../../shared/bicep/modules/apim/v1/api.bicep' = [for api in a
]
}]

// 10. APIM Private DNS Zone, VNet Link, and (optional) DNS Zone Group
// 11. APIM Private DNS Zone, VNet Link, and (optional) DNS Zone Group
module apimDnsPrivateLinkModule '../../shared/bicep/modules/dns/v1/dns-private-link.bicep' = {
name: 'apimDnsPrivateLinkModule'
params: {
Expand All @@ -288,7 +299,7 @@ module apimDnsPrivateLinkModule '../../shared/bicep/modules/dns/v1/dns-private-l
}
}

// 11. ACA Private DNS Zone (regional, e.g., eastus2.azurecontainerapps.io), VNet Link, and wildcard A record via shared module
// 12. ACA Private DNS Zone (regional, e.g., eastus2.azurecontainerapps.io), VNet Link, and wildcard A record via shared module
module acaDnsPrivateZoneModule '../../shared/bicep/modules/dns/v1/aca-dns-private-zone.bicep' = if (useACA && !empty(acaSubnetResourceId)) {
name: 'acaDnsPrivateZoneModule'
params: {
Expand All @@ -298,7 +309,7 @@ module acaDnsPrivateZoneModule '../../shared/bicep/modules/dns/v1/aca-dns-privat
}
}

// 12. Front Door
// 13. Front Door
module afdModule '../../shared/bicep/modules/afd/v1/afd.bicep' = {
name: 'afdModule'
params: {
Expand Down
46 changes: 30 additions & 16 deletions infrastructure/appgw-apim-pe/main.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -96,16 +96,30 @@ module appInsightsModule '../../shared/bicep/modules/monitor/v1/appinsights.bice
var appInsightsId = appInsightsModule.outputs.id
var appInsightsInstrumentationKey = appInsightsModule.outputs.instrumentationKey

// 3. Virtual Network and Subnets
// 3. Network Watcher (required for NSG flow logs)
module networkWatcherModule '../../shared/bicep/modules/network-watcher/v1/network-watcher.bicep' = {
name: 'networkWatcherModule'
params: {
location: location
}
}

// 4. Virtual Network and Subnets
resource nsgDefault 'Microsoft.Network/networkSecurityGroups@2025-01-01' = {
name: 'nsg-default'
location: location
dependsOn: [
networkWatcherModule
]
}

// App Gateway needs a specific NSG
resource nsgAppGw 'Microsoft.Network/networkSecurityGroups@2025-01-01' = {
name: 'nsg-appgw'
location: location
dependsOn: [
networkWatcherModule
]
properties: {
securityRules: [
{
Expand Down Expand Up @@ -226,7 +240,7 @@ var acaSubnetResourceId = '${vnetModule.outputs.vnetId}/subnets/${acaSubnetNam
var appgwSubnetResourceId = '${vnetModule.outputs.vnetId}/subnets/${appgwSubnetName}'
var peSubnetResourceId = '${vnetModule.outputs.vnetId}/subnets/${privateEndpointSubnetName}'

// 4. User Assigned Managed Identity
// 5. User Assigned Managed Identity
// https://github.com/Azure/bicep-registry-modules/tree/main/avm/res/managed-identity/user-assigned-identity
module uamiModule 'br/public:avm/res/managed-identity/user-assigned-identity:0.4.2' = {
name: 'uamiModule'
Expand All @@ -236,7 +250,7 @@ module uamiModule 'br/public:avm/res/managed-identity/user-assigned-identity:0.4
}
}

// 5. Key Vault
// 6. Key Vault
// https://learn.microsoft.com/azure/templates/microsoft.keyvault/vaults
// This assignment is helpful for testing to allow you to examine and administer the Key Vault. Adjust accordingly for real workloads!
var keyVaultAdminRoleAssignment = setCurrentUserAsKeyVaultAdmin && !empty(currentUserId) ? [
Expand Down Expand Up @@ -269,7 +283,7 @@ module keyVaultModule 'br/public:avm/res/key-vault/vault:0.13.3' = {
}
}

// 6. Public IP for Application Gateway
// 7. Public IP for Application Gateway
// https://github.com/Azure/bicep-registry-modules/tree/main/avm/res/network/public-ip-address
module appgwPipModule 'br/public:avm/res/network/public-ip-address:0.9.1' = {
name: 'appgwPipModule'
Expand All @@ -282,7 +296,7 @@ module appgwPipModule 'br/public:avm/res/network/public-ip-address:0.9.1' = {
}
}

// 7. WAF Policy for Application Gateway
// 8. WAF Policy for Application Gateway
// https://learn.microsoft.com/azure/templates/microsoft.network/applicationgatewaywebapplicationfirewallpolicies
resource wafPolicy 'Microsoft.Network/ApplicationGatewayWebApplicationFirewallPolicies@2025-01-01' = {
name: 'waf-${resourceSuffix}'
Expand All @@ -308,7 +322,7 @@ resource wafPolicy 'Microsoft.Network/ApplicationGatewayWebApplicationFirewallPo
}
}

// 8. Azure Container App Environment (ACAE)
// 9. Azure Container App Environment (ACAE)
module acaEnvModule '../../shared/bicep/modules/aca/v1/environment.bicep' = if (useACA) {
name: 'acaEnvModule'
params: {
Expand All @@ -319,7 +333,7 @@ module acaEnvModule '../../shared/bicep/modules/aca/v1/environment.bicep' = if (
}
}

// 9. Azure Container Apps (ACA) for Mock Web API
// 10. Azure Container Apps (ACA) for Mock Web API
module acaModule1 '../../shared/bicep/modules/aca/v1/containerapp.bicep' = if (useACA) {
name: 'acaModule-1'
params: {
Expand All @@ -338,7 +352,7 @@ module acaModule2 '../../shared/bicep/modules/aca/v1/containerapp.bicep' = if (u
}
}

// 10. API Management
// 11. API Management
module apimModule '../../shared/bicep/modules/apim/v1/apim.bicep' = {
name: 'apimModule'
params: {
Expand All @@ -352,7 +366,7 @@ module apimModule '../../shared/bicep/modules/apim/v1/apim.bicep' = {
}
}

// 11. APIM Policy Fragments
// 12. APIM Policy Fragments
module policyFragmentModule '../../shared/bicep/modules/apim/v1/policy-fragment.bicep' = [for pf in policyFragments: {
name: 'pf-${pf.name}'
params:{
Expand All @@ -366,7 +380,7 @@ module policyFragmentModule '../../shared/bicep/modules/apim/v1/policy-fragment.
]
}]

// 12. APIM Backends for ACA
// 13. APIM Backends for ACA
module backendModule1 '../../shared/bicep/modules/apim/v1/backend.bicep' = if (useACA) {
name: 'aca-backend-1'
params: {
Expand Down Expand Up @@ -415,7 +429,7 @@ module backendPoolModule '../../shared/bicep/modules/apim/v1/backend-pool.bicep'
]
}

// 13. APIM APIs
// 14. APIM APIs
module apisModule '../../shared/bicep/modules/apim/v1/api.bicep' = [for api in apis: if(length(apis) > 0) {
name: 'api-${api.name}'
params: {
Expand All @@ -434,7 +448,7 @@ module apisModule '../../shared/bicep/modules/apim/v1/api.bicep' = [for api in a
]
}]

// 14. Private Endpoint for APIM
// 15. Private Endpoint for APIM
// https://learn.microsoft.com/azure/templates/microsoft.network/privateendpoints
resource apimPrivateEndpoint 'Microsoft.Network/privateEndpoints@2024-05-01' = {
name: 'pe-apim-${resourceSuffix}'
Expand All @@ -457,7 +471,7 @@ resource apimPrivateEndpoint 'Microsoft.Network/privateEndpoints@2024-05-01' = {
}
}

// 15. Private DNS Zone Group for APIM Private Endpoint
// 16. Private DNS Zone Group for APIM Private Endpoint
// https://learn.microsoft.com/azure/templates/microsoft.network/privateendpoints/privatednszoneegroups
resource apimPrivateDnsZoneGroup 'Microsoft.Network/privateEndpoints/privateDnsZoneGroups@2024-05-01' = {
name: 'apim-dns-zone-group'
Expand All @@ -474,7 +488,7 @@ resource apimPrivateDnsZoneGroup 'Microsoft.Network/privateEndpoints/privateDnsZ
}
}

// 16. APIM Private DNS Zone, VNet Link
// 17. APIM Private DNS Zone, VNet Link
module apimDnsPrivateLinkModule '../../shared/bicep/modules/dns/v1/dns-private-link.bicep' = {
name: 'apimDnsPrivateLinkModule'
params: {
Expand All @@ -487,7 +501,7 @@ module apimDnsPrivateLinkModule '../../shared/bicep/modules/dns/v1/dns-private-l
}
}

// 17. ACA Private DNS Zone
// 18. ACA Private DNS Zone
module acaDnsPrivateZoneModule '../../shared/bicep/modules/dns/v1/aca-dns-private-zone.bicep' = if (useACA) {
name: 'acaDnsPrivateZoneModule'
params: {
Expand All @@ -497,7 +511,7 @@ module acaDnsPrivateZoneModule '../../shared/bicep/modules/dns/v1/aca-dns-privat
}
}

// 18. Application Gateway
// 19. Application Gateway
// https://github.com/Azure/bicep-registry-modules/tree/main/avm/res/network/application-gateway
module appgwModule 'br/public:avm/res/network/application-gateway:0.7.2' = {
name: 'appgwModule'
Expand Down
Loading