Skip to content

Commit

Permalink
feat: add property userdata to VM resource module (#3756)
Browse files Browse the repository at this point in the history
## Description

Adds the optional property UserData to the VM.

Closes #3599 
-->

## Pipeline Reference

Only nVidia run fails due to capacity restrictions

| Pipeline |
| -------- |
|
[![avm.res.compute.virtual-machine](https://github.com/rahalan/bicep-registry-modules/actions/workflows/avm.res.compute.virtual-machine.yml/badge.svg)](https://github.com/rahalan/bicep-registry-modules/actions/workflows/avm.res.compute.virtual-machine.yml)
|

## Type of Change

<!-- Use the checkboxes [x] on the options that are relevant. -->

- [ ] Update to CI Environment or utilities (Non-module affecting
changes)
- [ ] Azure Verified Module updates:
- [ ] Bugfix containing backwards-compatible bug fixes, and I have NOT
bumped the MAJOR or MINOR version in `version.json`:
- [ ] Someone has opened a bug report issue, and I have included "Closes
#{bug_report_issue_number}" in the PR description.
- [ ] The bug was found by the module author, and no one has opened an
issue to report it yet.
- [x] Feature update backwards compatible feature updates, and I have
bumped the MINOR version in `version.json`.
- [ ] Breaking changes and I have bumped the MAJOR version in
`version.json`.
  - [ ] Update to documentation

## Checklist

- [x] I'm sure there are no other open Pull Requests for the same
update/change
- [x] I have run `Set-AVMModule` locally to generate the supporting
module files.
- [x] My corresponding pipelines / checks run clean and green without
any errors or warnings

<!-- Please keep up to date with the contribution guide at
https://aka.ms/avm/contribute/bicep -->
  • Loading branch information
rahalan authored Nov 8, 2024
1 parent d5bc11b commit 3716384
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 86 deletions.
9 changes: 9 additions & 0 deletions avm/res/compute/virtual-machine/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4613,6 +4613,7 @@ param virtualMachineScaleSetResourceId = '<virtualMachineScaleSetResourceId>'
| [`tags`](#parameter-tags) | object | Tags of the resource. |
| [`timeZone`](#parameter-timezone) | string | Specifies the time zone of the virtual machine. e.g. 'Pacific Standard Time'. Possible values can be `TimeZoneInfo.id` value from time zones returned by `TimeZoneInfo.GetSystemTimeZones`. |
| [`ultraSSDEnabled`](#parameter-ultrassdenabled) | bool | The flag that enables or disables a capability to have one or more managed data disks with UltraSSD_LRS storage account type on the VM or VMSS. Managed disks with storage account type UltraSSD_LRS can be added to a virtual machine or virtual machine scale set only if this property is enabled. |
| [`userData`](#parameter-userdata) | string | UserData for the VM, which must be base-64 encoded. Customer should not pass any secrets in here. |
| [`virtualMachineScaleSetResourceId`](#parameter-virtualmachinescalesetresourceid) | string | Resource ID of a virtual machine scale set, where the VM should be added. |
| [`vTpmEnabled`](#parameter-vtpmenabled) | bool | Specifies whether vTPM should be enabled on the virtual machine. This parameter is part of the UefiSettings. SecurityType should be set to TrustedLaunch to enable UefiSettings. |
| [`winRM`](#parameter-winrm) | array | Specifies the Windows Remote Management listeners. This enables remote Windows PowerShell. - WinRMConfiguration object. |
Expand Down Expand Up @@ -5695,6 +5696,14 @@ The flag that enables or disables a capability to have one or more managed data
- Type: bool
- Default: `False`

### Parameter: `userData`

UserData for the VM, which must be base-64 encoded. Customer should not pass any secrets in here.

- Required: No
- Type: string
- Default: `''`

### Parameter: `virtualMachineScaleSetResourceId`

Resource ID of a virtual machine scale set, where the VM should be added.
Expand Down
9 changes: 3 additions & 6 deletions avm/res/compute/virtual-machine/extension/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.29.47.4906",
"templateHash": "10657605324993327332"
"version": "0.31.34.60546",
"templateHash": "1194243367873711347"
},
"name": "Virtual Machine Extensions",
"description": "This module deploys a Virtual Machine Extension.",
Expand Down Expand Up @@ -121,10 +121,7 @@
"settings": "[if(not(empty(parameters('settings'))), parameters('settings'), null())]",
"protectedSettings": "[if(not(empty(parameters('protectedSettings'))), parameters('protectedSettings'), null())]",
"suppressFailures": "[parameters('supressFailures')]"
},
"dependsOn": [
"virtualMachine"
]
}
}
},
"outputs": {
Expand Down
4 changes: 4 additions & 0 deletions avm/res/compute/virtual-machine/main.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ param adminUsername string
@secure()
param adminPassword string = ''

@description('Optional. UserData for the VM, which must be base-64 encoded. Customer should not pass any secrets in here.')
param userData string = ''

@description('Optional. Custom data associated to the VM, this value will be automatically converted into base64 to account for the expected VM format.')
param customData string = ''

Expand Down Expand Up @@ -620,6 +623,7 @@ resource vm 'Microsoft.Compute/virtualMachines@2024-07-01' = {
}
: null
licenseType: !empty(licenseType) ? licenseType : null
userData: !empty(userData) ? base64(userData) : null
}
dependsOn: [
vm_nic
Expand Down
130 changes: 51 additions & 79 deletions avm/res/compute/virtual-machine/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.30.3.12046",
"templateHash": "1443306495474212036"
"version": "0.31.34.60546",
"templateHash": "15583840681812853598"
},
"name": "Virtual Machines",
"description": "This module deploys a Virtual Machine with one or multiple NICs and optionally one or multiple public IPs.",
Expand Down Expand Up @@ -412,6 +412,13 @@
"description": "Optional. When specifying a Windows Virtual Machine, this value should be passed."
}
},
"userData": {
"type": "string",
"defaultValue": "",
"metadata": {
"description": "Optional. UserData for the VM, which must be base-64 encoded. Customer should not pass any secrets in here."
}
},
"customData": {
"type": "string",
"defaultValue": "",
Expand Down Expand Up @@ -1069,7 +1076,8 @@
"evictionPolicy": "[if(parameters('enableEvictionPolicy'), 'Deallocate', null())]",
"billingProfile": "[if(and(not(empty(parameters('priority'))), not(empty(parameters('maxPriceForLowPriorityVm')))), createObject('maxPrice', json(parameters('maxPriceForLowPriorityVm'))), null())]",
"host": "[if(not(empty(parameters('dedicatedHostId'))), createObject('id', parameters('dedicatedHostId')), null())]",
"licenseType": "[if(not(empty(parameters('licenseType'))), parameters('licenseType'), null())]"
"licenseType": "[if(not(empty(parameters('licenseType'))), parameters('licenseType'), null())]",
"userData": "[if(not(empty(parameters('userData'))), base64(parameters('userData')), null())]"
},
"dependsOn": [
"vm_nic"
Expand Down Expand Up @@ -1251,8 +1259,8 @@
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.30.3.12046",
"templateHash": "191716886366421622"
"version": "0.31.34.60546",
"templateHash": "4400762038950491974"
}
},
"definitions": {
Expand Down Expand Up @@ -2855,8 +2863,8 @@
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.30.3.12046",
"templateHash": "1742015474710386242"
"version": "0.31.34.60546",
"templateHash": "1194243367873711347"
},
"name": "Virtual Machine Extensions",
"description": "This module deploys a Virtual Machine Extension.",
Expand Down Expand Up @@ -2971,10 +2979,7 @@
"settings": "[if(not(empty(parameters('settings'))), parameters('settings'), null())]",
"protectedSettings": "[if(not(empty(parameters('protectedSettings'))), parameters('protectedSettings'), null())]",
"suppressFailures": "[parameters('supressFailures')]"
},
"dependsOn": [
"virtualMachine"
]
}
}
},
"outputs": {
Expand Down Expand Up @@ -3070,8 +3075,8 @@
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.30.3.12046",
"templateHash": "1742015474710386242"
"version": "0.31.34.60546",
"templateHash": "1194243367873711347"
},
"name": "Virtual Machine Extensions",
"description": "This module deploys a Virtual Machine Extension.",
Expand Down Expand Up @@ -3186,10 +3191,7 @@
"settings": "[if(not(empty(parameters('settings'))), parameters('settings'), null())]",
"protectedSettings": "[if(not(empty(parameters('protectedSettings'))), parameters('protectedSettings'), null())]",
"suppressFailures": "[parameters('supressFailures')]"
},
"dependsOn": [
"virtualMachine"
]
}
}
},
"outputs": {
Expand Down Expand Up @@ -3281,8 +3283,8 @@
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.30.3.12046",
"templateHash": "1742015474710386242"
"version": "0.31.34.60546",
"templateHash": "1194243367873711347"
},
"name": "Virtual Machine Extensions",
"description": "This module deploys a Virtual Machine Extension.",
Expand Down Expand Up @@ -3397,10 +3399,7 @@
"settings": "[if(not(empty(parameters('settings'))), parameters('settings'), null())]",
"protectedSettings": "[if(not(empty(parameters('protectedSettings'))), parameters('protectedSettings'), null())]",
"suppressFailures": "[parameters('supressFailures')]"
},
"dependsOn": [
"virtualMachine"
]
}
}
},
"outputs": {
Expand Down Expand Up @@ -3487,8 +3486,8 @@
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.30.3.12046",
"templateHash": "1742015474710386242"
"version": "0.31.34.60546",
"templateHash": "1194243367873711347"
},
"name": "Virtual Machine Extensions",
"description": "This module deploys a Virtual Machine Extension.",
Expand Down Expand Up @@ -3603,10 +3602,7 @@
"settings": "[if(not(empty(parameters('settings'))), parameters('settings'), null())]",
"protectedSettings": "[if(not(empty(parameters('protectedSettings'))), parameters('protectedSettings'), null())]",
"suppressFailures": "[parameters('supressFailures')]"
},
"dependsOn": [
"virtualMachine"
]
}
}
},
"outputs": {
Expand Down Expand Up @@ -3698,8 +3694,8 @@
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.30.3.12046",
"templateHash": "1742015474710386242"
"version": "0.31.34.60546",
"templateHash": "1194243367873711347"
},
"name": "Virtual Machine Extensions",
"description": "This module deploys a Virtual Machine Extension.",
Expand Down Expand Up @@ -3814,10 +3810,7 @@
"settings": "[if(not(empty(parameters('settings'))), parameters('settings'), null())]",
"protectedSettings": "[if(not(empty(parameters('protectedSettings'))), parameters('protectedSettings'), null())]",
"suppressFailures": "[parameters('supressFailures')]"
},
"dependsOn": [
"virtualMachine"
]
}
}
},
"outputs": {
Expand Down Expand Up @@ -3904,8 +3897,8 @@
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.30.3.12046",
"templateHash": "1742015474710386242"
"version": "0.31.34.60546",
"templateHash": "1194243367873711347"
},
"name": "Virtual Machine Extensions",
"description": "This module deploys a Virtual Machine Extension.",
Expand Down Expand Up @@ -4020,10 +4013,7 @@
"settings": "[if(not(empty(parameters('settings'))), parameters('settings'), null())]",
"protectedSettings": "[if(not(empty(parameters('protectedSettings'))), parameters('protectedSettings'), null())]",
"suppressFailures": "[parameters('supressFailures')]"
},
"dependsOn": [
"virtualMachine"
]
}
}
},
"outputs": {
Expand Down Expand Up @@ -4118,8 +4108,8 @@
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.30.3.12046",
"templateHash": "1742015474710386242"
"version": "0.31.34.60546",
"templateHash": "1194243367873711347"
},
"name": "Virtual Machine Extensions",
"description": "This module deploys a Virtual Machine Extension.",
Expand Down Expand Up @@ -4234,10 +4224,7 @@
"settings": "[if(not(empty(parameters('settings'))), parameters('settings'), null())]",
"protectedSettings": "[if(not(empty(parameters('protectedSettings'))), parameters('protectedSettings'), null())]",
"suppressFailures": "[parameters('supressFailures')]"
},
"dependsOn": [
"virtualMachine"
]
}
}
},
"outputs": {
Expand Down Expand Up @@ -4336,8 +4323,8 @@
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.30.3.12046",
"templateHash": "1742015474710386242"
"version": "0.31.34.60546",
"templateHash": "1194243367873711347"
},
"name": "Virtual Machine Extensions",
"description": "This module deploys a Virtual Machine Extension.",
Expand Down Expand Up @@ -4452,10 +4439,7 @@
"settings": "[if(not(empty(parameters('settings'))), parameters('settings'), null())]",
"protectedSettings": "[if(not(empty(parameters('protectedSettings'))), parameters('protectedSettings'), null())]",
"suppressFailures": "[parameters('supressFailures')]"
},
"dependsOn": [
"virtualMachine"
]
}
}
},
"outputs": {
Expand Down Expand Up @@ -4548,8 +4532,8 @@
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.30.3.12046",
"templateHash": "1742015474710386242"
"version": "0.31.34.60546",
"templateHash": "1194243367873711347"
},
"name": "Virtual Machine Extensions",
"description": "This module deploys a Virtual Machine Extension.",
Expand Down Expand Up @@ -4664,10 +4648,7 @@
"settings": "[if(not(empty(parameters('settings'))), parameters('settings'), null())]",
"protectedSettings": "[if(not(empty(parameters('protectedSettings'))), parameters('protectedSettings'), null())]",
"suppressFailures": "[parameters('supressFailures')]"
},
"dependsOn": [
"virtualMachine"
]
}
}
},
"outputs": {
Expand Down Expand Up @@ -4756,8 +4737,8 @@
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.30.3.12046",
"templateHash": "1742015474710386242"
"version": "0.31.34.60546",
"templateHash": "1194243367873711347"
},
"name": "Virtual Machine Extensions",
"description": "This module deploys a Virtual Machine Extension.",
Expand Down Expand Up @@ -4872,10 +4853,7 @@
"settings": "[if(not(empty(parameters('settings'))), parameters('settings'), null())]",
"protectedSettings": "[if(not(empty(parameters('protectedSettings'))), parameters('protectedSettings'), null())]",
"suppressFailures": "[parameters('supressFailures')]"
},
"dependsOn": [
"virtualMachine"
]
}
}
},
"outputs": {
Expand Down Expand Up @@ -4973,8 +4951,8 @@
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.30.3.12046",
"templateHash": "1742015474710386242"
"version": "0.31.34.60546",
"templateHash": "1194243367873711347"
},
"name": "Virtual Machine Extensions",
"description": "This module deploys a Virtual Machine Extension.",
Expand Down Expand Up @@ -5089,10 +5067,7 @@
"settings": "[if(not(empty(parameters('settings'))), parameters('settings'), null())]",
"protectedSettings": "[if(not(empty(parameters('protectedSettings'))), parameters('protectedSettings'), null())]",
"suppressFailures": "[parameters('supressFailures')]"
},
"dependsOn": [
"virtualMachine"
]
}
}
},
"outputs": {
Expand Down Expand Up @@ -5186,8 +5161,8 @@
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.30.3.12046",
"templateHash": "1742015474710386242"
"version": "0.31.34.60546",
"templateHash": "1194243367873711347"
},
"name": "Virtual Machine Extensions",
"description": "This module deploys a Virtual Machine Extension.",
Expand Down Expand Up @@ -5302,10 +5277,7 @@
"settings": "[if(not(empty(parameters('settings'))), parameters('settings'), null())]",
"protectedSettings": "[if(not(empty(parameters('protectedSettings'))), parameters('protectedSettings'), null())]",
"suppressFailures": "[parameters('supressFailures')]"
},
"dependsOn": [
"virtualMachine"
]
}
}
},
"outputs": {
Expand Down Expand Up @@ -5385,8 +5357,8 @@
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.30.3.12046",
"templateHash": "18427642917647797213"
"version": "0.31.34.60546",
"templateHash": "7575343013066166436"
},
"name": "Recovery Service Vaults Protection Container Protected Item",
"description": "This module deploys a Recovery Services Vault Protection Container Protected Item.",
Expand Down
Loading

0 comments on commit 3716384

Please sign in to comment.