Azure Compute Gallery
This page shows how to write Terraform and Azure Resource Manager for Compute Gallery and write them securely.
azurerm_shared_image_gallery (Terraform)
The Gallery in Compute can be configured in Terraform with the resource name azurerm_shared_image_gallery
. The following sections describe 10 examples of how to use the resource and its parameters.
Example Usage from GitHub
resource "azurerm_shared_image_gallery" "example" {
name = "example_image_gallery"
resource_group_name = "testrg"
location = "West Europe"
description = "Shared images and things."
resource "azurerm_shared_image_gallery" "sig" {
name = var.res_sig_name
resource_group_name = var.res_sig_rg_name
location = var.res_location
tags = var.res_tags
resource "azurerm_shared_image_gallery" "gallery" {
name = azurecaf_name.sig_name.result
resource_group_name = var.resource_group_name
location = var.location
description = var.settings.description
}
resource "azurerm_shared_image_gallery" "image_gallery" {
count = var.deploy_shared_image_gallery ? 1 : 0
name = format("%s", "global_image_gallery")
resource_group_name = module.rg-global.name
location = var.location
description = "Global Images"
resource "azurerm_shared_image_gallery" "main" {
name = var.sig_name
resource_group_name = azurerm_resource_group.main.name
location = var.location
}
resource "azurerm_shared_image_gallery" "shared_image_gallery" {
name = "Clariun_image_gallery"
resource_group_name = azurerm_resource_group.resource_group.name
location = azurerm_resource_group.resource_group.location
description = "Shared images"
resource "azurerm_shared_image_gallery" "gallery" {
name = var.image_gallery_name
resource_group_name = azurerm_resource_group.rg_services.name
location = azurerm_resource_group.rg_services.location
tags = {
resource "azurerm_shared_image_gallery" "sig" {
name = "sig"
resource_group_name = azurerm_resource_group.rg.name
location = azurerm_resource_group.rg.location
}
resource "azurerm_shared_image_gallery" "example" {
name = var.name
resource_group_name = module.resource_group.azurerm_resource_group.example.name
location = module.resource_group.azurerm_resource_group.example.location
description = var.description
resource "azurerm_shared_image_gallery" "gallery" {
name = azurecaf_name.sig_name.result
resource_group_name = var.resource_group_name
location = var.location
description = var.settings.description
}
Parameters
-
description
optional - string -
id
optional computed - string -
location
required - string -
name
required - string -
resource_group_name
required - string -
tags
optional - map from string to string -
unique_name
optional computed - string -
timeouts
single block
Explanation in Terraform Registry
Manages 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 (Azure Resource Manager)
The galleries in Microsoft.Compute can be configured in Azure Resource Manager with the resource name Microsoft.Compute/galleries
. The following sections describe how to use the resource and its parameters.
Example Usage from GitHub
"type": "Microsoft.Compute/galleries",
"apiVersion": "2020-09-30",
"name": "[concat(parameters('prefix'),'_imggal_',parameters('location'))]",
"location": "[parameters('location')]",
"properties": {}
},
"type": "Microsoft.Compute/galleries",
"apiVersion": "2019-03-01",
"name": "[parameters('galleries_testsharedgallery_name')]",
"location": "eastus",
"tags": {
"type": "test"
"type": "Microsoft.Compute/galleries",
"name": "[parameters('deploymentParameters').galleryName]",
"apiVersion": "2018-06-01",
"location": "[resourceGroup().location]",
"properties": {
"description": "My Private Gallery"
"type": "Microsoft.Compute/galleries",
"name": "[parameters('galleryName')]",
"apiVersion": "2018-06-01",
"location": "[parameters('location')]",
"properties": {
"description": "[parameters('description')]"
"type": "Microsoft.Compute/galleries",
"name": "[parameters('galleryDefinition').galleries.Name]",
"apiVersion": "2018-06-01",
"location": "[parameters('galleryDefinition').galleries.Location]",
"properties": {
"description": "[parameters('galleryDefinition').galleries.description]"
"type": "Microsoft.Compute/galleries",
"apiVersion": "2020-09-30",
"name": "[parameters('sigName')]",
"location": "[parameters('sigLocation')]"
},
{
"type": "Microsoft.Compute/galleries",
"name": "[parameters('galleryName')]",
"location": "westeurope",
"properties": {
"description": "[parameters('description')]"
}
"type": "Microsoft.Compute/galleries",
"apiVersion": "2020-09-30",
"name": "[parameters('sigName')]",
"location": "[parameters('sigLocation')]"
},
{
"type": "Microsoft.Compute/galleries",
"name": "[parameters('galleryName')]",
"apiVersion": "2019-12-01",
"location": "[parameters('location')]",
"properties": {
"description": "arm-imagebuilder-vmss-extension"
Parameters
apiVersion
required - stringlocation
required - stringResource location
name
required - stringThe name of the Shared Image Gallery. The allowed characters are alphabets and numbers with dots and periods allowed in the middle. The maximum length is 80 characters.
properties
requireddescription
optional - stringThe description of this Shared Image Gallery resource. This property is updatable.
identifier
optionalsharingProfile
optionalpermissions
optional - stringThis property allows you to specify the permission of sharing gallery. Possible values are: Private Groups.
softDeletePolicy
optionalisSoftDeleteEnabled
optional - booleanEnables soft-deletion for resources in this gallery, allowing them to be recovered within retention time.
tags
optional - stringResource tags
type
required - string
Frequently asked questions
What is Azure Compute Gallery?
Azure Compute Gallery 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 Gallery?
For Terraform, the kgopi1/TF_modules, avishekansible/AzureLandingZone and anmoltoppo/Terraform source code examples are useful. See the Terraform Example section for further details.
For Azure Resource Manager, the Duddit2LTD/Nordcloud_104, lavanyabojanapati/Powershell-Templates and MatthewGrimshaw/WVD-POC source code examples are useful. See the Azure Resource Manager Example section for further details.