[User Guide] Upgrade from v0.3.3 to v0.4.0 - Azure/terraform-azurerm-caf-enterprise-scale GitHub Wiki
Overview
As part of upgrade from release 0.3.3 to 0.4.0, the Terraform Module for Cloud Adoption Framework Enterprise-scale includes a number of breaking changes.
This update provides a number of new features, helps keep this module up to date with the latest reference architecture published in the Azure/Enterprise-Scale repository, and to support the latest releases of Terraform and the AzureRM Provider.
Required actions
Anyone using this module should be aware of the following when planning to upgrade from release 0.3.3 to 0.4.0:
-
A select number of policies and roles provided as part of this module will be redeployed. Please carefully review the output of
terraform planto ensure there are no issues with any custom configuration within your root module. -
The following library template types will need checking for references to policies as listed in the resource changes section below:
- Archetype Definitions
- Policy Assignments
- Policy Set Definitions
-
All Policy Assignments (and associated Role Assignments where a Managed Identity is required for policies with DeployIfNotExists or Modify effects) will be recreated to support moving these from the
azurerm_policy_assignment(deprecated) toazurerm_management_group_policy_assignmentresource types. -
Adds provider configuration within the module, allowing creation of resources across multiple Subscriptions. This impacts existing Management and monitoring resources. To avoid the need to re-create these resources, please review the management resources section below. Please also review the provider configuration page for more detail on how you should configure this in your module declaration.
-
Adds new functionality to enable deployment of Network topology and connectivity resources into the connectivity Subscription context. Currently based on the hub & spoke deployment model.
-
Adds new functionality to manage Policy Assignments as part of delivering the Identity and access management
Resource changes
The following changes have been made within the module which may cause issues when using custom archetype definitions:
-
The following Policy Definition changes have been included in the
es_rootarchetype definition:Audit-MachineLearning-PrivateEndpointIdaddedDeny-MachineLearning-AksaddedDeny-MachineLearning-Compute-SubnetIdaddedDeny-MachineLearning-Compute-VmSizeaddedDeny-MachineLearning-ComputeCluster-RemoteLoginPortPublicAccessaddedDeny-MachineLearning-ComputeCluster-ScaleaddedDeny-MachineLearning-HbiWorkspaceaddedDeny-MachineLearning-PublicAccessWhenBehindVnetaddedDeny-PublicEndpoint-AksremovedDeny-PublicEndpoint-CosmosDBremovedDeny-PublicEndpoint-KeyVaultremovedDeny-PublicEndpoint-MySQLremovedDeny-PublicEndpoint-PostgreSqlremovedDeny-PublicEndpoint-SqlremovedDeny-PublicEndpoint-StorageremovedDeploy-Default-UdraddedDeploy-Diagnostics-ActivityLogremovedDeploy-Diagnostics-AKSremovedDeploy-Diagnostics-BatchremovedDeploy-Diagnostics-DataLakeStoreremovedDeploy-Diagnostics-EventHubremovedDeploy-Diagnostics-KeyVaultremovedDeploy-Diagnostics-LogicAppsWFremovedDeploy-Diagnostics-RecoveryVaultremovedDeploy-Diagnostics-SearchServicesremovedDeploy-Diagnostics-ServiceBusremovedDeploy-Diagnostics-SQLDBsremovedDeploy-Diagnostics-StreamAnalyticsremovedDeploy-DNSZoneGroup-For-Blob-PrivateEndpointremovedDeploy-DNSZoneGroup-For-File-PrivateEndpointremovedDeploy-DNSZoneGroup-For-KeyVault-PrivateEndpointremovedDeploy-DNSZoneGroup-For-Queue-PrivateEndpointremovedDeploy-DNSZoneGroup-For-Sql-PrivateEndpointremovedDeploy-DNSZoneGroup-For-Table-PrivateEndpointremovedDeploy-HUBremovedDeploy-LA-ConfigremovedDeploy-Log-AnalyticsremovedDeploy-vHUBremovedDeploy-vNetremovedDeploy-vWANremoved
-
The following Policy Set Definition changes have been included in the
es_rootarchetype definition:Deny-PublicEndpointsreplaced withDeny-PublicPaaSEndpointsDeploy-Diag-LogAnalyticsreplaced withDeploy-Diagnostics-LogAnalyticsDeploy-Private-DNS-Zonesadded
-
The following Policy Assignment changes have been included
es_connectivityarchetype definition:Enable-DDoS-VNETadded
-
The following Policy Assignment changes have been included
es_corparchetype definition:Deny-Public-EndpointsaddedDeploy-Private-DNS-Zonesadded
-
The following Policy Assignment changes have been included
es_identityarchetype definition:Deny-Public-IPaddedDeny-RDP-From-InternetaddedDeny-Subnet-Without-NsgaddedDeploy-VM-Backupadded
-
The following Policy Assignment changes have been included
es_landing_zonesarchetype definition:Deny-http-Ingress-AKSremoved and replaced byEnforce-AKS-HTTPSDeploy-SQL-SecurityremovedDeploy-SQL-ThreataddedEnable-DDoS-VNETaddedEnforce-TLS-SSLadded
NOTE: All references to resource names are Case Sensitive. Failure to use the correct case will result in an
Invalid indexerror when runningterraform plan, such as the following example:
Error: Invalid index
on ../../modules/archetypes/locals.policy_definitions.tf line 82, in locals:
82: template = local.archetype_policy_definitions_map[policy]
|----------------
| local.archetype_policy_definitions_map is object with 100 attributes
The given key does not identify an element in this collection value.
Resource type: azurerm_policy_assignment
All azurerm_policy_assignment resources have been replaced by the azurerm_management_group_policy_assignment resource type.
Please see the next section for a list of further changes.
Resource type: azurerm_management_group_policy_assignment
All azurerm_policy_assignment resources have been replaced by the azurerm_management_group_policy_assignment resource type.
In addition to the resource type change, the following Policy Assignment changes are included in this update:
Deny-http-Ingress-AKShas been renamed toEnforce-AKS-HTTPSDeny-IP-Forwardingupdated display name and description fieldsDeny-Priv-Containers-AKSupdated display name and description fieldsDeny-Priv-Escalation-AKSupdated display name and description fieldsDeny-Public-EndpointsaddedDeny-Public-IPaddedDeny-RDP-From-Internetupdated display name and description fieldsDeny-Storage-httpupdated display name and description fieldsDeny-Subnet-Without-Nsgupdated display name and description fieldsDeny-Subnet-Without-Udrupdated display name and description fieldsDeploy-AKS-Policyupdated display name and description fieldsDeploy-ASC-Configurationadded (replacesDeploy-ASC-Defender)Deploy-Private-DNS-Zonesadded (still in development)Deploy-SQL-DB-Auditingupdated display name and description fieldsDeploy-SQL-ThreataddedDeploy-VM-Backupupdated display name and description fieldsDeploy-VM-Monitoringupdated display name and description fieldsDeploy-VMSS-Monitoringupdated display name and description fieldsDeploy-AzActivity-Logupdated to use new built-in Policy DefinitionDeploy-Log-Analyticsupdated to use new built-in Policy DefinitionDeploy-Resource-Diagupdated to use new customDeploy-Diagnostics-LogAnalyticsPolicy Set DefinitionEnable-DDoS-VNETaddedEnforce-TLS-SSLadded
Resource type: azurerm_policy_definition
All Policy Definition templates were updated to the latest apiVersion of 2021-06-01, although no impact as Terraform uses the Go SDK for interaction with Azure APIs.
A number of Policy Definition description fields were also updated, which will result in an in-place update of these.
The following Policy Definition changes are included in this update:
Append-AppService-latestTLShas been updated fromIndexedtoAllfor themodeattribute.Audit-MachineLearning-PrivateEndpointIdaddedDeny-MachineLearning-AksaddedDeny-MachineLearning-Compute-SubnetIdaddedDeny-MachineLearning-Compute-VmSizeaddedDeny-MachineLearning-ComputeCluster-RemoteLoginPortPublicAccessaddedDeny-MachineLearning-ComputeCluster-ScaleaddedDeny-MachineLearning-HbiWorkspaceaddedDeny-MachineLearning-PublicAccessWhenBehindVnetaddedDeploy-Default-UdraddedDeny-PublicEndpoint-AksremovedDeny-PublicEndpoint-CosmosDBremovedDeny-PublicEndpoint-KeyVaultremovedDeny-PublicEndpoint-MySQLremovedDeny-PublicEndpoint-PostgreSqlremovedDeny-PublicEndpoint-SqlremovedDeny-PublicEndpoint-StorageremovedDeny-Subnet-Without-Nsgnow includes a newexcludedSubnetsparameter to allow exclusions (default value =["GatewaySubnet", "AzureFirewallSubnet", "AzureFirewallManagementSubnet"])Deny-Subnet-Without-Udrnow includes a newexcludedSubnetsparameter to allow exclusions (default value =["AzureBastionSubnet"])Deny-VNET-Peer-Cross-Subhas been updated fromIndexedtoAllfor themodeattribute.Deny-VNet-Peeringhas been updated fromIndexedtoAllfor themodeattribute.Deploy-Default-UdraddedDeploy-Diagnostics-ActivityLogremovedDeploy-Diagnostics-AKSremovedDeploy-Diagnostics-BatchremovedDeploy-Diagnostics-DataLakeStoreremovedDeploy-Diagnostics-EventHubremovedDeploy-Diagnostics-KeyVaultremovedDeploy-Diagnostics-LogicAppsWFremovedDeploy-Diagnostics-RecoveryVaultremovedDeploy-Diagnostics-SearchServicesremovedDeploy-Diagnostics-ServiceBusremovedDeploy-Diagnostics-SQLDBsremovedDeploy-Diagnostics-StreamAnalyticsremovedDeploy-DNSZoneGroup-For-Blob-PrivateEndpointremovedDeploy-DNSZoneGroup-For-File-PrivateEndpointremovedDeploy-DNSZoneGroup-For-KeyVault-PrivateEndpointremovedDeploy-DNSZoneGroup-For-Queue-PrivateEndpointremovedDeploy-DNSZoneGroup-For-Sql-PrivateEndpointremovedDeploy-DNSZoneGroup-For-Table-PrivateEndpointremovedDeploy-HUBremovedDeploy-LA-ConfigremovedDeploy-Log-AnalyticsremovedDeploy-vHUBremovedDeploy-vNetremovedDeploy-VNET-HubSpokeupdate with newparametersandpolicyRuleconfigurationDeploy-vWANremoved
Resource type: azurerm_policy_set_definition
All Policy Set Definition templates were updated to the latest apiVersion of 2021-06-01, although no impact as Terraform uses the Go SDK for interaction with Azure APIs.
A number of Policy Set Definition description fields were also updated, which will result in an in-place update of these.
The following Policy Definition changes are included in this update:
Deny-PublicEndpointsrenamed toDeny-PublicPaaSEndpointsand updated with new configuration to reflect Policy Definition updatesDeploy-Diag-LogAnalyticsrenamed toDeploy-Diagnostics-LogAnalyticsand updated with new configuration to reflect Policy Definition updatesDeploy-Private-DNS-ZonesaddedEnforce-Encryption-CMKupdated to replace invalid unicode (whitespace) character
Management resources
As part of enabling support for multiple providers within the module to allow resources to be deployed to multiple Subscriptions within a single module declaration, it has been necessary to rename some resources within the module. These are all resources relating to the management solution within the module.
The following resources have been renamed:
| v0.3.x | v0.4.x |
|---|---|
| azurerm_automation_account.enterprise_scale[*] | azurerm_automation_account.management[*] |
| azurerm_log_analytics_linked_service.enterprise_scale[*] | azurerm_log_analytics_linked_service.management[*] |
| azurerm_log_analytics_solution.enterprise_scale[*] | azurerm_log_analytics_solution.management[*] |
| azurerm_log_analytics_workspace.enterprise_scale[*] | azurerm_log_analytics_workspace.management[*] |
| azurerm_resource_group.enterprise_scale[*] | azurerm_resource_group.management[*] |
This was necessary to allow the module to support deploying resources into different Subscriptions using dedicated providers for the core, management, and connectivity capabilities.
NOTE: The
identitycapability doesn't deploy any resources, as it configures Azure Policy on the Identity Management Group only. As such,identitydoesn't have a dedicated provider.
To prevent the need to redeploy these resources, you can simply run the terraform state mv command to move each updated resource within the state file before running terraform plan and terraform apply using the updated module version.
The following PowerShell script can be used to assist with this process, using a RegEx pattern to extract a list of the resources which should be updated, and then moving them to the target name:
[regex]$pattern = "(?<=module.([^.]+).(azurerm_resource_group|azurerm_log_analytics_workspace|azurerm_automation_account|azurerm_log_analytics_linked_service|azurerm_log_analytics_solution).)enterprise_scale"
[array]$(terraform state list) | ForEach-Object {
if ($pattern.IsMatch($_)) {
$newName = $pattern.Replace($_, "management")
Write-Host "Found resource to move..."
Write-Host " - Current resource name : $($_)"
Write-Host " - New resource name : $($newName)"
# Comment out the following line to check the script is proposing the expected resource moves.
terraform state mv $($_ -replace '"', '\"') $($newName -replace '"', '\"')
}
}
IMPORTANT: Whilst every effort has been made to ensure this script works correctly in a test environment, it may behave differently in your environment. Therefore we strongly recommend to backup your Terraform State files before attempting to run/use this script. As described in the MIT license associated with this repository, this script is provided as-is with no warranty or liability associated with its use.
Unfortunately it is not possible to take this approach with the azurerm_policy_assignment (deprecated) resources, as these are being changed to a different resource type. As such, these resources will be redeployed as part of the upgrade process.
To provide consistency across Connectivity, Identity, and Management resource configuration, the [currently undocumented] configure_management_resources.advanced.custom_settings_by_resource_type configuration object has also been updated to follow a consistent schema.
Outputs
In line with the changes above, the module outputs have also been restructured to better reflect the resource naming.
This includes:
- Management Groups are now output by the actual resource name (i.e.
level_1,level_2,level_3,level_4,level_5,level_6instead ofenterprise_scale) - Additional outputs are added to reflect the updated
managementresources and newconnectivityresources.
Next steps
Take a look at the latest User Guide documentation and our Examples to understand the latest module configuration options, and review your implementation against the changes documented on this page.