github.com/phobos182/packer@v0.2.3-0.20130819023704-c84d2aeffc68/website/source/docs/builders/amazon-ebs.html.markdown (about) 1 --- 2 layout: "docs" 3 page_title: "Amazon AMI Builder (EBS backed)" 4 --- 5 6 # AMI Builder (EBS backed) 7 8 Type: `amazon-ebs` 9 10 The `amazon-ebs` builder is able to create Amazon AMIs backed by EBS 11 volumes for use in [EC2](http://aws.amazon.com/ec2/). For more information 12 on the difference betwen EBS-backed instances and instance-store backed 13 instances, see the 14 ["storage for the root device" section in the EC2 documentation](http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ComponentsAMIs.html#storage-for-the-root-device). 15 16 This builder builds an AMI by launching an EC2 instance from a source AMI, 17 provisioning that running machine, and then creating an AMI from that machine. 18 This is all done in your own AWS account. The builder will create temporary 19 keypairs, security group rules, etc. that provide it temporary access to 20 the instance while the image is being created. This simplifies configuration 21 quite a bit. 22 23 The builder does _not_ manage AMIs. Once it creates an AMI and stores it 24 in your account, it is up to you to use, delete, etc. the AMI. 25 26 ## Configuration Reference 27 28 There are many configuration options available for the builder. They are 29 segmented below into two categories: required and optional parameters. Within 30 each category, the available configuration keys are alphabetized. 31 32 Required: 33 34 * `access_key` (string) - The access key used to communicate with AWS. 35 If not specified, Packer will attempt to read this from environmental 36 variables `AWS_ACCESS_KEY_ID` or `AWS_ACCESS_KEY` (in that order). 37 38 * `ami_name` (string) - The name of the resulting AMI that will appear 39 when managing AMIs in the AWS console or via APIs. This must be unique. 40 To help make this unique, use a function like `timestamp` (see 41 [configuration templates](/docs/templates/configuration-templates.html) for more info) 42 43 * `instance_type` (string) - The EC2 instance type to use while building 44 the AMI, such as "m1.small". 45 46 * `region` (string) - The name of the region, such as "us-east-1", in which 47 to launch the EC2 instance to create the AMI. 48 49 * `secret_key` (string) - The secret key used to communicate with AWS. 50 If not specified, Packer will attempt to read this from environmental 51 variables `AWS_SECRET_ACCESS_KEY` or `AWS_SECRET_KEY` (in that order). 52 53 * `source_ami` (string) - The initial AMI used as a base for the newly 54 created machine. 55 56 * `ssh_username` (string) - The username to use in order to communicate 57 over SSH to the running machine. 58 59 Optional: 60 61 * `ami_block_device_mappings` (array of block device mappings) - Add the block 62 device mappings to the AMI. The block device mappings allow for keys: 63 "device_name" (string), "virtual_name" (string), "snapshot_id" (string), 64 "volume_type" (string), "volume_size" (int), "delete_on_termination" (bool), 65 and "iops" (int). 66 67 * `ami_description` (string) - The description to set for the resulting 68 AMI(s). By default this description is empty. 69 70 * `ami_groups` (array of string) - A list of groups that have access 71 to launch the resulting AMI(s). By default no groups have permission 72 to launch the AMI. 73 74 * `ami_product_codes` (array of string) - A list of product codes to 75 associate with the AMI. By default no product codes are associated with 76 the AMI. 77 78 * `ami_users` (array of string) - A list of account IDs that have access 79 to launch the resulting AMI(s). By default no additional users other than the user 80 creating the AMI has permissions to launch it. 81 82 * `iam_instance_profile` (string) - The name of an 83 [IAM instance profile](http://docs.aws.amazon.com/IAM/latest/UserGuide/instance-profiles.html) 84 to launch the EC2 instance with. 85 86 * `launch_block_device_mappings` (array of block device mappings) - Add the 87 block device mappings to the launch instance. The block device mappings are 88 the same as `ami_block_device_mappings` above. 89 90 * `security_group_id` (string) - The ID (_not_ the name) of the security 91 group to assign to the instance. By default this is not set and Packer 92 will automatically create a new temporary security group to allow SSH 93 access. Note that if this is specified, you must be sure the security 94 group allows access to the `ssh_port` given below. 95 96 * `ssh_port` (int) - The port that SSH will be available on. This defaults 97 to port 22. 98 99 * `ssh_timeout` (string) - The time to wait for SSH to become available 100 before timing out. The format of this value is a duration such as "5s" 101 or "5m". The default SSH timeout is "1m", or one minute. 102 103 * `subnet_id` (string) - If using VPC, the ID of the subnet, such as 104 "subnet-12345def", where Packer will launch the EC2 instance. 105 106 * `tags` (object of key/value strings) - Tags applied to the AMI. 107 108 * `user_data` (string) - User data to apply when launching the instance. 109 Note that you need to be careful about escaping characters due to the 110 templates being JSON. It is often more convenient to use `user_data_file`, 111 instead. 112 113 * `user_data_file` (string) - Path to a file that will be used for the 114 user data when launching the instance. 115 116 * `vpc_id` (string) - If launching into a VPC subnet, Packer needs the 117 VPC ID in order to create a temporary security group within the VPC. 118 119 ## Basic Example 120 121 Here is a basic example. It is completely valid except for the access keys: 122 123 <pre class="prettyprint"> 124 { 125 "type": "amazon-ebs", 126 "access_key": "YOUR KEY HERE", 127 "secret_key": "YOUR SECRET KEY HERE", 128 "region": "us-east-1", 129 "source_ami": "ami-de0d9eb7", 130 "instance_type": "t1.micro", 131 "ssh_username": "ubuntu", 132 "ami_name": "packer-quick-start {{timestamp}}", 133 } 134 </pre> 135 136 <div class="alert alert-block alert-info"> 137 <strong>Note:</strong> Packer can also read the access key and secret 138 access key from environmental variables. See the configuration reference in 139 the section above for more information on what environmental variables Packer 140 will look for. 141 </div> 142 143 ## AMI Block Device Mappings Example 144 145 Here is an example using the optional AMI block device mappings. This will add 146 the /dev/sdb and /dev/sdc block device mappings to the finished AMI. 147 148 <pre class="prettyprint"> 149 { 150 "type": "amazon-ebs", 151 "access_key": "YOUR KEY HERE", 152 "secret_key": "YOUR SECRET KEY HERE", 153 "region": "us-east-1", 154 "source_ami": "ami-de0d9eb7", 155 "instance_type": "t1.micro", 156 "ssh_username": "ubuntu", 157 "ami_name": "packer-quick-start {{timestamp}}", 158 "ami_block_device_mappings": [ 159 { 160 "device_name": "/dev/sdb", 161 "virtual_name": "ephemeral0" 162 }, 163 { 164 "device_name": "/dev/sdc", 165 "virtual_name": "ephemeral1" 166 } 167 ] 168 } 169 </pre> 170 171 ## Tag Example 172 173 Here is an example using the optional AMI tags. This will add the tags 174 "OS_Version" and "Release" to the finished AMI. 175 176 <pre class="prettyprint"> 177 { 178 "type": "amazon-ebs", 179 "access_key": "YOUR KEY HERE", 180 "secret_key": "YOUR SECRET KEY HERE", 181 "region": "us-east-1", 182 "source_ami": "ami-de0d9eb7", 183 "instance_type": "t1.micro", 184 "ssh_username": "ubuntu", 185 "ami_name": "packer-quick-start {{timestamp}}", 186 "tags": { 187 "OS_Version": "Ubuntu", 188 "Release": "Latest" 189 } 190 } 191 </pre>