Skip to content

Resource: awsAmiCopy

The "AMI copy" resource allows duplication of an Amazon Machine Image (AMI), including cross-region copies.

If the source AMI has associated EBS snapshots, those will also be duplicated along with the AMI.

This is useful for taking a single AMI provisioned in one region and making it available in another for a multi-region deployment.

Copying an AMI can take several minutes. The creation of this resource will block until the new AMI is available for use on new instances.

Example Usage

/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as aws from "./.gen/providers/aws";
new aws.amiCopy.AmiCopy(this, "example", {
  description: "A copy of ami-xxxxxxxx",
  name: "terraform-example",
  sourceAmiId: "ami-xxxxxxxx",
  sourceAmiRegion: "us-west-1",
  tags: {
    Name: "HelloWorld",
  },
});

Argument Reference

The following arguments are supported:

  • name - (Required) Region-unique name for the AMI.
  • sourceAmiId - (Required) Id of the AMI to copy. This id must be valid in the region given by sourceAmiRegion.
  • sourceAmiRegion - (Required) Region from which the AMI will be copied. This may be the same as the AWS provider region in order to create a copy within the same region.
  • destinationOutpostArn - (Optional) ARN of the Outpost to which to copy the AMI. Only specify this parameter when copying an AMI from an AWS Region to an Outpost. The AMI must be in the Region of the destination Outpost.
  • encrypted - (Optional) Whether the destination snapshots of the copied image should be encrypted. Defaults to false
  • kmsKeyId - (Optional) Full ARN of the KMS Key to use when encrypting the snapshots of an image during a copy operation. If not specified, then the default AWS KMS Key will be used
  • tags - (Optional) Map of tags to assign to the resource. If configured with a provider defaultTags configuration block present, tags with matching keys will overwrite those defined at the provider-level.

This resource also exposes the full set of arguments from the awsAmi resource.

Attributes Reference

In addition to all arguments above, the following attributes are exported:

  • arn - ARN of the AMI.
  • id - ID of the created AMI.

This resource also exports a full set of attributes corresponding to the arguments of the awsAmi resource, allowing the properties of the created AMI to be used elsewhere in the configuration.

Timeouts

Configuration options:

  • create - (Default 40M)
  • update - (Default 40M)
  • delete - (Default 90M)