copyImage

abstract suspend fun copyImage(input: CopyImageRequest): CopyImageResponse

Initiates an AMI copy operation. You can copy an AMI from one Region to another, or from a Region to an Outpost. You can't copy an AMI from an Outpost to a Region, from one Outpost to another, or within the same Outpost. To copy an AMI to another partition, see CreateStoreImageTask.

When you copy an AMI from one Region to another, the destination Region is the current Region.

When you copy an AMI from a Region to an Outpost, specify the ARN of the Outpost as the destination. Backing snapshots copied to an Outpost are encrypted by default using the default encryption key for the Region or the key that you specify. Outposts do not support unencrypted snapshots.

For information about the prerequisites when copying an AMI, see Copy an Amazon EC2 AMI in the Amazon EC2 User Guide.

Samples


fun main() { 
   //sampleStart 
   // This example copies the specified AMI from the us east 1 region to the current region.
val resp = ec2Client.copyImage {
    description = ""
    name = "My server"
    sourceImageId = "ami-5731123e"
    sourceRegion = "us-east-1"
} 
   //sampleEnd
}