On this page
azurerm_image
Create a custom virtual machine image that can be used to create virtual machines.
Example Usage Creating from VHD
resource "azurerm_resource_group" "test" {
name = "acctest"
location = "West US"
}
resource "azurerm_image" "test" {
name = "acctest"
location = "West US"
resource_group_name = "${azurerm_resource_group.test.name}"
os_disk {
os_type = "Linux"
os_state = "Generalized"
blob_uri = "{blob_uri}"
size_gb = 30
}
}
Example Usage Creating from Virtual Machine (VM must be generalized beforehand)
resource "azurerm_resource_group" "test" {
name = "acctest"
location = "West US"
}
resource "azurerm_image" "test" {
name = "acctest"
location = "West US"
resource_group_name = "${azurerm_resource_group.test.name}"
source_virtual_machine_id = "{vm_id}"
}
Argument Reference
The following arguments are supported:
name
- (Required) Specifies the name of the image. Changing this forces a new resource to be created.resource_group_name
- (Required) The name of the resource group in which to create the image. Changing this forces a new resource to be created.location
- (Required) Specified the supported Azure location where the resource exists. Changing this forces a new resource to be created.source_virtual_machine_id
- (Optional) The Virtual Machine ID from which to create the image.os_disk
- (Optional) One or moreos_disk
elements as defined below.data_disk
- (Optional) One or moredata_disk
elements as defined below.tags
- (Optional) A mapping of tags to assign to the resource.
os_disk
supports the following:
os_type
- (Required) Specifies the type of operating system contained in the the virtual machine image. Possible values are: Windows or Linux.os_state
- (Required) Specifies the state of the operating system contained in the blob. Currently, the only value is Generalized.managed_disk_id
- (Optional) Specifies the ID of the managed disk resource that you want to use to create the image.blob_uri
- (Optional) Specifies the URI in Azure storage of the blob that you want to use to create the image.caching
- (Optional) Specifies the caching mode asReadWrite
,ReadOnly
, orNone
. The default isNone
.
data_disk
supports the following:
lun
- (Required) Specifies the logical unit number of the data disk.managed_disk_id
- (Optional) Specifies the ID of the managed disk resource that you want to use to create the image.blob_uri
- (Optional) Specifies the URI in Azure storage of the blob that you want to use to create the image.caching
- (Optional) Specifies the caching mode asReadWrite
,ReadOnly
, orNone
. The default isNone
.size_gb
- (Optional) Specifies the size of the image to be created. The target size can't be smaller than the source size.
Attributes Reference
The following attributes are exported:
id
- The managed image ID.
Import
Image can be imported using the resource id
, e.g.
terraform import azurerm_image.test /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/mygroup1/providers/microsoft.compute/images/image1
© 2018 HashiCorp
Licensed under the MPL 2.0 License.
https://www.terraform.io/docs/providers/azurerm/r/image.html