Azure Compute Version
This page shows how to write Terraform and Azure Resource Manager for Compute Version and write them securely.
azurerm_shared_image_version (Terraform)
The Version in Compute can be configured in Terraform with the resource name azurerm_shared_image_version
. The following sections describe 7 examples of how to use the resource and its parameters.
Example Usage from GitHub
resource "azurerm_shared_image_version" "version" {
count = var.create ? 1 : 0
name = var.global_image_version
gallery_name = var.gallery_name
image_name = var.image_name
resource_group_name = var.resource_group_name
resource "azurerm_shared_image_version" "ubuntu" {
name = "1.0.1"
gallery_name = azurerm_shared_image_gallery.image_gallery.name
image_name = azurerm_shared_image.image_definition.name
resource_group_name = azurerm_resource_group.image_gallery.name
location = var.source_image_location
resource "azurerm_shared_image_version" "siver" {
name = var.res_si_ver_name
gallery_name = var.res_sig_name
image_name = azurerm_shared_image.si.name
resource_group_name = var.res_si_rg_name
location = var.res_location
resource "azurerm_shared_image_version" "example" {
name = var.name
gallery_name = data.azurerm_shared_image.existing.gallery_name
image_name = data.azurerm_shared_image.existing.name
resource_group_name = data.azurerm_shared_image.existing.resource_group_name
location = data.azurerm_shared_image.existing.location
resource "azurerm_shared_image_version" "image_tr" {
name = "1.0.0"
gallery_name = azurerm_shared_image.image_tr.gallery_name
image_name = azurerm_shared_image.image_tr.name
resource_group_name = azurerm_shared_image.image_tr.resource_group_name
location = azurerm_shared_image.image_tr.location
resource "azurerm_shared_image_version" "this" {
exclude_from_latest = var.exclude_from_latest
gallery_name = var.gallery_name
image_name = var.image_name
location = var.location
managed_image_id = var.managed_image_id
resource "azurerm_shared_image_version" "this" {
exclude_from_latest = var.exclude_from_latest
gallery_name = var.gallery_name
image_name = var.image_name
location = var.location
managed_image_id = var.managed_image_id
Parameters
-
exclude_from_latest
optional - bool -
gallery_name
required - string -
id
optional computed - string -
image_name
required - string -
location
required - string -
managed_image_id
optional - string -
name
required - string -
os_disk_snapshot_id
optional - string -
resource_group_name
required - string -
tags
optional - map from string to string -
target_region
set block-
name
required - string -
regional_replica_count
required - number -
storage_account_type
optional - string
-
-
timeouts
single block
Explanation in Terraform Registry
Manages a Version of a Shared Image within a Shared Image Gallery.
Tips: Best Practices for The Other Azure Compute Resources
In addition to the azurerm_linux_virtual_machine, Azure Compute has the other resources that should be configured for security reasons. Please check some examples of those resources and precautions.
azurerm_linux_virtual_machine
Ensure to use SSH authentication for virtual machines
It is better to use SSH authentication for virtual machines instead of password authentication to enforce more secure ways.
azurerm_managed_disk
Ensure to enable the encryption on managed disks
It is better to enable the encryption on managed disks.
azurerm_virtual_machine
Ensure to use SSH authentication for virtual machines
It is better to use SSH authentication for virtual machines instead of password authentication to enforce more secure ways.
Microsoft.Compute/galleries/images/versions (Azure Resource Manager)
The galleries/images/versions in Microsoft.Compute can be configured in Azure Resource Manager with the resource name Microsoft.Compute/galleries/images/versions
. The following sections describe how to use the resource and its parameters.
Example Usage from GitHub
"type": "Microsoft.Compute/galleries/images/versions",
"apiVersion": "2019-03-01",
"location": "string",
"tags": {},
"properties": {
"publishingProfile": {
"type": "Microsoft.Compute/galleries/images/versions",
"name": "[concat(parameters('galleryName'), '/', parameters('galleryImageDefinitionName'), '/', parameters('galleryImageVersionName'))]",
"apiVersion": "2018-06-01",
"location": "[resourceGroup().location]",
"properties": {
"publishingProfile": {
"type": "Microsoft.Compute/galleries/images/versions",
"name": "[concat(parameters('galleryName'), '/', parameters('galleryImageDefinitionName'), '/', parameters('galleryImageVersionName'))]",
"apiVersion": "2018-06-01",
"location": "[resourceGroup().location]",
"properties": {
"publishingProfile": {
"type": "Microsoft.Compute/galleries/images/versions",
"name": "[variables('versionName')]",
"apiVersion": "2018-06-01",
"location": "[resourceGroup().location]",
"properties": {
"publishingProfile": {
"type": "Microsoft.Compute/galleries/images/versions",
"name": "[concat(parameters('galleryName'), '/', parameters('galleryImageDefinitionName'), '/', parameters('galleryImageVersionName'))]",
"apiVersion": "2018-06-01",
"location": "[resourceGroup().location]",
"properties": {
"publishingProfile": {
"type": "Microsoft.Compute/galleries/images/versions",
"name": "[concat(parameters('galleryName'), '/', parameters('galleryImageDefinitionName'), '/', parameters('galleryImageVersionName'))]",
"apiVersion": "2018-06-01",
"location": "[resourceGroup().location]",
"properties": {
"publishingProfile": {
"type": "Microsoft.Compute/galleries/images/versions",
"name": "[concat(parameters('galleryName'), '/', parameters('galleryImageDefinitionName'), '/', parameters('galleryImageVersionName'))]",
"apiVersion": "2018-06-01",
"location": "[resourceGroup().location]",
"properties": {
"publishingProfile": {
"type": "Microsoft.Compute/galleries/images/versions",
"name": "[concat(parameters('galleryName'), '/', parameters('galleryImageDefinitionName'), '/', parameters('galleryImageVersionName'))]",
"apiVersion": "2018-06-01",
"location": "[resourceGroup().location]",
"properties": {
"publishingProfile": {
"type": "Microsoft.Compute/galleries/images/versions",
"name": "[concat(parameters('galleryName'), '/', parameters('galleryImageDefinitionName'), '/', parameters('galleryImageVersionName'))]",
"apiVersion": "2018-06-01",
"location": "[resourceGroup().location]",
"properties": {
"publishingProfile": {
"type": "Microsoft.Compute/galleries/images/versions",
"name": "[concat(parameters('galleryName'), '/', parameters('galleryImageDefinitionName'), '/', parameters('galleryImageVersionName'))]",
"apiVersion": "2018-06-01",
"location": "[resourceGroup().location]",
"properties": {
"publishingProfile": {
Parameters
apiVersion
required - stringlocation
required - stringResource location
name
required - stringThe name of the gallery image version to be created. Needs to follow semantic version name pattern: The allowed characters are digit and period. Digits must be within the range of a 32-bit integer. Format: <MajorVersion>.<MinorVersion>.<Patch>
properties
requiredpublishingProfile
optionalendOfLifeDate
optional - stringThe end of life date of the gallery image version. This property can be used for decommissioning purposes. This property is updatable.
excludeFromLatest
optional - booleanIf set to true, Virtual Machines deployed from the latest version of the Image Definition won't use this Image Version.
replicaCount
optional - integerThe number of replicas of the Image Version to be created per region. This property would take effect for a region when regionalReplicaCount is not specified. This property is updatable.
replicationMode
optional - stringOptional parameter which specifies the mode to be used for replication. This property is not updatable.
storageAccountType
optional - stringSpecifies the storage account type to be used to store the image. This property is not updatable.
targetRegions
optional arrayencryption
optionaldataDiskImages
optional arraydiskEncryptionSetId
optional - stringA relative URI containing the resource ID of the disk encryption set.
lun
required - integerThis property specifies the logical unit number of the data disk. This value is used to identify data disks within the Virtual Machine and therefore must be unique for each data disk attached to the Virtual Machine.
osDiskImage
optionaldiskEncryptionSetId
optional - stringA relative URI containing the resource ID of the disk encryption set.
name
required - stringThe name of the region.
regionalReplicaCount
optional - integerThe number of replicas of the Image Version to be created per region. This property is updatable.
storageAccountType
optional - stringSpecifies the storage account type to be used to store the image. This property is not updatable.
storageProfile
requireddataDiskImages
optional arrayhostCaching
optional - stringThe host caching of the disk. Valid values are 'None', 'ReadOnly', and 'ReadWrite'.
lun
required - integerThis property specifies the logical unit number of the data disk. This value is used to identify data disks within the Virtual Machine and therefore must be unique for each data disk attached to the Virtual Machine.
source
optionalid
optional - stringThe id of the gallery artifact version source. Can specify a disk uri, snapshot uri, user image or storage account resource.
uri
optional - stringThe uri of the gallery artifact version source. Currently used to specify vhd/blob source.
osDiskImage
optionalhostCaching
optional - stringThe host caching of the disk. Valid values are 'None', 'ReadOnly', and 'ReadWrite'.
source
optionalid
optional - stringThe id of the gallery artifact version source. Can specify a disk uri, snapshot uri, user image or storage account resource.
uri
optional - stringThe uri of the gallery artifact version source. Currently used to specify vhd/blob source.
source
optionalid
optional - stringThe id of the gallery artifact version source. Can specify a disk uri, snapshot uri, user image or storage account resource.
uri
optional - stringThe uri of the gallery artifact version source. Currently used to specify vhd/blob source.
tags
optional - stringResource tags
type
required - string
Frequently asked questions
What is Azure Compute Version?
Azure Compute Version is a resource for Compute of Microsoft Azure. Settings can be wrote in Terraform.
Where can I find the example code for the Azure Compute Version?
For Terraform, the rohrerb/terraform-eiac, raymondbutcher/pretf and avishekansible/AzureLandingZone source code examples are useful. See the Terraform Example section for further details.
For Azure Resource Manager, the da-edra/scraping-azure, jacksonhansen498/azure-quickstart-templates and ConsistentTheory/AzureRep source code examples are useful. See the Azure Resource Manager Example section for further details.