Skip to content

Commit

Permalink
Breestryker/restructure code (#699)
Browse files Browse the repository at this point in the history
* So many renames.

* Fix mlz.bicep.

* Add brief readmes to core and module.

* GitHub Action: Build Bicep to JSON

Co-authored-by: Bree Stryker <[email protected]>
Co-authored-by: github-actions <[email protected]>
  • Loading branch information
3 people authored Apr 4, 2022
1 parent f261f1d commit 8d4ff53
Show file tree
Hide file tree
Showing 53 changed files with 86 additions and 75 deletions.
2 changes: 1 addition & 1 deletion .azure-devops/nightlybuild/templates/az-deployment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,5 @@ steps:
--subscription ${{ parameters.WorkloadSubId }} \
--location ${{ parameters.Location }} \
--name ${{ parameters.WorkloadName }} \
--template-file $(Build.SourcesDirectory)/src/bicep/examples/newWorkload/newWorkload.bicep \
--template-file $(Build.SourcesDirectory)/src/bicep/examples/tier3/tier3.bicep \
--parameters resourcePrefix=$datetime
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ deploymentVariables.json
src/bicep/examples/appServicePlan/appService.json
src/bicep/examples/containerRegistry/contRegistry.json
src/bicep/examples/keyVault/azureKeyVault.json
src/bicep/examples/newWorkload/newWorkload.json
src/bicep/examples/tier3/tier3.json
4 changes: 2 additions & 2 deletions docs/deployment-guide-bicep.md
Original file line number Diff line number Diff line change
Expand Up @@ -221,9 +221,9 @@ params: {

MLZ allows for deploying one or many workloads that are peered to the hub network. Each workload can be in its own subscription or multiple workloads may be combined into a single subscription.

A separate Bicep template is provided for deploying an empty workload. It deploys a virtual network, a route table, a network security group, a storage account (for logs), and a network peering to the hub network. The template is at [src/bicep/examples/newWorkload](../src/bicep/examples/newWorkload). You can use this template as a starting point to create and customize specific workload deployments.
A separate Bicep template is provided for deploying an empty workload. It deploys a virtual network, a route table, a network security group, a storage account (for logs), and a network peering to the hub network. The template is at [src/bicep/add-ons/tier3](../src/bicep/add-ons/tier3). You can use this template as a starting point to create and customize specific workload deployments.

The `newWorkload` template contains defaults for IP address ranges, but additional workloads will require planning for additional ranges. The following parameters affect `newWorkload` networking:
The `tier3` template contains defaults for IP address ranges, but additional workloads will require planning for additional ranges. The following parameters affect `tier3` networking:

Parameter name | Default Value | Description
-------------- | ------------- | -----------
Expand Down
2 changes: 1 addition & 1 deletion docs/deployment-guide-terraform.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ MLZ allows for deploying one or many workloads that are peered to the hub networ

A separate Terraform template is provided for deploying an empty workload `src/terraform/tier3`. You can use this template as a starting point to create and customize specific workload deployments.

The following parameters affect newWorkload networking. To override the defaults edit the variables file at [`src/terraform/tier3/variables.tf`](../src/terraform/tier3/variables.tf).
The following parameters affect tier3 networking. To override the defaults edit the variables file at [`src/terraform/tier3/variables.tf`](../src/terraform/tier3/variables.tf).

Parameter name | Default Value | Description
-------------- | ------------- | -----------
Expand Down
2 changes: 1 addition & 1 deletion docs/policies.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ Or, you can apply policy after deploying MLZ:
az deployment group create \
--resource-group <Resource Group to assign> \
--name <original deployment name + descriptor> \
--template-file ./src/bicep/modules/policyAssignment.bicep \
--template-file ./src/bicep/modules/policy-assignment.bicep \
--parameters builtInAssignment=<one of 'CMMC', 'IL5', or 'NIST'> logAnalyticsWorkspaceName=<Log analytics workspace name> \
--parameters logAnalyticsWorkspaceName=<Log Analytics Workspace Name> \
--parameters logAnalyticsWorkspaceResourceGroupName=<Log Analytics Workspace Resource Group Name>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ Once you have the Mission LZ output values, you can pass those in as parameters
For example, deploying using the `az deployment group create` command in the Azure CLI:

```bash
cd examples/remoteAccess
cd add-ons/remote-access

hubResourceGroupName="mlz-dev-hub"
hubVirtualNetworkName="hub-vnet"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ var defaultTags = {
}
var calculatedTags = union(tags, defaultTags)

module remoteAccess '../../modules/remoteAccess.bicep' = {
module remoteAccess '../../core/remote-access.bicep' = {
name: 'deploy-remoteAccess-Example-${nowUtc}'
params: {
location: location
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ virtualNetworkAddressPrefix | 10.0.125.0/26 | The address prefix for the network

### Generate MLZ Variable File

For instructions on generating 'deploymentVariables.json' using both Azure PowerShell and Azure CLI, please see the [README at the root of the examples folder](..\README.md).
For instructions on generating 'deploymentVariables.json' using both Azure PowerShell and Azure CLI, please see the [README at the root of the examples folder](..\examples\README.md).

Place the resulting 'deploymentVariables.json' file within the ./src/bicep/examples folder.
Place the resulting 'deploymentVariables.json' file within the ./src/bicep/add-ons folder.

## Deploy the example

Expand All @@ -42,24 +42,24 @@ And deploy with `az deployment sub create` from the Azure CLI or `New-AzSubscrip

### Deploying the new workload

Connect to the appropriate Azure Environment and set appropriate context, see [getting started with Azure PowerShell or Azure CLI](..\README.md) for help if needed. The commands below assume you are deploying in Azure Commercial and show the entire process from deploying MLZ and then adding an Azure App Service Plan post-deployment.
Connect to the appropriate Azure Environment and set appropriate context, see [getting started with Azure PowerShell or Azure CLI](..\examples\README.md) for help if needed. The commands below assume you are deploying in Azure Commercial and show the entire process from deploying MLZ and then adding an Azure App Service Plan post-deployment.

```PowerShell
cd .\src\bicep
Connect-AzAccount
New-AzSubscriptionDeployment -Name contoso -TemplateFile .\mlz.bicep -resourcePrefix 'contoso' -Location 'eastus'
cd .\examples
cd .\add-ons
(Get-AzSubscriptionDeployment -Name contoso).outputs | ConvertTo-Json | Out-File -FilePath .\deploymentVariables.json
cd .\newWorkload
New-AzSubscriptionDeployment -DeploymentName deployNewWorkload -TemplateFile .\newWorkload.bicep -resourcePrefix myWorkload -Location 'eastus'
cd .\tier3
New-AzSubscriptionDeployment -DeploymentName deployTier3 -TemplateFile .\tier3.bicep -resourcePrefix myTier3 -Location 'eastus'
```

```Azure CLI
az login
cd src/bicep
az deployment sub create -n contoso -f mlz.bicep -l eastus --parameters resourcePrefix=contoso
cd examples
cd add-ons
az deployment sub show -n contoso --query properties.outputs > ./deploymentVariables.json
cd newWorkload
az deployment sub create -n deployNewWorkload -f newWorkload.bicep -l eastus --parameters resourcePrefix='myWorkload'
cd tier3
az deployment sub create -n deployTier3 -f tier3.bicep -l eastus --parameters resourcePrefix='myTier3'
```
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ param hubVirtualNetworkName string
param spokeVirtualNetworkName string
param spokeVirtualNetworkResourceId string

module hubToSpokeVirtualNetworkPeering '../../../modules/virtualNetworkPeering.bicep' = {
module hubToSpokeVirtualNetworkPeering '../../../modules/virtual-network-peering.bicep' = {
scope: resourceGroup(hubResourceGroupName)
name: 'hubToSpokeVirtualNetworkPeering'
params: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ var defaultTags = {
}
var calculatedTags = union(tags, defaultTags)

module resourceGroup '../../modules/resourceGroup.bicep' = {
module resourceGroup '../../modules/resource-group.bicep' = {
name: workloadResourceGroupName
params: {
name: workloadResourceGroupName
Expand All @@ -125,7 +125,7 @@ module resourceGroup '../../modules/resourceGroup.bicep' = {
}
}

module spokeNetwork '../../modules/spokeNetwork.bicep' = {
module spokeNetwork '../../core/spoke-network.bicep' = {
name: 'spokeNetwork'
scope: az.resourceGroup(resourceGroup.name)
params: {
Expand Down Expand Up @@ -154,7 +154,7 @@ module spokeNetwork '../../modules/spokeNetwork.bicep' = {
}
}

module workloadVirtualNetworkPeerings '../../modules/spokeNetworkPeering.bicep' = {
module workloadVirtualNetworkPeerings '../../core/spoke-network-peering.bicep' = {
name: take('${workloadName}-to-hub-vnet-peering', 64)
params: {
spokeName: workloadName
Expand All @@ -166,7 +166,7 @@ module workloadVirtualNetworkPeerings '../../modules/spokeNetworkPeering.bicep'
}
}

module hubToWorkloadVirtualNetworkPeering './modules/hubNetworkPeering.bicep' = {
module hubToWorkloadVirtualNetworkPeering './modules/hub-network-peering.bicep' = {
scope: subscription(hubSubscriptionId)
name: take('hub-to-${workloadName}-vnet-peering', 64)
params: {
Expand Down
5 changes: 5 additions & 0 deletions src/bicep/core/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Mission Landing Zone Core Bicep Templates

This folder contains the core bicep templates deploying Mission Landing Zone. These templates provide the core networking and functionality for the landing zone. These components make use of the modules in the [Modules](../modules/) folder.

See the [Deployment Guide for Bicep](../../docs/deployment-guide-bicep.md) for detailed instructions on how to use these templates.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Licensed under the MIT License.
param hubVirtualNetworkName string
param spokes array

module hubToSpokePeering './virtualNetworkPeering.bicep' = [ for spoke in spokes: {
module hubToSpokePeering '../modules/virtual-network-peering.bicep' = [ for spoke in spokes: {
name: 'hub-to-${spoke.type}-vnet-peering'
params: {
name: '${hubVirtualNetworkName}/to-${spoke.virtualNetworkName}'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ param supportedClouds array = [
'AzureUSGovernment'
]

module logStorage './storageAccount.bicep' = {
module logStorage '../modules/storage-account.bicep' = {
name: 'logStorage'
params: {
storageAccountName: logStorageAccountName
Expand All @@ -86,7 +86,7 @@ module logStorage './storageAccount.bicep' = {
}
}

module networkSecurityGroup './networkSecurityGroup.bicep' = {
module networkSecurityGroup '../modules/network-security-group.bicep' = {
name: 'networkSecurityGroup'
params: {
name: networkSecurityGroupName
Expand All @@ -103,7 +103,7 @@ module networkSecurityGroup './networkSecurityGroup.bicep' = {
}
}

module virtualNetwork './virtualNetwork.bicep' = {
module virtualNetwork '../modules/virtual-network.bicep' = {
name: 'virtualNetwork'
params: {
name: virtualNetworkName
Expand Down Expand Up @@ -137,7 +137,7 @@ module virtualNetwork './virtualNetwork.bicep' = {
}
}

module routeTable './routeTable.bicep' = {
module routeTable '../modules/route-table.bicep' = {
name: 'routeTable'
params: {
name: routeTableName
Expand Down Expand Up @@ -171,7 +171,7 @@ resource subnet 'Microsoft.Network/virtualNetworks/subnets@2021-02-01' = {
]
}

module firewallClientPublicIPAddress './publicIPAddress.bicep' = {
module firewallClientPublicIPAddress '../modules/public-ip-address.bicep' = {
name: 'firewallClientPublicIPAddress'
params: {
name: firewallClientPublicIPAddressName
Expand All @@ -190,7 +190,7 @@ module firewallClientPublicIPAddress './publicIPAddress.bicep' = {
}
}

module firewallManagementPublicIPAddress './publicIPAddress.bicep' = {
module firewallManagementPublicIPAddress '../modules/public-ip-address.bicep' = {
name: 'firewallManagementPublicIPAddress'
params: {
name: firewallManagementPublicIPAddressName
Expand All @@ -209,7 +209,7 @@ module firewallManagementPublicIPAddress './publicIPAddress.bicep' = {
}
}

module firewall './firewall.bicep' = {
module firewall '../modules/firewall.bicep' = {
name: 'firewall'
params: {
name: firewallName
Expand Down Expand Up @@ -238,7 +238,7 @@ module firewall './firewall.bicep' = {
}
}

module azureMonitorPrivateLink './privateLink.bicep' = if ( contains(supportedClouds, environment().name) ){
module azureMonitorPrivateLink '../modules/private-link.bicep' = if ( contains(supportedClouds, environment().name) ){
name: 'azure-monitor-private-link'
params: {
logAnalyticsWorkspaceName: logAnalyticsWorkspaceName
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ resource hubVirtualNetwork 'Microsoft.Network/virtualNetworks@2021-02-01' existi
name: hubVirtualNetworkName
}

module bastionHost './bastionHost.bicep' = {
module bastionHost '../modules/bastion-host.bicep' = {
name: 'remoteAccess-bastionHost'

params: {
Expand All @@ -81,7 +81,7 @@ module bastionHost './bastionHost.bicep' = {
}
}

module linuxNetworkInterface './networkInterface.bicep' = {
module linuxNetworkInterface '../modules/network-interface.bicep' = {
name: 'remoteAccess-linuxNetworkInterface'
params: {
name: linuxNetworkInterfaceName
Expand All @@ -95,7 +95,7 @@ module linuxNetworkInterface './networkInterface.bicep' = {
}
}

module linuxVirtualMachine './linuxVirtualMachine.bicep' = {
module linuxVirtualMachine '../modules/linux-virtual-machine.bicep' = {
name: 'remoteAccess-linuxVirtualMachine'
params: {
name: linuxVmName
Expand All @@ -117,7 +117,7 @@ module linuxVirtualMachine './linuxVirtualMachine.bicep' = {
}
}

module windowsNetworkInterface './networkInterface.bicep' = {
module windowsNetworkInterface '../modules/network-interface.bicep' = {
name: 'remoteAccess-windowsNetworkInterface'
params: {
name: windowsNetworkInterfaceName
Expand All @@ -131,7 +131,7 @@ module windowsNetworkInterface './networkInterface.bicep' = {
}
}

module windowsVirtualMachine './windowsVirtualMachine.bicep' = {
module windowsVirtualMachine '../modules/windows-virtual-machine.bicep' = {
name: 'remoteAccess-windowsVirtualMachine'
params: {
name: windowsVmName
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ param spokeVirtualNetworkName string
param hubVirtualNetworkName string
param hubVirtualNetworkResourceId string

module spokeNetworkPeering './virtualNetworkPeering.bicep' = {
module spokeNetworkPeering '../modules/virtual-network-peering.bicep' = {
name: '${spokeName}-to-hub-vnet-peering'
scope: resourceGroup(spokeResourceGroupName)
params: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ param routeTableRouteAddressPrefix string = '0.0.0.0/0'
param routeTableRouteNextHopIpAddress string = firewallPrivateIPAddress
param routeTableRouteNextHopType string = 'VirtualAppliance'

module logStorage './storageAccount.bicep' = {
module logStorage '../modules/storage-account.bicep' = {
name: 'logStorage'
params: {
storageAccountName: logStorageAccountName
Expand All @@ -44,7 +44,7 @@ module logStorage './storageAccount.bicep' = {
}
}

module networkSecurityGroup './networkSecurityGroup.bicep' = {
module networkSecurityGroup '../modules/network-security-group.bicep' = {
name: 'networkSecurityGroup'
params: {
name: networkSecurityGroupName
Expand All @@ -61,7 +61,7 @@ module networkSecurityGroup './networkSecurityGroup.bicep' = {
}
}

module routeTable './routeTable.bicep' = {
module routeTable '../modules/route-table.bicep' = {
name: 'routeTable'
params: {
name: routeTableName
Expand All @@ -75,7 +75,7 @@ module routeTable './routeTable.bicep' = {
}
}

module virtualNetwork './virtualNetwork.bicep' = {
module virtualNetwork '../modules/virtual-network.bicep' = {
name: 'virtualNetwork'
params: {
name: virtualNetworkName
Expand Down
14 changes: 6 additions & 8 deletions src/bicep/examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,13 @@ You [must first deploy MissionLZ](../README.md#Deployment), then you can deploy

Example | Description
------- | -----------
[appServicePlan](./appServicePlan) | Deploys an App Service Plan (AKA: Web Server Cluster) to support simple web accessible linux docker containers with optional dynamic auto scaling.
[Automation Account](./automationAccount) | Deploys an Azure Automation account that can be used to execute runbooks.
[Container Registry](./containerRegistry/) | Deploys an Azure Container Registry for holding and deploying docker containers.
[Inherit Tags](./inheritTags) | Adds or replaces a specified tag and value from the parent resource group when any resource is created or updated.
[KeyVault](./keyVault/) | Deploys a premium Azure Key Vault with RBAC enabled to support secret, key, and certificate management.
[New Workload](./newWorkload) | Adds a new Spoke Network and peers it to the Hub Network routing all traffic to the Azure Firewall.
[Remote Access](./remoteAccess) | Adds a Bastion Host and a virtual machine to serve as a jumpbox into the network.
[appServicePlan](./app-service-plan) | Deploys an App Service Plan (AKA: Web Server Cluster) to support simple web accessible linux docker containers with optional dynamic auto scaling.
[Automation Account](./automation-account) | Deploys an Azure Automation account that can be used to execute runbooks.
[Container Registry](./container-registry/) | Deploys an Azure Container Registry for holding and deploying docker containers.
[Inherit Tags](./inherit-tags) | Adds or replaces a specified tag and value from the parent resource group when any resource is created or updated.
[KeyVault](./key-vault/) | Deploys a premium Azure Key Vault with RBAC enabled to support secret, key, and certificate management.
[Azure Sentinel](./sentinel) | A Terraform module that adds an Azure Sentinel solution to a Log Analytics Workspace. Sentinel can also be deployed via bicep and the base deployment of mlz.bicep by using the boolean param '-deploySentinel'.
[Zero Trust (TIC3.0) Workbook](./zeroTrustWorkbook) | Deploys an Azure Sentinel Zero Trust (TIC3.0) Workbook
[Zero Trust (TIC3.0) Workbook](./zero-trust-workbook) | Deploys an Azure Sentinel Zero Trust (TIC3.0) Workbook

## Shared Variable File Pattern (deploymentVariables.json)

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ param enableAutoScale bool = true
@description('Defines the performance tier of your web farm. By default the performance scale will be premium 2nd generation version 2 "p2v2". Another value would be standard generation 2 "s2".')
param appServiceSkuName string = 'p2v2'

@description('The deployment location being deployed to.')
param location string = deployment().location

@description('A string dictionary of tags to add to deployed resources. See https://docs.microsoft.com/en-us/azure/azure-resource-manager/management/tag-resources?tabs=json#arm-templates for valid settings.')
param tags object = {}
var defaultTags = {
Expand All @@ -29,7 +32,7 @@ var defaultTags = {
var calculatedTags = union(tags, defaultTags)

var targetSubscriptionId_Var = targetResourceGroup == '${mlzDeploymentVariables.spokes.Value[2].resourceGroupName}' ? '${mlzDeploymentVariables.spokes.Value[2].subscriptionId}' : subscription().subscriptionId
var location = deployment().location

var kind = 'linux'
var capacity = 2

Expand All @@ -39,7 +42,7 @@ resource targetASPResourceGroup 'Microsoft.Resources/resourceGroups@2020-10-01'
tags: calculatedTags
}

module appServicePlan 'modules/appServicePlan.bicep' = {
module appServicePlan './modules/app-service-plan.bicep' = {
name: appServicePlanName
scope: resourceGroup(targetSubscriptionId_Var, targetASPResourceGroup.name)
params: {
Expand All @@ -52,7 +55,7 @@ module appServicePlan 'modules/appServicePlan.bicep' = {
}
}

module appServicePlanSettings 'modules/appServiceSettings.bicep' = if (enableAutoScale) {
module appServicePlanSettings './modules/app-service-settings.bicep' = if (enableAutoScale) {
name: 'appServicePlanSettingsName'
scope: resourceGroup(targetSubscriptionId_Var, targetASPResourceGroup.name)
params: {
Expand Down
Loading

0 comments on commit 8d4ff53

Please sign in to comment.