Image

class Image : KotlinCustomResource

Creates a custom image. You can then use a custom image to create ECS instances (RunInstances) or change the system disk for an existing instance (ReplaceSystemDisk).

NOTE: If you want to create a template from an ECS instance, you can specify the instance ID (InstanceId) to create a custom image. You must make sure that the status of the specified instance is Running or Stopped. After a successful invocation, each disk of the specified instance has a new snapshot created. NOTE: If you want to create a custom image based on the system disk of your ECS instance, you can specify one of the system disk snapshots (SnapshotId) to create a custom image. However, the specified snapshot cannot be created on or before July 15, 2013. NOTE: If you want to combine snapshots of multiple disks into an image template, you can specify DiskDeviceMapping to create a custom image. NOTE: Available in 1.64.0+

Example Usage

package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.alicloud.AlicloudFunctions;
import com.pulumi.alicloud.inputs.GetZonesArgs;
import com.pulumi.alicloud.ecs.EcsFunctions;
import com.pulumi.alicloud.ecs.inputs.GetInstanceTypesArgs;
import com.pulumi.alicloud.ecs.inputs.GetImagesArgs;
import com.pulumi.alicloud.vpc.Network;
import com.pulumi.alicloud.vpc.NetworkArgs;
import com.pulumi.alicloud.vpc.Switch;
import com.pulumi.alicloud.vpc.SwitchArgs;
import com.pulumi.alicloud.ecs.SecurityGroup;
import com.pulumi.alicloud.ecs.SecurityGroupArgs;
import com.pulumi.alicloud.ecs.Instance;
import com.pulumi.alicloud.ecs.InstanceArgs;
import com.pulumi.alicloud.resourcemanager.ResourcemanagerFunctions;
import com.pulumi.alicloud.resourcemanager.inputs.GetResourceGroupsArgs;
import com.pulumi.alicloud.ecs.Image;
import com.pulumi.alicloud.ecs.ImageArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
final var defaultZones = AlicloudFunctions.getZones(GetZonesArgs.builder()
.availableResourceCreation("Instance")
.build());
final var defaultInstanceTypes = EcsFunctions.getInstanceTypes(GetInstanceTypesArgs.builder()
.instanceTypeFamily("ecs.sn1ne")
.build());
final var defaultImages = EcsFunctions.getImages(GetImagesArgs.builder()
.nameRegex("^ubuntu_[0-9]+_[0-9]+_x64*")
.owners("system")
.build());
var defaultNetwork = new Network("defaultNetwork", NetworkArgs.builder()
.vpcName("terraform-example")
.cidrBlock("172.17.3.0/24")
.build());
var defaultSwitch = new Switch("defaultSwitch", SwitchArgs.builder()
.vswitchName("terraform-example")
.cidrBlock("172.17.3.0/24")
.vpcId(defaultNetwork.id())
.zoneId(defaultZones.applyValue(getZonesResult -> getZonesResult.zones()[0].id()))
.build());
var defaultSecurityGroup = new SecurityGroup("defaultSecurityGroup", SecurityGroupArgs.builder()
.vpcId(defaultNetwork.id())
.build());
var defaultInstance = new Instance("defaultInstance", InstanceArgs.builder()
.availabilityZone(defaultZones.applyValue(getZonesResult -> getZonesResult.zones()[0].id()))
.instanceName("terraform-example")
.securityGroups(defaultSecurityGroup.id())
.vswitchId(defaultSwitch.id())
.instanceType(defaultInstanceTypes.applyValue(getInstanceTypesResult -> getInstanceTypesResult.ids()[0]))
.imageId(defaultImages.applyValue(getImagesResult -> getImagesResult.ids()[0]))
.internetMaxBandwidthOut(10)
.build());
final var defaultResourceGroups = ResourcemanagerFunctions.getResourceGroups();
var defaultImage = new Image("defaultImage", ImageArgs.builder()
.instanceId(defaultInstance.id())
.imageName("terraform-example")
.description("terraform-example")
.architecture("x86_64")
.platform("CentOS")
.resourceGroupId(defaultResourceGroups.applyValue(getResourceGroupsResult -> getResourceGroupsResult.ids()[0]))
.tags(Map.of("FinanceDept", "FinanceDeptJoshua"))
.build());
}
}

Import

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

$ pulumi import alicloud:ecs/image:Image default m-uf66871ape***yg1q***

Properties

Link copied to clipboard
val architecture: Output<String>?

Specifies the architecture of the system disk after you specify a data disk snapshot as the data source of the system disk for creating an image. Valid values: i386 , Default is x86_64.

Link copied to clipboard
Link copied to clipboard
val description: Output<String>?

The description of the image. It must be 2 to 256 characters in length and must not start with http:// or https://. Default value: null.

Link copied to clipboard

Description of the system with disks and snapshots under the image.

Link copied to clipboard
val force: Output<Boolean>?

Indicates whether to force delete the custom image, Default is false.

Link copied to clipboard
val id: Output<String>
Link copied to clipboard
val imageName: Output<String>

The image name. It must be 2 to 128 characters in length, and must begin with a letter or Chinese character (beginning with http:// or https:// is not allowed). It can contain digits, colons (:), underscores (_), or hyphens (-). Default value: null.

Link copied to clipboard
val instanceId: Output<String>?

The instance ID.

Link copied to clipboard
val name: Output<String>
Link copied to clipboard
val platform: Output<String>

The distribution of the operating system for the system disk in the custom image. If you specify a data disk snapshot to create the system disk of the custom image, you must use the Platform parameter to specify the distribution of the operating system for the system disk. Default value: Others Linux. More valid values refer to CreateImage OpenAPI NOTE: It's default value is Ubuntu before version 1.197.0.

Link copied to clipboard
val pulumiChildResources: Set<KotlinResource>
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
val resourceGroupId: Output<String>?

The ID of the enterprise resource group to which a custom image belongs

Link copied to clipboard
val snapshotId: Output<String>?

Specifies a snapshot that is used to create a combined custom image.

Link copied to clipboard
val tags: Output<Map<String, Any>>?

The tag value of an image. The value of N ranges from 1 to 20.

Link copied to clipboard
val urn: Output<String>