The Features Block
The Azure Provider allows the behaviour of certain resources to be configured using the features
block.
This allows different users to select the behaviour they require, for example some users may wish for the OS Disks for a Virtual Machine to be removed automatically when the Virtual Machine is destroyed - whereas other users may wish for these OS Disks to be detached but not deleted.
Example Usage
If you wish to use the default behaviours of the Azure Provider, then you only need to define an empty features
block as below:
/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as azurerm from "./.gen/providers/azurerm";
/*The following providers are missing schema information and might need manual adjustments to synthesize correctly: azurerm.
For a more precise conversion please use the --provider flag in convert.*/
new azurerm.provider.AzurermProvider(this, "azurerm", {
features: [{}],
});
Each of the blocks defined below can be optionally specified to configure the behaviour as needed - this example shows all the possible behaviours which can be configured:
/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as azurerm from "./.gen/providers/azurerm";
/*The following providers are missing schema information and might need manual adjustments to synthesize correctly: azurerm.
For a more precise conversion please use the --provider flag in convert.*/
new azurerm.provider.AzurermProvider(this, "azurerm", {
features: [
{
api_management: [
{
purge_soft_delete_on_destroy: true,
recover_soft_deleted: true,
},
],
app_configuration: [
{
purge_soft_delete_on_destroy: true,
recover_soft_deleted: true,
},
],
application_insights: [
{
disable_generated_rule: false,
},
],
cognitive_account: [
{
purge_soft_delete_on_destroy: true,
},
],
key_vault: [
{
purge_soft_delete_on_destroy: true,
recover_soft_deleted_key_vaults: true,
},
],
log_analytics_workspace: [
{
permanently_delete_on_destroy: true,
},
],
managed_disk: [
{
expand_without_downtime: true,
},
],
resource_group: [
{
prevent_deletion_if_contains_resources: true,
},
],
template_deployment: [
{
delete_nested_items_during_deletion: true,
},
],
virtual_machine: [
{
delete_os_disk_on_deletion: true,
graceful_shutdown: false,
skip_shutdown_and_force_delete: false,
},
],
virtual_machine_scale_set: [
{
force_delete: false,
roll_instances_when_required: true,
scale_to_zero_before_deletion: true,
},
],
},
],
});
Arguments Reference
The features
block supports the following:
-
apiManagement
- (Optional) AnapiManagement
block as defined below. -
appConfiguration
- (Optional) AnappConfiguration
block as defined below. -
applicationInsights
- (Optional) AnapplicationInsights
block as defined below. -
cognitiveAccount
- (Optional) AcognitiveAccount
block as defined below. -
keyVault
- (Optional) AkeyVault
block as defined below. -
logAnalyticsWorkspace
- (Optional) AlogAnalyticsWorkspace
block as defined below. -
managedDisk
- (Optional) AmanagedDisk
block as defined below. -
resourceGroup
- (Optional) AresourceGroup
block as defined below. -
templateDeployment
- (Optional) AtemplateDeployment
block as defined below. -
virtualMachine
- (Optional) AvirtualMachine
block as defined below. -
virtualMachineScaleSet
- (Optional) AvirtualMachineScaleSet
block as defined below.
The apiManagement
block supports the following:
-
purgeSoftDeleteOnDestroy
- (Optional) Should theazurermApiManagement
resources be permanently deleted (e.g. purged) when destroyed? Defaults totrue
. -
recoverSoftDeleted
- (Optional) Should theazurermApiManagement
resources recover a Soft-Deleted API Management service? Defaults totrue
The appConfiguration
block supports the following:
-
purgeSoftDeleteOnDestroy
- (Optional) Should theazurermAppConfiguration
resources be permanently deleted (e.g. purged) when destroyed? Defaults totrue
. -
recoverSoftDeleted
- (Optional) Should theazurermAppConfiguration
resources recover a Soft-Deleted App Configuration service? Defaults totrue
*
The applicationInsights
block supports the following:
disableGeneratedRule
- (Optional) Should theazurermApplicationInsights
resources disable the Azure generated Alert Rule during the create step? Defaults tofalse
.
The cognitiveAccount
block supports the following:
purgeSoftDeleteOnDestroy
- (Optional) Should theazurermCognitiveAccount
resources be permanently deleted (e.g. purged) when destroyed? Defaults totrue
.
The keyVault
block supports the following:
purgeSoftDeleteOnDestroy
- (Optional) Should theazurermKeyVault
resource be permanently deleted (e.g. purged) when destroyed? Defaults totrue
.
\~> Note: When purge protection is enabled, a key vault or an object in the deleted state cannot be purged until the retention period (7-90 days) has passed.
-
purgeSoftDeletedCertificatesOnDestroy
- (Optional) Should theazurermKeyVaultCertificate
resource be permanently deleted (e.g. purged) when destroyed? Defaults totrue
. -
purgeSoftDeletedKeysOnDestroy
- (Optional) Should theazurermKeyVaultKey
resource be permanently deleted (e.g. purged) when destroyed? Defaults totrue
. -
purgeSoftDeletedSecretsOnDestroy
- (Optional) Should theazurermKeyVaultSecret
resource be permanently deleted (e.g. purged) when destroyed? Defaults totrue
. -
purgeSoftDeletedHardwareSecurityModulesOnDestroy
- (Optional) Should theazurermKeyVaultManagedHardwareSecurityModule
resource be permanently deleted (e.g. purged) when destroyed? Defaults totrue
. -
recoverSoftDeletedCertificates
- (Optional) Should theazurermKeyVaultCertificate
resource recover a Soft-Deleted Certificate? Defaults totrue
. -
recoverSoftDeletedKeyVaults
- (Optional) Should theazurermKeyVault
resource recover a Soft-Deleted Key Vault? Defaults totrue
. -
recoverSoftDeletedKeys
- (Optional) Should theazurermKeyVaultKey
resource recover a Soft-Deleted Key? Defaults totrue
. -
recoverSoftDeletedSecrets
- (Optional) Should theazurermKeyVaultSecret
resource recover a Soft-Deleted Secret? Defaults totrue
.
\~> Note: When recovering soft-deleted Key Vault items (Keys, Certificates, and Secrets) the Principal used by Terraform needs the "recover"
permission.
The logAnalyticsWorkspace
block supports the following:
permanentlyDeleteOnDestroy
- (Optional) Should theazurermLogAnalyticsWorkspace
be permanently deleted (e.g. purged) when destroyed? Defaults totrue
.
-> Note: This will be defaulted to false
in the next major version of the Azure Provider (4.0).
The managedDisk
block supports the following:
expandWithoutDowntime
- (Optional) Specifies whether Managed Disks which can be Expanded without Downtime (on either a Linux VM or a Windows VM) should be expanded without restarting the associated Virtual Machine. Defaults totrue
.
\~> Note: Expand Without Downtime requires a specific configuration for the Managed Disk and Virtual Machine - Terraform will use Expand Without Downtime when the Managed Disk and Virtual Machine meet these requirements, and shut the Virtual Machine down as needed if this is inapplicable. More information on when Expand Without Downtime is applicable can be found in the Linux VM or Windows VM documentation.
The resourceGroup
block supports the following:
preventDeletionIfContainsResources
- (Optional) Should theazurermResourceGroup
resource check that there are no Resources within the Resource Group during deletion? This means that all Resources within the Resource Group must be deleted prior to deleting the Resource Group. Defaults totrue
.
The templateDeployment
block supports the following:
deleteNestedItemsDuringDeletion
- (Optional) Should theazurermResourceGroupTemplateDeployment
resource attempt to delete resources that have been provisioned by the ARM Template, when the Resource Group Template Deployment is deleted? Defaults totrue
.
The virtualMachine
block supports the following:
deleteOsDiskOnDeletion
- (Optional) Should theazurermLinuxVirtualMachine
andazurermWindowsVirtualMachine
resources delete the OS Disk attached to the Virtual Machine when the Virtual Machine is destroyed? Defaults totrue
.
\~> Note: This does not affect the older azurermVirtualMachine
resource, which has its own flags for managing this within the resource.
gracefulShutdown
- (Optional) Should theazurermLinuxVirtualMachine
andazurermWindowsVirtualMachine
request a graceful shutdown when the Virtual Machine is destroyed? Defaults tofalse
.
\~> Note: When using a graceful shutdown, Azure gives the Virtual Machine a 5 minutes window in which to complete the shutdown process, at which point the machine will be force powered off - more information can be found in this blog post.
skipShutdownAndForceDelete
- Should theazurermLinuxVirtualMachine
andazurermWindowsVirtualMachine
skip the shutdown command andforceDelete
, this provides the ability to forcefully and immediately delete the VM and detach all sub-resources associated with the virtual machine. This allows those freed resources to be reattached to another VM instance or deleted. Defaults tofalse
.
\~> Note: Support for Force Delete is in an opt-in Preview.
The virtualMachineScaleSet
block supports the following:
forceDelete
- Should theazurermLinuxVirtualMachineScaleSet
andazurermWindowsVirtualMachineScaleSet
resourcesforceDelete
, this provides the ability to forcefully and immediately delete the VM and detach all sub-resources associated with the virtual machine. This allows those freed resources to be reattached to another VM instance or deleted. Defaults tofalse
.
\~> Note: Support for Force Delete is in an opt-in Preview.
-
rollInstancesWhenRequired
- (Optional) Should theazurermLinuxVirtualMachineScaleSet
andazurermWindowsVirtualMachineScaleSet
resources automatically roll the instances in the Scale Set when Required (for example when updating the Sku/Image). Defaults totrue
. -
scaleToZeroBeforeDeletion
- (Optional) Should theazurermLinuxVirtualMachineScaleSet
andazurermWindowsVirtualMachineScaleSet
resources scale to 0 instances before deleting the resource. Defaults totrue
.