ImageCopyArgs

data class ImageCopyArgs(val deleteAutoSnapshot: Output<Boolean>? = null, val description: Output<String>? = null, val encrypted: Output<Boolean>? = null, val force: Output<Boolean>? = null, val imageName: Output<String>? = null, val kmsKeyId: Output<String>? = null, val name: Output<String>? = null, val sourceImageId: Output<String>? = null, val sourceRegionId: Output<String>? = null, val tags: Output<Map<String, Any>>? = null) : ConvertibleToJava<ImageCopyArgs>

Copies a custom image from one region to another. You can use copied images to perform operations in the target region, such as creating instances (RunInstances) and replacing system disks (ReplaceSystemDisk).

NOTE: You can only copy the custom image when it is in the Available state. NOTE: You can only copy the image belonging to your Alibaba Cloud account. Images cannot be copied from one account to another. NOTE: If the copying is not completed, you cannot call DeleteImage to delete the image but you can call CancelCopyImage to cancel the copying. NOTE: Available in 1.66.0+.

Example Usage

package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.alicloud.Provider;
import com.pulumi.alicloud.ProviderArgs;
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.ecs.Image;
import com.pulumi.alicloud.ecs.ImageArgs;
import com.pulumi.alicloud.ecs.ImageCopy;
import com.pulumi.alicloud.ecs.ImageCopyArgs;
import com.pulumi.resources.CustomResourceOptions;
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) {
var sh = new Provider("sh", ProviderArgs.builder()
.region("cn-shanghai")
.build());
var hz = new Provider("hz", ProviderArgs.builder()
.region("cn-hangzhou")
.build());
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(), CustomResourceOptions.builder()
.provider(alicloud.hz())
.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(), CustomResourceOptions.builder()
.provider(alicloud.hz())
.build());
var defaultSecurityGroup = new SecurityGroup("defaultSecurityGroup", SecurityGroupArgs.builder()
.vpcId(defaultNetwork.id())
.build(), CustomResourceOptions.builder()
.provider(alicloud.hz())
.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(), CustomResourceOptions.builder()
.provider(alicloud.hz())
.build());
var defaultImage = new Image("defaultImage", ImageArgs.builder()
.instanceId(defaultInstance.id())
.imageName("terraform-example")
.description("terraform-example")
.build(), CustomResourceOptions.builder()
.provider(alicloud.hz())
.build());
var defaultImageCopy = new ImageCopy("defaultImageCopy", ImageCopyArgs.builder()
.sourceImageId(defaultImage.id())
.sourceRegionId("cn-hangzhou")
.imageName("terraform-example")
.description("terraform-example")
.tags(Map.of("FinanceDept", "FinanceDeptJoshua"))
.build(), CustomResourceOptions.builder()
.provider(alicloud.sh())
.build());
}
}

Attributes Reference0

The following attributes are exported:

  • id - ID of the image.

Import

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

$ pulumi import alicloud:ecs/imageCopy:ImageCopy default m-uf66871ape***yg1q***

Constructors

Link copied to clipboard
fun ImageCopyArgs(deleteAutoSnapshot: Output<Boolean>? = null, description: Output<String>? = null, encrypted: Output<Boolean>? = null, force: Output<Boolean>? = null, imageName: Output<String>? = null, kmsKeyId: Output<String>? = null, name: Output<String>? = null, sourceImageId: Output<String>? = null, sourceRegionId: Output<String>? = null, tags: Output<Map<String, Any>>? = null)

Functions

Link copied to clipboard
open override fun toJava(): ImageCopyArgs

Properties

Link copied to clipboard
val deleteAutoSnapshot: Output<Boolean>? = null
Link copied to clipboard
val description: Output<String>? = null

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
val encrypted: Output<Boolean>? = null

Indicates whether to encrypt the image.

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

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

Link copied to clipboard
val imageName: Output<String>? = null

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 kmsKeyId: Output<String>? = null

Key ID used to encrypt the image.

Link copied to clipboard
val name: Output<String>? = null
Link copied to clipboard
val sourceImageId: Output<String>? = null

The source image ID.

Link copied to clipboard
val sourceRegionId: Output<String>? = null

The ID of the region to which the source custom image belongs. You can call DescribeRegions to view the latest regions of Alibaba Cloud.

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

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