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_latestoptional - bool -
gallery_namerequired - string -
idoptional computed - string -
image_namerequired - string -
locationrequired - string -
managed_image_idoptional - string -
namerequired - string -
os_disk_snapshot_idoptional - string -
resource_group_namerequired - string -
tagsoptional - map from string to string -
target_regionset block-
namerequired - string -
regional_replica_countrequired - number -
storage_account_typeoptional - string
-
-
timeoutssingle 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
apiVersionrequired - stringlocationrequired - stringResource location
namerequired - 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>
propertiesrequiredpublishingProfileoptionalendOfLifeDateoptional - stringThe end of life date of the gallery image version. This property can be used for decommissioning purposes. This property is updatable.
excludeFromLatestoptional - booleanIf set to true, Virtual Machines deployed from the latest version of the Image Definition won't use this Image Version.
replicaCountoptional - 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.
replicationModeoptional - stringOptional parameter which specifies the mode to be used for replication. This property is not updatable.
storageAccountTypeoptional - stringSpecifies the storage account type to be used to store the image. This property is not updatable.
targetRegionsoptional arrayencryptionoptionaldataDiskImagesoptional arraydiskEncryptionSetIdoptional - stringA relative URI containing the resource ID of the disk encryption set.
lunrequired - 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.
osDiskImageoptionaldiskEncryptionSetIdoptional - stringA relative URI containing the resource ID of the disk encryption set.
namerequired - stringThe name of the region.
regionalReplicaCountoptional - integerThe number of replicas of the Image Version to be created per region. This property is updatable.
storageAccountTypeoptional - stringSpecifies the storage account type to be used to store the image. This property is not updatable.
storageProfilerequireddataDiskImagesoptional arrayhostCachingoptional - stringThe host caching of the disk. Valid values are 'None', 'ReadOnly', and 'ReadWrite'.
lunrequired - 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.
sourceoptionalidoptional - stringThe id of the gallery artifact version source. Can specify a disk uri, snapshot uri, user image or storage account resource.
urioptional - stringThe uri of the gallery artifact version source. Currently used to specify vhd/blob source.
osDiskImageoptionalhostCachingoptional - stringThe host caching of the disk. Valid values are 'None', 'ReadOnly', and 'ReadWrite'.
sourceoptionalidoptional - stringThe id of the gallery artifact version source. Can specify a disk uri, snapshot uri, user image or storage account resource.
urioptional - stringThe uri of the gallery artifact version source. Currently used to specify vhd/blob source.
sourceoptionalidoptional - stringThe id of the gallery artifact version source. Can specify a disk uri, snapshot uri, user image or storage account resource.
urioptional - stringThe uri of the gallery artifact version source. Currently used to specify vhd/blob source.
tagsoptional - stringResource tags
typerequired - 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.