Deploy the Microsoft Cloud Adoption Framework enterprise-scale module
Microsoft's Cloud Adoption Framework (CAF) for Azure is a collection of documentation, tools, and best practices that guide organizations through cloud adoption. The framework sets up landing zones, which are pre-configured environments where you can host your workloads. These landing zones implement best practices in governance, networking, and identity management that allow you to securely scale your workloads. There are two strategies to implement the Cloud Adoption Framework in your organization:
- Start with enterprise scale to deploy fully integrated landing zones with governance, security, networking, and more.
- Start small and expand to deploy landing zones that have the basic landing zones considerations, these include compute, storage, networking and database decisions. You can supplement these landing zones with governance and management layers in the future.
Each strategy includes a corresponding Terraform module to help you deploy resources according to the strategy guidelines. Every organization is unique, so you must consider different trade-offs of each approach when you deploy landing zones.
In this tutorial, you will use the caf-enterprise-scale
Terraform module to:
- deploy the core and demo landing zones. The core landing zones manage and organize user workloads to provide the services and governance that the CAF recommends. The demo landing zones represent sample landing zones that your infrastructure team would deploy to give downstream teams access to infrastructure for their workloads.
- deploy a custom landing zone. This simulates a workflow you can use to deploy landing additional, CAF-compliant infrastructure for teams within your organization.
- add logging and security with the management submodule.
- create subnets, DNS zones, and policies with the connectivity module.
In the process, you will review the module configuration to help you tailor the module to your organization's priorities and enable sustainable scale.
Prerequisites
This tutorial assumes that you are familiar with the standard Terraform workflow. If you are new to Terraform, complete the Get Started tutorials first.
For this tutorial, you will need:
- the Terraform 1.0.4+ CLI installed locally.
- an Azure account with one or more Subscriptions.
- a configured Azure CLI.
Note
Some of the infrastructure in this tutorial may not qualify for the Azure free tier. Destroy the infrastructure at the end of the tutorial to avoid unnecessary charges. We are not responsible for any charges that you incur.
Clone the example repository
In your terminal, clone the example repository.
Navigate to the cloned repository.
Explore the configuration
This repository contains the configuration to deploy the core and demo landing zones according to the Cloud Adoption Framework guidance for the enterprise scale strategy. The module will deploy the demo landing zones in the Landing Zones
management group that are part of the core landing zones.
Here, you will find the following files:
the
terraform.tf
file defines the provider versions this configuration uses. The module requires anazurerm
provider version2.77.0
or greater.the
.terraform.lock.hcl
file ensures that Terraform uses the same provider versions for each run.the
providers.tf
file defines the three Azure providers this configuration uses. This configuration supports multi-subscription workloads, so that different teams can manage each submodule. If you do not provide a subscription ID (as a Terraform variable) for management or connectivity, the management and connectivity Azure providers default to the current subscription.the
main.tf
file configures thecaf-enterprise-scale
module. This configuration deploys the core and demo landing zones in the current subscription and thedefault_location
. Thedefault_location
defaults touseast
, as defined byterraform.tfvars.example
.the
client.tf
file contains data sources that retrieve your current subscription ID.the
variables.tf
file declares the configuration's input variables. Each variable has a description and a default value.the
terraform.tfvars.example
file defines values for the variables declared in thevariables.tf
file.the
locals.tf
file converts the input variables to local values. Assigning input variables to local values enables you to modify the values before you use them throughout the configuration.Take note of the
subscription_id_management
andsubscription_id_connectivity
local values.locals.tfThis configuration supports multi-subscription workloads, but uses the
coalesce()
Terraform function to default to your account's default subscription ID if you do not set thesubscription_id_management
andsubscription_id_connectivity
input variables.
Deploy enterprise-scale resources
The caf-enterprise-scale
Terraform module provides an opinionated way to deploy and manage the core platform capabilities defined in the enterprise-scale landing zone architecture documentation. The module creates the core resources, which include management groups, policies, and roles, that make it easier to organize and manage your other landing zone. In addition, the module includes three submodules; each one creates management group(s) with policies scoped the resources they manage:
- The management submodule adds a central Log Analytics workspace and Automation Account and enables Azure Security Center.
- The connectivity submodule creates guidelines for networks by defining common policies. In addition, this submodule creates an Azure Firewall and configures subnets and DNS zones.
- The identity submodule creates policies to manage compliance and security.
The core landing zones create management groups for Decommissioned
, Landing zones
, Platform
, and Sandboxes
. The CAF recommends these landing zones to manage and organize your workloads. You can also configure the module to provision Online
, Corp
, and SAP
demo landing zones. These landing zones represent ones that your organization may set up to migrate your workloads to Azure.
Deploy the core and demo enterprise scale landing zones.
First, rename the terraform.tfvars.example
to terraform.tfvars
.
Then, in terraform.tfvars
, replace the security contact email address with your email address.
Next, initialize the Terraform configuration.
Finally, apply the configuration. It may take a while for Terraform to generate the execution plan — the caf-enterprise-scale
module provisions 187 resources. Once prompted, respond yes
to confirm.
Tip
Deploying the core enterprise scale resources takes an average of 30 minutes. Review the caf-enterprise-scale
module while you wait for Terraform to finish provisioning these resources.
Review the configuration by reading the next section while you wait.
Review caf-enterprise-scale
module
The current main.tf
configuration deploys the core and demo landing zones by setting the following module arguments to true
. The local.deploy_*_landing_zones
are set to true in the terraform.tfvars
file.
In this section, you will review the caf-enterprise-scale
module configuration to understand how the module arguments modify the architecture that the module provisions.
When Terraform initializes the configuration, it downloads the providers and modules used into the .terraform
directory. For this configuration, Terraform stores a copy of the caf-enterprise-scale
module in the .terraform/modules
directory.
Terraform stores the module under the module name as the name defined in the main.tf
file (enterprise_scale
) and not the module source (caf-enterprise-scale
).
This module uses local values and submodules to manipulate the input variables into data structures. The submodule configuration is in the modules
directory, and the rest of the configuration primarily consists of two types of files:
- The
locals.*.tf
files parse and manipulate the variables. - The respective
resources.*tf
files use the local values to configure resources.
For example, the locals.management_groups.tf
file creates the local values that resources.management_groups.tf
consumes.
Review core and demo landing zones
The caf-enterprise-scale
module uses a similar pattern for each of the landing zones you can provision. Review the configuration for the core landing zones; the deploy_core_landing_zones
argument in the configuration toggles the core landing zones deployment.
Run the following command to find references of deploy_core_landing_zones
in the .terraform/modules/enterprise_scale
directory. It only searches files that end in .tf
.
Tip
You can find all instances of deploy_core_landing_zones
by searching in the caf-enterprise-scale
GitHub repository.
This argument appears in three files: variables.tf
, locals.tf
, and locals.management_groups.tf
.
The
.terraform/modules/enterprise_scale/locals.tf
file sets thedeploy_core_landing_zones
local value to the value of the input variable. Assigning input variables to local values lets you modify the variables before you use them throughout the configuration.The
.terraform/modules/enterprise_scale/variables.tf
file declares thedeploy_core_landing_zones
input variable. It sets the default value totrue
..terraform/module/enterprise_scale/variables.tfThe
.terraform/modules/enterprise_scale/locals.management_groups.tf
file uses thelocal.deploy_core_landing_zones
to determine whether to assign a list of recommended landing zones.Find
es_core_landing_zones_to_include
..terraform/modules/enterprise_scale/locals.management_groups.tfIf
deploy_core_landing_zones
is set to true, it setses_core_landing_zones_to_include
local value to thees_core_landing_zones
local value. Otherwise, it sets the value tonull
. This makes the module more dynamic, only provisioning the core landing zones if enabled.Find the
es_core_landing_zones
local value. This local value interpolates input information including theroot_name
androot_id
to create a data structure that defines customized core management groups for all of the CAF-recommended landing zones..terraform/modules/enterprise_scale/locals.management_groups.tfFind the
es_landing_zones_merge
local value..terraform/modules/enterprise_scale/locals.management_groups.tfNotice that this local value uses
merge
to combine thees_core_landing_zones_to_include
local value with the other landing zones, including the demo landing zones andcustom_landing_zone
.Find the
es_landing_zones_map
local value..terraform/modules/enterprise_scale/locals.management_groups.tfThis local value iterates through
es_landing_zones_merge
and automatically generates the management groups, populating them with default values.Find the
azurerm_management_group_level_*
local values..terraform/modules/enterprise_scale/locals.management_groups.tfThese local values take the landing zones listed in
es_landing_zones_map
and organize them according to their hierarchy.
Open resources.management_groups.tf
. This file defines and deploys the management groups. The parent_management_group_id
argument creates dependencies between different groups.
Since the demo landing zones are merged into es_landing_zones_merge
, the module deploys all of the enabled zones, including the demo landing zones, when you apply your configuration.
The caf-enterprise-module
also creates archetypes, which define the Azure Policy and Access control (IAM) settings needed to secure and configure the landing zones. This includes creating guidelines for role-based access control (RBAC) settings, security settings, and common workload configurations. The module uses es_landing_zones_map
and the archetypes
submodule to create the landing zone archetypes.
The ./modules/archetypes
submodule creates and assigns the policies and roles for each management group. The locals.*_definitions.tf
files contain the definition; the locals.*_assignments.tf
files contain the assignment. These files reference the roles and policies defined in their respective directories in ./modules/archetypes/lib
.
Tip
Use grep
, GitHub search, or any search alternative to navigate the module configuration and find where the module references a particular local
value.
Verify core and demo landing zones
Once Terraform finishes applying your resources, open the Azure Portal's Management group page. Here, you will find the management groups provisioned by the caf-enterprise-scale
module.
Click the Expand/Collapse all button to view all the management groups in the Learn Terraform ES management group.
Under Landing Zones, notice there are three management groups (Corp, Online, and SAP), each one mapping to the demo landing zones you defined in the enterprise-scale
module.
Deploy custom landing zones
Now that you have deployed the core and demo landing zones, deploy a custom landing zone with the caf-enterprise-scale
module. You will follow this workflow to deploy landing zones within your organization.
Define a new management group with default policies and access control (IAM) settings by adding the following code snippet to the enterprise_scale
module in main.tf
.
Next, apply the configuration. Once prompted, respond yes
to deploy the custom landing zone. The module automatically nests the custom landing zone in the root parent management group.
The module defines custom landing zones using the same patterns as the core and demo landing zones.
Verify custom landing zone
Once the deployment completes, open the Azure Portal's Management group page.
Under Landing Zones, there is a new landing zone named "LearnTerraform".
Select the LearnTerraform landing zone to review its policies and access control (IAM) settings, which follow Microsoft's best practices. The caf-enterprise-scale
module codifies these recommendations, helping you easily provision secure and scalable cloud environments.
Select Access control (IAM) in the left navigation, then Roles. You will find a CustomRole
named [TF-CAFES] Network-Subnet-Contributor, a standard role defined by the module.
Deploy management resources
In this section, you will deploy a new management group that will enable logging and security resources, covering all your landing zones.
Add the following code snippet to the enterprise_scale
module block in main.tf
.
Tip
Add subscription_id_management = SUBSCRIPTION_ID
to your terraform.tfvars
file to deploy your management resources in another subscription.
Next, create a new file named settings.management.tf
with the following configuration to enable Log Analytics and Security Center in the new landing zone.
This configuration defines a local
value that the caf-enterprise-scale
modules uses to configure the management resource settings including enabling log analytics and Azure Security Center.
Next, apply the configuration. Once prompted, respond yes
to deploy the custom landing zone.
Review management
submodule
The management
submodule deploys the management group and subscription organization by setting the following module arguments:
The deploy_management_resources
is set to true
to enable the submodule.
The configure_management_resources
argument customizes the management resources. The settings in settings.management.tf
enable log analytics and Azure Security Center.
The subscription_id_management
sets the management subscription ID. This is useful if you want to deploy management resources in another subscription. Otherwise, this defaults to your current subscription.
Like the core resources, review how the caf-enterprise-scale
module deploys and customizes the management resources.
First, open resources.management.tf
.
Notice that this module deploys resource groups defined by the azurerm_resource_group_management
resource.
Open locals.management.tf
.
The azurerm_resource_group_management
local value depends on es_management_resource_groups
, which is defined by the module.management_resources
submodule.
In .terraform/modules/enterprise_scale/management/outputs.tf
, configuration
maps to local.module_output
. Open .terraform/modules/enterprise_scale/management/locals.tf
and find module_output
to review how the management
submodule defines the resource group configuration and adds logging and Security Center to it.
Verify management resources
After Terraform applies your changes, open the Azure Portal's Management group page.
Under Platform, find and click the subscription in the "Management" management group.
The deploy_management_resources
argument enables log analytics and Azure Security Center for this subscription. Verify this subscription has Security Center by clicking Security from the left navigation menu.
Deploy connectivity resources
Add the following configuration to the enterprise_scale
module block in main.tf
Tip
Add subscription_id_connectivity = SUBSCRIPTION_ID
to your terraform.tfvars
file to deploy your connectivity resources in another subscription.
This defines a new management group with default policies and access control (IAM) settings. In addition, it creates a centralized hub so your organization can connect with on-premise resources, secures the network with Azure Firewall, and centrally manages the DNS zones.
Next, apply the configuration. Once prompted, respond yes
to deploy the custom landing zone.
Tip
Deploying the connectivity resources takes an average of 30 minutes. Review connectivity
submodule while you wait for Terraform to finish provisioning these resources.
Review connectivity
submodule
The module deploys the connectivity resources by setting the following module arguments.
The deploy_connectivity_resources
is true
. This enables the connectivity
submodule.
The subscription_id_connectivity
sets the management subscription ID. This is useful if you want to deploy management resources in another subscription. Otherwise, this defaults to your current subscription.
The module deploys the connectivity resources very similarly to the management resources.
First, open resources.connectivity.tf
to find all the connectivity resources this module deploys, including resource groups, virtual network, and subnets.
The resources in this file reference local values for their definitions. Open locals.connectivity.tf
to view these local values.
Similarly to the management local values, the connectivity local values are defined in the connectivity
submodule. Review the connectivity submodule's outputs.tf
and locals.tf
files to understand how it parses and creates the downstream local values.
Verify connectivity resources
Once the deployment completes, open the Azure Portal's Subscription page page and select your subscription. Then, click Resource groups on the left navigation menu.
Filter the resource groups on tf-cafes
.
You should find a total of four resource groups. The connectivity submodule created the tf-cafes-connectivity-eastus
and tf-cafe-dns
resource groups for all the resources it provisioned.
The tf-cafes-connectivity-eastus
resource group contains a single virtual network named tf-cafes-hub-eastus
. The caf-enterprise-scale
module pre-configured the virtual network with subnets for GatewaySubnet
and AzureFirewallSubnet
. The DDos Protection Standard is disabled to save costs for this tutorial. Enable this in production environments.
The tf-cafes-dns
resource group creates all the DNS resources. Even though the resource group is in useast
(as defined by the `default_location input value), the DNS resources are all global resources. By default, the module creates a private DNS Zone for all services and connects each private DNS zone to the virtual network.
Clean up resources
Before moving on, destroy the infrastructure you created in this tutorial.
Tip
Destroying the enterprise scale resources deployed in this tutorial takes an average of 20 minutes.
Be sure to respond to the confirmation prompt with yes
.
Next steps
Over the course of this tutorial, you used the caf-enterprise-scale
module to deploy the core, management, and connectivity resources as defined by the Cloud Adoption Framework. In the process, you reviewed the module configuration to understand how the module operates behind-the-scenes. Now, you are equipped with the skills to better tailor the module to your organization's priorities and set your organization on a path to sustainable scale.
For more information on topics covered in this tutorial, check out the following resources.