github.com/amanya/packer@v0.12.1-0.20161117214323-902ac5ab2eb6/website/source/docs/builders/amazon-ebs-volume.html.md (about) 1 --- 2 description: | 3 The `amazon-ebsvolume` Packer builder is like the EBS builder, but is 4 intended to create EBS volumes rather than a machine image. 5 layout: docs 6 page_title: 'Amazon EBS Volume Builder' 7 ... 8 9 # EBS Volume Builder 10 11 Type: `amazon-ebsvolume` 12 13 The `amazon-ebsvolume` Packer builder is able to create Amazon Elastic Block 14 Store volumes which are prepopulated with filesystems or data. 15 16 This builder builds EBS volumes by launching an EC2 instance from a source AMI, 17 provisioning that running machine, and then destroying the source machine, keeping 18 the volumes intact. 19 20 This is all done in your own AWS account. The builder will create temporary 21 keypairs, security group rules, etc. that provide it temporary access to the 22 instance while the image is being created. 23 24 The builder does *not* manage EBS Volumes. Once it creates volumes and stores 25 it in your account, it is up to you to use, delete, etc. the volumes. 26 27 ## Configuration Reference 28 29 There are many configuration options available for the builder. They are 30 segmented below into two categories: required and optional parameters. Within 31 each category, the available configuration keys are alphabetized. 32 33 In addition to the options listed here, a 34 [communicator](/docs/templates/communicator.html) can be configured for this 35 builder. 36 37 ### Required: 38 39 - `access_key` (string) - The access key used to communicate with AWS. [Learn 40 how to set this.](/docs/builders/amazon.html#specifying-amazon-credentials) 41 42 - `instance_type` (string) - The EC2 instance type to use while building the 43 AMI, such as "m1.small". 44 45 - `region` (string) - The name of the region, such as "us-east-1", in which to 46 launch the EC2 instance to create the AMI. 47 48 - `secret_key` (string) - The secret key used to communicate with AWS. [Learn 49 how to set this.](/docs/builders/amazon.html#specifying-amazon-credentials) 50 51 - `source_ami` (string) - The initial AMI used as a base for the newly 52 created machine. `source_ami_filter` may be used instead to populate this 53 automatically. 54 55 ### Optional: 56 57 - `ebs_volumes` (array of block device mappings) - Add the block 58 device mappings to the AMI. The block device mappings allow for keys: 59 60 - `device_name` (string) - The device name exposed to the instance (for 61 example, "/dev/sdh" or "xvdh"). Required when specifying `volume_size`. 62 - `delete_on_termination` (boolean) - Indicates whether the EBS volume is 63 deleted on instance termination 64 - `encrypted` (boolean) - Indicates whether to encrypt the volume or not 65 - `iops` (integer) - The number of I/O operations per second (IOPS) that the 66 volume supports. See the documentation on 67 [IOPs](https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_EbsBlockDevice.html) 68 for more information 69 - `no_device` (boolean) - Suppresses the specified device included in the 70 block device mapping of the AMI 71 - `snapshot_id` (string) - The ID of the snapshot 72 - `virtual_name` (string) - The virtual device name. See the documentation on 73 [Block Device 74 Mapping](https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_BlockDeviceMapping.html) 75 for more information 76 - `volume_size` (integer) - The size of the volume, in GiB. Required if not 77 specifying a `snapshot_id` 78 - `volume_type` (string) - The volume type. gp2 for General Purpose (SSD) 79 volumes, io1 for Provisioned IOPS (SSD) volumes, and standard for Magnetic 80 volumes 81 - `tags` (map) - Tags to apply to the volume. These are retained after the 82 builder completes. 83 84 - `associate_public_ip_address` (boolean) - If using a non-default VPC, public 85 IP addresses are not provided by default. If this is toggled, your new 86 instance will get a Public IP. 87 88 - `availability_zone` (string) - Destination availability zone to launch 89 instance in. Leave this empty to allow Amazon to auto-assign. 90 91 - `ebs_optimized` (boolean) - Mark instance as [EBS 92 Optimized](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/EBSOptimized.html). 93 Default `false`. 94 95 - `enhanced_networking` (boolean) - Enable enhanced 96 networking (SriovNetSupport) on HVM-compatible AMIs. If true, add 97 `ec2:ModifyInstanceAttribute` to your AWS IAM policy. 98 99 - `iam_instance_profile` (string) - The name of an [IAM instance 100 profile](https://docs.aws.amazon.com/IAM/latest/UserGuide/instance-profiles.html) 101 to launch the EC2 instance with. 102 103 - `run_tags` (object of key/value strings) - Tags to apply to the instance 104 that is *launched* to create the AMI. These tags are *not* applied to the 105 resulting AMI unless they're duplicated in `tags`. 106 107 - `security_group_id` (string) - The ID (*not* the name) of the security group 108 to assign to the instance. By default this is not set and Packer will 109 automatically create a new temporary security group to allow SSH access. 110 Note that if this is specified, you must be sure the security group allows 111 access to the `ssh_port` given below. 112 113 - `security_group_ids` (array of strings) - A list of security groups as 114 described above. Note that if this is specified, you must omit the 115 `security_group_id`. 116 117 - `skip_region_validation` (boolean) - Set to true if you want to skip 118 validation of the region configuration option. Defaults to false. 119 120 - `source_ami_filter` (object) - Filters used to populate the `source_ami` field. 121 Example: 122 ``` {.javascript} 123 "source_ami_filter": { 124 "filters": { 125 "virtualization-type": "hvm", 126 "name": "*ubuntu-xenial-16.04-amd64-server-*", 127 "root-device-type": "ebs" 128 }, 129 "owners": ["099720109477"], 130 "most_recent": true 131 } 132 ``` 133 This selects the most recent Ubuntu 16.04 HVM EBS AMI from Canonical. 134 NOTE: This will fail unless *exactly* one AMI is returned. In the above 135 example, `most_recent` will cause this to succeed by selecting the newest image. 136 137 - `filters` (map of strings) - filters used to select a `source_ami`. 138 NOTE: This will fail unless *exactly* one AMI is returned. 139 Any filter described in the docs for [DescribeImages](http://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_DescribeImages.html) 140 is valid. 141 142 - `owners` (array of strings) - This scopes the AMIs to certain Amazon account IDs. 143 This is helpful to limit the AMIs to a trusted third party, or to your own account. 144 145 - `most_recent` (bool) - Selects the newest created image when true. 146 This is most useful for selecting a daily distro build. 147 148 - `spot_price` (string) - The maximum hourly price to pay for a spot instance 149 to create the AMI. Spot instances are a type of instance that EC2 starts 150 when the current spot price is less than the maximum price you specify. Spot 151 price will be updated based on available spot instance capacity and current 152 spot instance requests. It may save you some costs. You can set this to 153 "auto" for Packer to automatically discover the best spot price or to "0" 154 to use an on demand instance (default). 155 156 - `spot_price_auto_product` (string) - Required if `spot_price` is set 157 to "auto". This tells Packer what sort of AMI you're launching to find the 158 best spot price. This must be one of: `Linux/UNIX`, `SUSE Linux`, `Windows`, 159 `Linux/UNIX (Amazon VPC)`, `SUSE Linux (Amazon VPC)`, `Windows (Amazon VPC)` 160 161 - `ssh_keypair_name` (string) - If specified, this is the key that will be 162 used for SSH with the machine. By default, this is blank, and Packer will 163 generate a temporary keypair unless 164 [`ssh_password`](/docs/templates/communicator.html#ssh_password) is used. 165 [`ssh_private_key_file`](/docs/templates/communicator.html#ssh_private_key_file) 166 must be specified with this. 167 168 - `ssh_private_ip` (boolean) - If true, then SSH will always use the private 169 IP if available. 170 171 - `subnet_id` (string) - If using VPC, the ID of the subnet, such as 172 "subnet-12345def", where Packer will launch the EC2 instance. This field is 173 required if you are using an non-default VPC. 174 175 - `temporary_key_pair_name` (string) - The name of the temporary keypair 176 to generate. By default, Packer generates a name with a UUID. 177 178 - `token` (string) - The access token to use. This is different from the 179 access key and secret key. If you're not sure what this is, then you 180 probably don't need it. This will also be read from the `AWS_SESSION_TOKEN` 181 environmental variable. 182 183 - `user_data` (string) - User data to apply when launching the instance. Note 184 that you need to be careful about escaping characters due to the templates 185 being JSON. It is often more convenient to use `user_data_file`, instead. 186 187 - `user_data_file` (string) - Path to a file that will be used for the user 188 data when launching the instance. 189 190 - `vpc_id` (string) - If launching into a VPC subnet, Packer needs the VPC ID 191 in order to create a temporary security group within the VPC. Requires `subnet_id` 192 to be set. 193 194 - `windows_password_timeout` (string) - The timeout for waiting for a Windows 195 password for Windows instances. Defaults to 20 minutes. Example value: "10m" 196 197 - `shutdown_behaviour` (string) - Automatically terminate instances on shutdown 198 incase packer exits ungracefully. Possible values are "stop" and "terminate", 199 default is stop. 200 201 ## Basic Example 202 203 ``` 204 { 205 "type" : "amazon-ebsvolume", 206 "secret_key" : "YOUR SECRET KEY HERE", 207 "access_key" : "YOUR KEY HERE", 208 "region" : "us-east-1", 209 "ssh_username" : "ubuntu", 210 "instance_type" : "t2.medium", 211 "source_ami" : "ami-40d28157", 212 "ebs_volumes" : [ 213 { 214 "volume_type" : "gp2", 215 "device_name" : "/dev/xvdf", 216 "delete_on_termination" : false, 217 "tags" : { 218 "zpool" : "data", 219 "Name" : "Data1" 220 }, 221 "volume_size" : 10 222 }, 223 { 224 "volume_type" : "gp2", 225 "device_name" : "/dev/xvdg", 226 "tags" : { 227 "zpool" : "data", 228 "Name" : "Data2" 229 }, 230 "delete_on_termination" : false, 231 "volume_size" : 10 232 }, 233 { 234 "volume_size" : 10, 235 "tags" : { 236 "Name" : "Data3", 237 "zpool" : "data" 238 }, 239 "delete_on_termination" : false, 240 "device_name" : "/dev/xvdh", 241 "volume_type" : "gp2" 242 } 243 ] 244 } 245 ``` 246 247 -> **Note:** Packer can also read the access key and secret access key from 248 environmental variables. See the configuration reference in the section above 249 for more information on what environmental variables Packer will look for. 250 251 Further information on locating AMI IDs and their relationship to instance 252 types and regions can be found in the AWS EC2 Documentation 253 [for Linux](http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/finding-an-ami.html) 254 or [for Windows](http://docs.aws.amazon.com/AWSEC2/latest/WindowsGuide/finding-an-ami.html). 255 256 ## Accessing the Instance to Debug 257 258 If you need to access the instance to debug for some reason, run the builder 259 with the `-debug` flag. In debug mode, the Amazon builder will save the private 260 key in the current directory and will output the DNS or IP information as well. 261 You can use this information to access the instance as it is running. 262 263 -> **Note:** Packer uses pre-built AMIs as the source for building images. 264 These source AMIs may include volumes that are not flagged to be destroyed on 265 termination of the instance building the new image. In addition to those volumes 266 created by this builder, any volumes inn the source AMI which are not marked for 267 deletion on termination will remain in your account.