All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.pulumi.alicloud.ecs.Image Maven / Gradle / Ivy

There is a newer version: 3.63.0-alpha.1727424957
Show newest version
// *** WARNING: this file was generated by pulumi-java-gen. ***
// *** Do not edit by hand unless you're certain you know what you are doing! ***

package com.pulumi.alicloud.ecs;

import com.pulumi.alicloud.Utilities;
import com.pulumi.alicloud.ecs.ImageArgs;
import com.pulumi.alicloud.ecs.inputs.ImageState;
import com.pulumi.alicloud.ecs.outputs.ImageDiskDeviceMapping;
import com.pulumi.core.Output;
import com.pulumi.core.annotations.Export;
import com.pulumi.core.annotations.ResourceType;
import com.pulumi.core.internal.Codegen;
import java.lang.Boolean;
import java.lang.Object;
import java.lang.String;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import javax.annotation.Nullable;

/**
 * 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 since v1.64.0.
 * 
 * ## Example Usage
 * 
 * <!--Start PulumiCodeChooser -->
 * 
 * {@code
 * 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.random.integer;
 * import com.pulumi.random.IntegerArgs;
 * 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 default = AlicloudFunctions.getZones(GetZonesArgs.builder()
 *             .availableResourceCreation("Instance")
 *             .build());
 * 
 *         final var defaultGetInstanceTypes = EcsFunctions.getInstanceTypes(GetInstanceTypesArgs.builder()
 *             .instanceTypeFamily("ecs.sn1ne")
 *             .build());
 * 
 *         final var defaultGetImages = 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(default_.zones()[0].id())
 *             .build());
 * 
 *         var defaultSecurityGroup = new SecurityGroup("defaultSecurityGroup", SecurityGroupArgs.builder()
 *             .name("terraform-example")
 *             .vpcId(defaultNetwork.id())
 *             .build());
 * 
 *         var defaultInstance = new Instance("defaultInstance", InstanceArgs.builder()
 *             .availabilityZone(default_.zones()[0].id())
 *             .instanceName("terraform-example")
 *             .securityGroups(defaultSecurityGroup.id())
 *             .vswitchId(defaultSwitch.id())
 *             .instanceType(defaultGetInstanceTypes.applyValue(getInstanceTypesResult -> getInstanceTypesResult.ids()[0]))
 *             .imageId(defaultGetImages.applyValue(getImagesResult -> getImagesResult.ids()[0]))
 *             .internetMaxBandwidthOut(10)
 *             .build());
 * 
 *         final var defaultGetResourceGroups = ResourcemanagerFunctions.getResourceGroups();
 * 
 *         var defaultInteger = new Integer("defaultInteger", IntegerArgs.builder()
 *             .min(10000)
 *             .max(99999)
 *             .build());
 * 
 *         var defaultImage = new Image("defaultImage", ImageArgs.builder()
 *             .instanceId(defaultInstance.id())
 *             .imageName(String.format("terraform-example-%s", defaultInteger.result()))
 *             .description("terraform-example")
 *             .architecture("x86_64")
 *             .resourceGroupId(defaultGetResourceGroups.applyValue(getResourceGroupsResult -> getResourceGroupsResult.ids()[0]))
 *             .tags(Map.of("FinanceDept", "FinanceDeptJoshua"))
 *             .build());
 * 
 *     }
 * }
 * }
 * 
* <!--End PulumiCodeChooser --> * * ## Import * * image can be imported using the id, e.g. * * ```sh * $ pulumi import alicloud:ecs/image:Image default m-uf66871ape***yg1q*** * ``` * */ @ResourceType(type="alicloud:ecs/image:Image") public class Image extends com.pulumi.resources.CustomResource { /** * 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`. * */ @Export(name="architecture", refs={String.class}, tree="[0]") private Output architecture; /** * @return 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`. * */ public Output> architecture() { return Codegen.optional(this.architecture); } @Export(name="deleteAutoSnapshot", refs={Boolean.class}, tree="[0]") private Output deleteAutoSnapshot; public Output> deleteAutoSnapshot() { return Codegen.optional(this.deleteAutoSnapshot); } /** * 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. * */ @Export(name="description", refs={String.class}, tree="[0]") private Output description; /** * @return 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. * */ public Output> description() { return Codegen.optional(this.description); } /** * Description of the system with disks and snapshots under the image. * */ @Export(name="diskDeviceMappings", refs={List.class,ImageDiskDeviceMapping.class}, tree="[0,1]") private Output> diskDeviceMappings; /** * @return Description of the system with disks and snapshots under the image. * */ public Output> diskDeviceMappings() { return this.diskDeviceMappings; } /** * Indicates whether to force delete the custom image, Default is `false`. * - true:Force deletes the custom image, regardless of whether the image is currently being used by other instances. * - false:Verifies that the image is not currently in use by any other instances before deleting the image. * */ @Export(name="force", refs={Boolean.class}, tree="[0]") private Output force; /** * @return Indicates whether to force delete the custom image, Default is `false`. * - true:Force deletes the custom image, regardless of whether the image is currently being used by other instances. * - false:Verifies that the image is not currently in use by any other instances before deleting the image. * */ public Output> force() { return Codegen.optional(this.force); } /** * 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. * */ @Export(name="imageName", refs={String.class}, tree="[0]") private Output imageName; /** * @return 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. * */ public Output imageName() { return this.imageName; } /** * The instance ID. * */ @Export(name="instanceId", refs={String.class}, tree="[0]") private Output instanceId; /** * @return The instance ID. * */ public Output> instanceId() { return Codegen.optional(this.instanceId); } /** * @deprecated * Attribute 'name' has been deprecated from version 1.69.0. Use `image_name` instead. * */ @Deprecated /* Attribute 'name' has been deprecated from version 1.69.0. Use `image_name` instead. */ @Export(name="name", refs={String.class}, tree="[0]") private Output name; public Output name() { return this.name; } /** * 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](https://www.alibabacloud.com/help/en/elastic-compute-service/latest/createimage) * **NOTE**: It's default value is Ubuntu before version 1.197.0. * */ @Export(name="platform", refs={String.class}, tree="[0]") private Output platform; /** * @return 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](https://www.alibabacloud.com/help/en/elastic-compute-service/latest/createimage) * **NOTE**: It's default value is Ubuntu before version 1.197.0. * */ public Output platform() { return this.platform; } /** * The ID of the enterprise resource group to which a custom image belongs * */ @Export(name="resourceGroupId", refs={String.class}, tree="[0]") private Output resourceGroupId; /** * @return The ID of the enterprise resource group to which a custom image belongs * */ public Output> resourceGroupId() { return Codegen.optional(this.resourceGroupId); } /** * Specifies a snapshot that is used to create a custom image. * */ @Export(name="snapshotId", refs={String.class}, tree="[0]") private Output snapshotId; /** * @return Specifies a snapshot that is used to create a custom image. * */ public Output> snapshotId() { return Codegen.optional(this.snapshotId); } /** * The tag value of an image. The value of N ranges from 1 to 20. * */ @Export(name="tags", refs={Map.class,String.class,Object.class}, tree="[0,1,2]") private Output> tags; /** * @return The tag value of an image. The value of N ranges from 1 to 20. * */ public Output>> tags() { return Codegen.optional(this.tags); } /** * * @param name The _unique_ name of the resulting resource. */ public Image(String name) { this(name, ImageArgs.Empty); } /** * * @param name The _unique_ name of the resulting resource. * @param args The arguments to use to populate this resource's properties. */ public Image(String name, @Nullable ImageArgs args) { this(name, args, null); } /** * * @param name The _unique_ name of the resulting resource. * @param args The arguments to use to populate this resource's properties. * @param options A bag of options that control this resource's behavior. */ public Image(String name, @Nullable ImageArgs args, @Nullable com.pulumi.resources.CustomResourceOptions options) { super("alicloud:ecs/image:Image", name, args == null ? ImageArgs.Empty : args, makeResourceOptions(options, Codegen.empty())); } private Image(String name, Output id, @Nullable ImageState state, @Nullable com.pulumi.resources.CustomResourceOptions options) { super("alicloud:ecs/image:Image", name, state, makeResourceOptions(options, id)); } private static com.pulumi.resources.CustomResourceOptions makeResourceOptions(@Nullable com.pulumi.resources.CustomResourceOptions options, @Nullable Output id) { var defaultOptions = com.pulumi.resources.CustomResourceOptions.builder() .version(Utilities.getVersion()) .build(); return com.pulumi.resources.CustomResourceOptions.merge(defaultOptions, options, id); } /** * Get an existing Host resource's state with the given name, ID, and optional extra * properties used to qualify the lookup. * * @param name The _unique_ name of the resulting resource. * @param id The _unique_ provider ID of the resource to lookup. * @param state * @param options Optional settings to control the behavior of the CustomResource. */ public static Image get(String name, Output id, @Nullable ImageState state, @Nullable com.pulumi.resources.CustomResourceOptions options) { return new Image(name, id, state, options); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy