Skip to content

Commit a2d77d9

Browse files
SFI updates, Bug Fixes, and example refactoring. (#138)
* enc_at_host default true * example vnet changes * pre-commit * sku 0.2.0 * sku zonal awareness * sku version updates * extension and backup issues * initial run_command * run command example fixes * Refactor custom script extension examples in README.md (#125) Co-authored-by: jchancellor-ms <84210452+jchancellor-ms@users.noreply.github.com> * example fix * bastion commenting * example stg tflint fix * stg naming fix --------- Co-authored-by: Phil Huang <phil.huang@microsoft.com>
1 parent fea0d69 commit a2d77d9

53 files changed

Lines changed: 4645 additions & 1432 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.terraform-version

Lines changed: 0 additions & 1 deletion
This file was deleted.

README.md

Lines changed: 132 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ The following requirements are needed by this module:
1212

1313
- <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) (~> 1.6)
1414

15+
- <a name="requirement_azapi"></a> [azapi](#requirement\_azapi) (~> 2.0)
16+
1517
- <a name="requirement_azurerm"></a> [azurerm](#requirement\_azurerm) (>= 3.116, < 5.0)
1618

1719
- <a name="requirement_modtm"></a> [modtm](#requirement\_modtm) (~> 0.3)
@@ -24,7 +26,7 @@ The following requirements are needed by this module:
2426

2527
The following resources are used by this module:
2628

27-
- [azurerm_backup_protected_vm.this](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/backup_protected_vm) (resource)
29+
- [azapi_resource.this_backup_intent](https://registry.terraform.io/providers/Azure/azapi/latest/docs/resources/resource) (resource)
2830
- [azurerm_dev_test_global_vm_shutdown_schedule.this](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/dev_test_global_vm_shutdown_schedule) (resource)
2931
- [azurerm_key_vault_secret.admin_password](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/key_vault_secret) (resource)
3032
- [azurerm_key_vault_secret.admin_ssh_key](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/key_vault_secret) (resource)
@@ -52,6 +54,9 @@ The following resources are used by this module:
5254
- [azurerm_virtual_machine_data_disk_attachment.this_linux](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/virtual_machine_data_disk_attachment) (resource)
5355
- [azurerm_virtual_machine_data_disk_attachment.this_windows](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/virtual_machine_data_disk_attachment) (resource)
5456
- [azurerm_virtual_machine_extension.this_extension](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/virtual_machine_extension) (resource)
57+
- [azurerm_virtual_machine_extension.this_extension_1](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/virtual_machine_extension) (resource)
58+
- [azurerm_virtual_machine_extension.this_extension_2](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/virtual_machine_extension) (resource)
59+
- [azurerm_virtual_machine_run_command.this](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/virtual_machine_run_command) (resource)
5560
- [azurerm_windows_virtual_machine.this](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/windows_virtual_machine) (resource)
5661
- [modtm_telemetry.telemetry](https://registry.terraform.io/providers/Azure/modtm/latest/docs/resources/telemetry) (resource)
5762
- [random_password.admin_password](https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/password) (resource)
@@ -380,33 +385,34 @@ Default: `null`
380385
Description: This object describes the backup configuration to use for this VM instance. Provide the backup details for configuring the backup. It defaults to null.
381386

382387
- `<map_key>` - An arbitrary map key to avoid terraform issues with know before apply challenges
383-
- `resource_group_name` - (Optional) - The resource group name for the resource group containing the recovery services vault. If not supplied it will default to the deployment resource group.
384-
- `recovery_vault_name` - (Required) - The name of the recovery services vault where the backup will be stored.
385-
- `backup_policy_resource_id` - (Optional) - Required during creation, but can be optional when the protection state is not `ProtectionStopped`.
386-
- `exclude_disk_luns` - (Optional) - A list of Disk Logical Unit Numbers (LUN) to be excluded from VM Protection.
387-
- `include_disk_luns` - (Optional) - A list of Disk Logical Unit Numbers (LUN) to be included for VM Protection.
388-
- `protection_state` - (Optional) - Specifies the protection state of the backup. Possible values are `Invalid`, `Protected`, `ProtectionStopped`, `ProtectionError`, and `ProtectionPaused`.
388+
- `recovery_vault_resource_id - (Required) - The Azure Resource ID of the recovery services vault where the backup will be stored.
389+
- `resource\_group\_name` - (Optional) - This value is deprecated and will be removed in future versions as the RSV resource group name will be extracted from the RSV resource id. The resource group name for the resource group containing the recovery services vault. If not supplied it will default to the deployment resource group.
390+
- `recovery\_vault\_name` - (Optional) - This value is deprecated and will be removed in future versions as the RSV information will be pulled from the RSV resource id. The name of the recovery services vault where the backup will be stored.
391+
- `backup\_policy\_resource\_id` - (Optional) - Required during creation, but can be optional when the protection state is not `ProtectionStopped`.
392+
- `exclude\_disk\_luns` - (Optional) - A list of Disk Logical Unit Numbers (LUN) to be excluded from VM Protection. Only one of `exclude\_disk\_luns` or `include\_disk\_luns` can be set. If both are set then only the `exclude\_disk\_luns` value will be used.
393+
- `include\_disk\_luns` - (Optional) - A list of Disk Logical Unit Numbers (LUN) to be included for VM Protection. Only one of `exclude\_disk\_luns` or `include\_disk\_luns` can be set. If both are set then only the `exclude\_disk\_luns` value will be used.
389394

390395
Example Input:
391-
azure\_backup\_configurations = {
392-
arbitrary\_key = {
393-
resource\_group\_name = azurerm\_recovery\_services\_vault.test\_vault.resource\_group\_name
394-
recovery\_vault\_name = azurerm\_recovery\_services\_vault.test\_vault.name
395-
backup\_policy\_resource\_id = azurerm\_backup\_policy\_vm.test\_policy.id
396-
exclude\_disk\_luns = [1]
396+
azure_backup_configurations = {
397+
arbitrary_key = {
398+
recovery_vault_resource_id = azurerm_recovery_services_vault.test_vault.id
399+
backup_policy_resource_id = azurerm_backup_policy_vm.test_policy.id
400+
exclude_disk_luns = [0,1]
397401
}
398402
}
403+
`
399404

400405
Type:
401406

402407
```hcl
403408
map(object({
404-
resource_group_name = optional(string, null)
405-
recovery_vault_name = string
406-
backup_policy_resource_id = optional(string, null)
407-
exclude_disk_luns = optional(list(number), null)
408-
include_disk_luns = optional(list(number), null)
409-
protection_state = optional(string, null)
409+
resource_group_name = optional(string, null)
410+
recovery_vault_name = optional(string, null)
411+
recovery_vault_resource_id = string
412+
backup_policy_resource_id = optional(string, null)
413+
exclude_disk_luns = optional(list(number), null)
414+
include_disk_luns = optional(list(number), null)
415+
410416
}))
411417
```
412418

@@ -706,7 +712,7 @@ Description: (Optional) Should all of the disks (including the temp disk) attach
706712

707713
Type: `bool`
708714

709-
Default: `null`
715+
Default: `true`
710716

711717
### <a name="input_eviction_policy"></a> [eviction\_policy](#input\_eviction\_policy)
712718

@@ -727,6 +733,7 @@ Description: This map of objects is used to create additional `azurerm_virtual_m
727733
- `type_handler_version` (Required) - The type handler version for the extension. A common value is 1.0.
728734
- `auto_upgrade_minor_version` (Optional) - Set this to false to avoid automatic upgrades for minor versions on the extension. Defaults to true
729735
- `automatic_upgrade_enabled` (Optional) - Set this to false to avoid automatic upgrades for major versions on the extension. Defaults to true
736+
- `deploy_sequence` (Optional) - The sequence number in which the extension should be provisioned. This value allows for serialization of two extensions. Sequence numbers of 3 and higher are deployed in parallel after the first two serialized extensions. Defaults to 3 to be non-breaking for previous versions of the module.
730737
- `failure_suppression_enabled` (Optional) - Should failures from the extension be suppressed? Possible values are true or false. Defaults to false. Operational failures such as not connecting to the VM will not be suppressed regardless of the failure\_suppression\_enabled value.
731738
- `settings` (Optional) - The settings passed to the extension, these are specified as a JSON object in a string. Certain VM Extensions require that the keys in the settings block are case sensitive. If you're seeing unhelpful errors, please ensure the keys are consistent with how Azure is expecting them (for instance, for the JsonADDomainExtension extension, the keys are expected to be in TitleCase.)
732739
- `protected_settings` (Optional) - The protected\_settings passed to the extension, like settings, these are specified as a JSON object in a string. Certain VM Extensions require that the keys in the protected\_settings block are case sensitive. If you're seeing unhelpful errors, please ensure the keys are consistent with how Azure is expecting them (for instance, for the JsonADDomainExtension extension, the keys are expected to be in TitleCase.)
@@ -741,7 +748,7 @@ Example Inputs:
741748
```hcl
742749
#custom script extension example - linux
743750
extensions = {
744-
{
751+
custom_script_extension_linux = {
745752
name = "CustomScriptExtension"
746753
publisher = "Microsoft.Azure.Extensions"
747754
type = "CustomScript"
@@ -756,7 +763,7 @@ extensions = {
756763
757764
#custom script extension example - windows
758765
extensions = {
759-
{
766+
custom_script_extension_windows = {
760767
name = "CustomScriptExtension"
761768
publisher = "Microsoft.Compute"
762769
type = "CustomScriptExtension"
@@ -791,6 +798,7 @@ map(object({
791798
type_handler_version = string
792799
auto_upgrade_minor_version = optional(bool)
793800
automatic_upgrade_enabled = optional(bool)
801+
deploy_sequence = optional(number, 3)
794802
failure_suppression_enabled = optional(bool, false)
795803
settings = optional(string)
796804
protected_settings = optional(string)
@@ -1290,6 +1298,108 @@ map(object({
12901298

12911299
Default: `{}`
12921300

1301+
### <a name="input_run_commands"></a> [run\_commands](#input\_run\_commands)
1302+
1303+
Description: The `run_commands` variable defines the configuration for Virtual Machine Run Commands. Note that the run command configuration is split into two parts, the `run_commands` and `run_commands_secrets` variables. Ensure that the map keys match when using both variables.
1304+
The following arguments are supported:
1305+
1306+
- `location` (Required): The Azure Region where the Virtual Machine Run Command should exist. Changing this forces a new Virtual Machine Run Command to be created.
1307+
- `name` (Required): Specifies the name of this Virtual Machine Run Command. Changing this forces a new Virtual Machine Run Command to be created.
1308+
- `source` (Required): A source block as defined below. The source of the run command script.
1309+
- `error_blob_managed_identity` (Optional): An error\_blob\_managed\_identity block as defined below. User-assigned managed Identity that has access to errorBlobUri storage blob.
1310+
- `error_blob_uri` (Optional): Specifies the Azure storage blob where script error stream will be uploaded.
1311+
- `output_blob_managed_identity` (Optional): An output\_blob\_managed\_identity block as defined below. User-assigned managed Identity that has access to outputBlobUri storage blob.
1312+
- `output_blob_uri` (Optional): Specifies the Azure storage blob where script output stream will be uploaded. It can be basic blob URI with SAS token.
1313+
- `parameter` (Optional): A list of parameter blocks as defined below. The parameters used by the script.
1314+
- `protected_parameter` (Optional): A list of protected\_parameter blocks as defined below. The protected parameters used by the script.
1315+
- `tags` (Optional): A mapping of tags which should be assigned to the Virtual Machine Run Command.
1316+
1317+
An error\_blob\_managed\_identity block supports the following arguments:
1318+
- `client_id` (Optional): The client ID of the managed identity.
1319+
- `object_id` (Optional): The object ID of the managed identity.
1320+
1321+
An output\_blob\_managed\_identity block supports the following arguments:
1322+
- `client_id` (Optional): The client ID of the managed identity.
1323+
- `object_id` (Optional): The object ID of the managed identity.
1324+
1325+
A parameter block supports the following arguments:
1326+
- `name` (Required): The run parameter name.
1327+
- `value` (Required): The run parameter value.
1328+
1329+
A script\_uri\_managed\_identity block supports the following arguments:
1330+
- `client_id` (Optional): The client ID of the managed identity.
1331+
- `object_id` (Optional): The object ID of the managed identity.
1332+
1333+
A source block supports the following arguments:
1334+
- `command_id` (Optional)
1335+
- `script` (Optional)
1336+
- `script_uri` (Optional)
1337+
- `script_uri_managed_identity` (Optional): A script\_uri\_managed\_identity block as defined above.
1338+
1339+
Type:
1340+
1341+
```hcl
1342+
map(object({
1343+
location = string
1344+
name = string
1345+
source = object({
1346+
command_id = optional(string)
1347+
script = optional(string)
1348+
script_uri = optional(string)
1349+
script_uri_managed_identity = optional(object({
1350+
client_id = optional(string)
1351+
object_id = optional(string)
1352+
}))
1353+
})
1354+
error_blob_managed_identity = optional(object({
1355+
client_id = optional(string)
1356+
object_id = optional(string)
1357+
}))
1358+
error_blob_uri = optional(string)
1359+
output_blob_managed_identity = optional(object({
1360+
client_id = optional(string)
1361+
object_id = optional(string)
1362+
}))
1363+
output_blob_uri = optional(string)
1364+
parameters = optional(list(object({
1365+
name = string
1366+
value = string
1367+
})), [])
1368+
1369+
tags = optional(map(string))
1370+
}))
1371+
```
1372+
1373+
Default: `{}`
1374+
1375+
### <a name="input_run_commands_secrets"></a> [run\_commands\_secrets](#input\_run\_commands\_secrets)
1376+
1377+
Description: The `run_commands_secrets` variable defines the configuration for Virtual Machine Run Command Sensitive values. This requires that the `run_commands_secrets` map key match the `run_commands` map key.
1378+
The following arguments are supported:
1379+
1380+
- `protected_parameters` (Optional): A list of protected\_parameter blocks as defined below. The protected parameters used by the script.
1381+
- `run_as_password` (Optional): Specifies the user account password on the VM when executing the Virtual Machine Run Command.
1382+
- `run_as_user` (Optional): Specifies the user account on the VM when executing the Virtual Machine Run Command.
1383+
1384+
A protected\_parameter block supports the following arguments:
1385+
- `name` (Required): The run parameter name.
1386+
- `value` (Required): The run parameter value.
1387+
1388+
Type:
1389+
1390+
```hcl
1391+
map(object({
1392+
protected_parameters = optional(list(object({
1393+
name = string
1394+
value = string
1395+
})), [])
1396+
run_as_password = optional(string)
1397+
run_as_user = optional(string)
1398+
}))
1399+
```
1400+
1401+
Default: `{}`
1402+
12931403
### <a name="input_secrets"></a> [secrets](#input\_secrets)
12941404

12951405
Description: A list of objects defining VM secrets with the following attributes:

avm.tflint.override.hcl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
rule "diagnostic_settings" {
2+
enabled = false
3+
}

0 commit comments

Comments
 (0)