github.com/vtorhonen/terraform@v0.9.0-beta2.0.20170307220345-5d894e4ffda7/website/source/docs/providers/aws/r/ami.html.markdown (about) 1 --- 2 layout: "aws" 3 page_title: "AWS: aws_ami" 4 sidebar_current: "docs-aws-resource-ami" 5 description: |- 6 Creates and manages a custom Amazon Machine Image (AMI). 7 --- 8 9 # aws\_ami 10 11 The AMI resource allows the creation and management of a completely-custom 12 *Amazon Machine Image* (AMI). 13 14 If you just want to duplicate an existing AMI, possibly copying it to another 15 region, it's better to use `aws_ami_copy` instead. 16 17 If you just want to share an existing AMI with another AWS account, 18 it's better to use `aws_ami_launch_permission` instead. 19 20 ## Example Usage 21 22 ``` 23 # Create an AMI that will start a machine whose root device is backed by 24 # an EBS volume populated from a snapshot. It is assumed that such a snapshot 25 # already exists with the id "snap-xxxxxxxx". 26 resource "aws_ami" "example" { 27 name = "terraform-example" 28 virtualization_type = "hvm" 29 root_device_name = "/dev/xvda" 30 31 ebs_block_device { 32 device_name = "/dev/xvda" 33 snapshot_id = "snap-xxxxxxxx" 34 volume_size = 8 35 } 36 } 37 ``` 38 39 ## Argument Reference 40 41 The following arguments are supported: 42 43 * `name` - (Required) A region-unique name for the AMI. 44 * `description` - (Optional) A longer, human-readable description for the AMI. 45 * `virtualization_type` - (Optional) Keyword to choose what virtualization mode created instances 46 will use. Can be either "paravirtual" (the default) or "hvm". The choice of virtualization type 47 changes the set of further arguments that are required, as described below. 48 * `architecture` - (Optional) Machine architecture for created instances. Defaults to "x86_64". 49 * `ebs_block_device` - (Optional) Nested block describing an EBS block device that should be 50 attached to created instances. The structure of this block is described below. 51 * `ephemeral_block_device` - (Optional) Nested block describing an ephemeral block device that 52 should be attached to created instances. The structure of this block is described below. 53 54 When `virtualization_type` is "paravirtual" the following additional arguments apply: 55 56 * `image_location` - (Required) Path to an S3 object containing an image manifest, e.g. created 57 by the `ec2-upload-bundle` command in the EC2 command line tools. 58 * `kernel_id` - (Required) The id of the kernel image (AKI) that will be used as the paravirtual 59 kernel in created instances. 60 * `ramdisk_id` - (Optional) The id of an initrd image (ARI) that will be used when booting the 61 created instances. 62 63 When `virtualization_type` is "hvm" the following additional arguments apply: 64 65 * `sriov_net_support` - (Optional) When set to "simple" (the default), enables enhanced networking 66 for created instances. No other value is supported at this time. 67 68 Nested `ebs_block_device` blocks have the following structure: 69 70 * `device_name` - (Required) The path at which the device is exposed to created instances. 71 * `delete_on_termination` - (Optional) Boolean controlling whether the EBS volumes created to 72 support each created instance will be deleted once that instance is terminated. 73 * `encrypted` - (Optional) Boolean controlling whether the created EBS volumes will be encrypted. 74 * `iops` - (Required only when `volume_type` is "io1") Number of I/O operations per second the 75 created volumes will support. 76 * `snapshot_id` - (Optional) The id of an EBS snapshot that will be used to initialize the created 77 EBS volumes. If set, the `volume_size` attribute must be at least as large as the referenced 78 snapshot. 79 * `volume_size` - (Required unless `snapshot_id` is set) The size of created volumes in GiB. 80 If `snapshot_id` is set and `volume_size` is omitted then the volume will have the same size 81 as the selected snapshot. 82 * `volume_type` - (Optional) The type of EBS volume to create. Can be one of "standard" (the 83 default), "io1" or "gp2". 84 * `encrypted` - (Optional) Specifies whether the destination snapshots of the copied image should be encrypted. 85 The default CMK for EBS is used unless a non-default AWS Key Management Service (AWS KMS) CMK is specified with KmsKeyId. 86 * `kms_key_id` - (Optional) The full ARN of the AWS Key Management Service (AWS KMS) CMK to use when encrypting the snapshots of 87 an image during a copy operation. This parameter is only required if you want to use a non-default CMK; 88 if this parameter is not specified, the default CMK for EBS is used 89 90 Nested `ephemeral_block_device` blocks have the following structure: 91 92 * `device_name` - (Required) The path at which the device is exposed to created instances. 93 * `virtual_name` - (Required) A name for the ephemeral device, of the form "ephemeralN" where 94 *N* is a volume number starting from zero. 95 96 ## Attributes Reference 97 98 The following attributes are exported: 99 100 * `id` - The ID of the created AMI.