Skip to content

azurermSharedImage

Manages 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 azurermResourceGroupExample = new azurerm.resourceGroup.ResourceGroup(
  this,
  "example",
  {
    location: "West Europe",
    name: "example-resources",
  }
);
const azurermSharedImageGalleryExample =
  new azurerm.sharedImageGallery.SharedImageGallery(this, "example_1", {
    description: "Shared images and things.",
    location: azurermResourceGroupExample.location,
    name: "example_image_gallery",
    resource_group_name: azurermResourceGroupExample.name,
    tags: {
      Hello: "There",
      World: "Example",
    },
  });
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
azurermSharedImageGalleryExample.overrideLogicalId("example");
const azurermSharedImageExample = new azurerm.sharedImage.SharedImage(
  this,
  "example_2",
  {
    gallery_name: azurermSharedImageGalleryExample.name,
    identifier: [
      {
        offer: "OfferName",
        publisher: "PublisherName",
        sku: "ExampleSku",
      },
    ],
    location: azurermResourceGroupExample.location,
    name: "my-image",
    os_type: "Linux",
    resource_group_name: azurermResourceGroupExample.name,
  }
);
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
azurermSharedImageExample.overrideLogicalId("example");

Argument Reference

The following arguments are supported:

  • name - (Required) Specifies the name of the Shared Image. Changing this forces a new resource to be created.

  • galleryName - (Required) Specifies the name of the Shared Image Gallery in which this Shared Image should exist. 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.

  • location - (Required) Specifies the supported Azure location where the Shared Image Gallery exists. Changing this forces a new resource to be created.

  • identifier - (Required) An identifier block as defined below.

  • osType - (Required) The type of Operating System present in this Shared Image. Possible values are linux and windows. Changing this forces a new resource to be created.

  • purchasePlan - (Optional) A purchasePlan block as defined below.


  • description - (Optional) A description of this Shared Image.

  • diskTypesNotAllowed - (Optional) One or more Disk Types not allowed for the Image. Possible values include standardLrs and premiumLrs.

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

  • eula - (Optional) The End User Licence Agreement for the Shared Image. Changing this forces a new resource to be created.

  • specialized - (Optional) Specifies that the Operating System used inside this Image has not been Generalized (for example, sysprep on Windows has not been run). Changing this forces a new resource to be created.

!> Note: It's recommended to Generalize images where possible - Specialized Images reuse the same UUID internally within each Virtual Machine, which can have unintended side-effects.

  • architecture - (Optional) CPU architecture supported by an OS. Possible values are x64 and arm64. Defaults to x64. Changing this forces a new resource to be created.

  • hyperVGeneration - (Optional) The generation of HyperV that the Virtual Machine used to create the Shared Image is based on. Possible values are v1 and v2. Defaults to v1. Changing this forces a new resource to be created.

  • maxRecommendedVcpuCount - (Optional) Maximum count of vCPUs recommended for the Image.

  • minRecommendedVcpuCount - (Optional) Minimum count of vCPUs recommended for the Image.

  • maxRecommendedMemoryInGb - (Optional) Maximum memory in GB recommended for the Image.

  • minRecommendedMemoryInGb - (Optional) Minimum memory in GB recommended for the Image.

  • privacyStatementUri - (Optional) The URI containing the Privacy Statement associated with this Shared Image. Changing this forces a new resource to be created.

  • releaseNoteUri - (Optional) The URI containing the Release Notes associated with this Shared Image.

  • trustedLaunchEnabled - (Optional) Specifies if Trusted Launch has to be enabled for the Virtual Machine created from the Shared Image. Changing this forces a new resource to be created.

  • confidentialVmSupported - (Optional) Specifies if supports creation of both Confidential virtual machines and Gen2 virtual machines with standard security from a compatible Gen2 OS disk VHD or Gen2 Managed image. Changing this forces a new resource to be created.

  • confidentialVmEnabled - (Optional) Specifies if Confidential Virtual Machines enabled. It will enable all the features of trusted, with higher confidentiality features for isolate machines or encrypted data. Available for Gen2 machines. Changing this forces a new resource to be created.

-> Note:: Only one of trustedLaunchEnabled, confidentialVmSupported and confidentialVmEnabled could only be specified.

  • acceleratedNetworkSupportEnabled - (Optional) Specifies if the Shared Image supports Accelerated Network. Changing this forces a new resource to be created.

  • tags - (Optional) A mapping of tags to assign to the Shared Image.


A identifier block supports the following:

  • offer - (Required) The Offer Name for this Shared Image. Changing this forces a new resource to be created.

  • publisher - (Required) The Publisher Name for this Gallery Image. Changing this forces a new resource to be created.

  • sku - (Required) The Name of the SKU for this Gallery Image. Changing this forces a new resource to be created.


A purchasePlan block supports the following:

  • name - (Required) The Purchase Plan Name for this Shared Image. Changing this forces a new resource to be created.

  • publisher - (Optional) The Purchase Plan Publisher for this Gallery Image. Changing this forces a new resource to be created.

  • product - (Optional) The Purchase Plan Product for this Gallery Image. Changing this forces a new resource to be created.

Attributes Reference

The following attributes are exported:

  • id - The ID of the Shared Image.

Timeouts

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

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

Import

Shared Images can be imported using the resourceId, e.g.

terraform import azurerm_shared_image.image1 /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/mygroup1/providers/Microsoft.Compute/galleries/gallery1/images/image1