Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add property userdata to VM resource module #3756

Merged
merged 4 commits into from
Nov 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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