Skip to content

azurermSharedImageVersion

Manages a Version of a Shared Image within a Shared Image Gallery.

Example Usage

/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as azurerm from "./.gen/providers/azurerm";
/*The following providers are missing schema information and might need manual adjustments to synthesize correctly: azurerm.
For a more precise conversion please use the --provider flag in convert.*/
const dataAzurermImageExisting = new azurerm.dataAzurermImage.DataAzurermImage(
  this,
  "existing",
  {
    name: "search-api",
    resource_group_name: "packerimages",
  }
);
const dataAzurermSharedImageExisting =
  new azurerm.dataAzurermSharedImage.DataAzurermSharedImage(
    this,
    "existing_1",
    {
      gallery_name: "existing_gallery",
      name: "existing-image",
      resource_group_name: "existing-resources",
    }
  );
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
dataAzurermSharedImageExisting.overrideLogicalId("existing");
new azurerm.sharedImageVersion.SharedImageVersion(this, "example", {
  gallery_name: dataAzurermSharedImageExisting.galleryName,
  image_name: dataAzurermSharedImageExisting.name,
  location: dataAzurermSharedImageExisting.location,
  managed_image_id: dataAzurermImageExisting.id,
  name: "0.0.1",
  resource_group_name: dataAzurermSharedImageExisting.resourceGroupName,
  target_region: [
    {
      name: dataAzurermSharedImageExisting.location,
      regional_replica_count: 5,
      storage_account_type: "Standard_LRS",
    },
  ],
});

Argument Reference

The following arguments are supported:

  • name - (Required) The version number for this Image Version, such as 100. Changing this forces a new resource to be created.

  • galleryName - (Required) The name of the Shared Image Gallery in which the Shared Image exists. Changing this forces a new resource to be created.

  • imageName - (Required) The name of the Shared Image within the Shared Image Gallery in which this Version should be created. Changing this forces a new resource to be created.

  • location - (Required) The Azure Region in which the Shared Image Gallery exists. Changing this forces a new resource to be created.

  • resourceGroupName - (Required) The name of the Resource Group in which the Shared Image Gallery exists. Changing this forces a new resource to be created.

  • targetRegion - (Required) One or more targetRegion blocks as documented below.

  • blobUri - (Optional) URI of the Azure Storage Blob used to create the Image Version. Changing this forces a new resource to be created.

-> NOTE: You must specify exact one of blobUri, managedImageId and osDiskSnapshotId.

-> NOTE: blobUri and storageAccountId must be specified together

  • endOfLifeDate - (Optional) The end of life date in RFC3339 format of the Image Version.

  • excludeFromLatest - (Optional) Should this Image Version be excluded from the latest filter? If set to true this Image Version won't be returned for the latest version. Defaults to false.

  • managedImageId - (Optional) The ID of the Managed Image or Virtual Machine ID which should be used for this Shared Image Version. Changing this forces a new resource to be created.

-> NOTE: The ID can be sourced from the azurermImage Data Source or Resource.

-> NOTE: You must specify exact one of blobUri, managedImageId and osDiskSnapshotId.

  • osDiskSnapshotId - (Optional) The ID of the OS disk snapshot which should be used for this Shared Image Version. Changing this forces a new resource to be created.

-> NOTE: You must specify exact one of blobUri, managedImageId and osDiskSnapshotId.

  • replicationMode - (Optional) Mode to be used for replication. Possible values are full and shallow. Defaults to full. Changing this forces a new resource to be created.

  • storageAccountId - (Optional) The ID of the Storage Account where the Blob exists. Changing this forces a new resource to be created.

-> NOTE: blobUri and storageAccountId must be specified together

  • tags - (Optional) A collection of tags which should be applied to this resource.

The targetRegion block supports the following:

  • name - (Required) The Azure Region in which this Image Version should exist.

  • regionalReplicaCount - (Required) The number of replicas of the Image Version to be created per region.

  • diskEncryptionSetId - (Optional) The ID of the Disk Encryption Set to encrypt the Image Version in the target region. Changing this forces a new resource to be created.

  • storageAccountType - (Optional) The storage account type for the image version. Possible values are standardLrs, premiumLrs and standardZrs. Defaults to standardLrs. You can store all of your image version replicas in Zone Redundant Storage by specifying standardZrs.

Attributes Reference

The following attributes are exported:

  • id - The ID of the Shared Image Version.

Timeouts

The timeouts block allows you to specify timeouts for certain actions:

  • create - (Defaults to 30 minutes) Used when creating the Shared Image Version.
  • update - (Defaults to 30 minutes) Used when updating the Shared Image Version.
  • read - (Defaults to 5 minutes) Used when retrieving the Shared Image Version.
  • delete - (Defaults to 30 minutes) Used when deleting the Shared Image Version.

Import

Shared Image Versions can be imported using the resourceId, e.g.

terraform import azurerm_shared_image_version.version /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/mygroup1/providers/Microsoft.Compute/galleries/gallery1/images/image1/versions/1.2.3