oci_core_image

This resource provides the Image resource in Oracle Cloud Infrastructure Core service.

Creates a boot disk image for the specified instance or imports an exported image from the Oracle Cloud Infrastructure Object Storage service.

When creating a new image, you must provide the OCID of the instance you want to use as the basis for the image, and the OCID of the compartment containing that instance. For more information about images, see Managing Custom Images.

When importing an exported image from Object Storage, you specify the source information in ImageSourceDetails.

When importing an image based on the namespace, bucket name, and object name, use ImageSourceViaObjectStorageTupleDetails.

When importing an image based on the Object Storage URL, use ImageSourceViaObjectStorageUriDetails. See Object Storage URLs and Using Pre-Authenticated Requests for constructing URLs for image import/export.

For more information about importing exported images, see Image Import/Export.

You may optionally specify a display name for the image, which is simply a friendly name or description. It does not have to be unique, and you can change it. See UpdateImage. Avoid entering confidential information.

Example Usage

Create image from instance in tenancy

resource "oci_core_image" "test_image" {
	#Required
	compartment_id = var.compartment_id
	instance_id = oci_core_instance.test_instance.id

	#Optional
	defined_tags = {"Operations.CostCenter"= "42"}
	display_name = var.image_display_name
	launch_mode = var.image_launch_mode
	freeform_tags = {"Department"= "Finance"}
}

Create image from exported image via direct access to object store

resource "oci_core_image" "test_image" {
	#Required
	compartment_id = var.compartment_id

	#Optional
	display_name = var.image_display_name
	launch_mode = var.image_launch_mode
	
	image_source_details {
		source_type = "objectStorageTuple"
		bucket_name = var.bucket_name
		namespace_name = var.namespace
		object_name = var.object_name # exported image name
        
		#Optional
		operating_system = var.image_image_source_details_operating_system
		operating_system_version = var.image_image_source_details_operating_system_version
		source_image_type = var.source_image_type
	}
}

Create image from exported image at publicly accessible uri

resource "oci_core_image" "test_image" {
	#Required
	compartment_id = var.compartment_id

	#Optional
	display_name = var.image_display_name
	launch_mode = var.image_launch_mode
	
	image_source_details {
		source_type = "objectStorageUri"
		source_uri = var.source_uri 

		#Optional
		operating_system = var.image_image_source_details_operating_system
		operating_system_version = var.image_image_source_details_operating_system_version
		source_image_type = var.source_image_type
    }
}

Argument Reference

The following arguments are supported:

** IMPORTANT ** Any change to a property that does not support update will force the destruction and recreation of the resource with the new property values

Attributes Reference

The following attributes are exported:

Timeouts

The timeouts block allows you to specify timeouts for certain operations: * create - (Defaults to 2 hours), when creating the Image * update - (Defaults to 2 hours), when updating the Image * delete - (Defaults to 2 hours), when destroying the Image

Import

Images can be imported using the id, e.g.

$ terraform import oci_core_image.test_image "id"