github.com/homburg/packer@v0.6.1-0.20140528012651-1dcaf1716848/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 use the environment variables
    36    `AWS_ACCESS_KEY_ID` or `AWS_ACCESS_KEY` (in that order), if set.
    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 use the environment variables
    51    `AWS_SECRET_ACCESS_KEY` or `AWS_SECRET_KEY` (in that order), if set.
    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" (integer), "delete\_on\_termination"
    65    (boolean), "encrypted" (boolean), "no\_device" (boolean), and "iops"
    66    (integer).
    67  
    68  * `ami_description` (string) - The description to set for the resulting
    69    AMI(s). By default this description is empty.
    70  
    71  * `ami_groups` (array of strings) - A list of groups that have access
    72    to launch the resulting AMI(s). By default no groups have permission
    73    to launch the AMI. `all` will make the AMI publicly accessible.
    74  
    75  * `ami_product_codes` (array of strings) - A list of product codes to
    76    associate with the AMI. By default no product codes are associated with
    77    the AMI.
    78  
    79  * `ami_regions` (array of strings) - A list of regions to copy the AMI to.
    80    Tags and attributes are copied along with the AMI. AMI copying takes time
    81    depending on the size of the AMI, but will generally take many minutes.
    82  
    83  * `ami_users` (array of strings) - A list of account IDs that have access
    84    to launch the resulting AMI(s). By default no additional users other than the user
    85    creating the AMI has permissions to launch it.
    86  
    87  * `ami_virtualization_type` (string) - The type of virtualization for the AMI
    88    you are building. This option is required to register HVM images. Can be
    89    "paravirtual" (default) or "hvm".
    90  
    91  * `associate_public_ip_address` (boolean) - If using a non-default VPC, public
    92    IP addresses are not provided by default. If this is toggled, your new
    93    instance will get a Public IP.
    94  
    95  * `availability_zone` (string) - Destination availability zone to launch instance in.
    96    Leave this empty to allow Amazon to auto-assign.
    97  
    98  * `iam_instance_profile` (string) - The name of an
    99    [IAM instance profile](http://docs.aws.amazon.com/IAM/latest/UserGuide/instance-profiles.html)
   100    to launch the EC2 instance with.
   101  
   102  * `launch_block_device_mappings` (array of block device mappings) - Add the
   103    block device mappings to the launch instance. The block device mappings are
   104    the same as `ami_block_device_mappings` above.
   105  
   106  * `run_tags` (object of key/value strings) - Tags to apply to the instance
   107    that is _launched_ to create the AMI. These tags are _not_ applied to
   108    the resulting AMI unless they're duplicated in `tags`.
   109  
   110  * `security_group_id` (string) - The ID (_not_ the name) of the security
   111    group to assign to the instance. By default this is not set and Packer
   112    will automatically create a new temporary security group to allow SSH
   113    access. Note that if this is specified, you must be sure the security
   114    group allows access to the `ssh_port` given below.
   115  
   116  * `security_group_ids` (array of strings) - A list of security groups as
   117    described above. Note that if this is specified, you must omit the
   118    security_group_id.
   119  
   120  * `ssh_port` (integer) - The port that SSH will be available on. This defaults
   121    to port 22.
   122  
   123  * `ssh_private_key_file` (string) - Use this ssh private key file instead of
   124    a generated ssh key pair for connecting to the instance.
   125  
   126  * `ssh_timeout` (string) - The time to wait for SSH to become available
   127    before timing out. The format of this value is a duration such as "5s"
   128    or "5m". The default SSH timeout is "5m", or five minutes.
   129  
   130  * `subnet_id` (string) - If using VPC, the ID of the subnet, such as
   131    "subnet-12345def", where Packer will launch the EC2 instance.
   132  
   133  * `tags` (object of key/value strings) - Tags applied to the AMI.
   134  
   135  * `temporary_key_pair_name` (string) - The name of the temporary keypair
   136    to generate. By default, Packer generates a name with a UUID.
   137  
   138  * `user_data` (string) - User data to apply when launching the instance.
   139    Note that you need to be careful about escaping characters due to the
   140    templates being JSON. It is often more convenient to use `user_data_file`,
   141    instead.
   142  
   143  * `user_data_file` (string) - Path to a file that will be used for the
   144    user data when launching the instance.
   145  
   146  * `vpc_id` (string) - If launching into a VPC subnet, Packer needs the
   147    VPC ID in order to create a temporary security group within the VPC.
   148  
   149  ## Basic Example
   150  
   151  Here is a basic example. It is completely valid except for the access keys:
   152  
   153  <pre class="prettyprint">
   154  {
   155    "type": "amazon-ebs",
   156    "access_key": "YOUR KEY HERE",
   157    "secret_key": "YOUR SECRET KEY HERE",
   158    "region": "us-east-1",
   159    "source_ami": "ami-de0d9eb7",
   160    "instance_type": "t1.micro",
   161    "ssh_username": "ubuntu",
   162    "ami_name": "packer-quick-start {{timestamp}}"
   163  }
   164  </pre>
   165  
   166  <div class="alert alert-block alert-info">
   167  <strong>Note:</strong> Packer can also read the access key and secret
   168  access key from environmental variables. See the configuration reference in
   169  the section above for more information on what environmental variables Packer
   170  will look for.
   171  </div>
   172  
   173  ## Accessing the Instance to Debug
   174  
   175  If you need to access the instance to debug for some reason, run the builder
   176  with the `-debug` flag. In debug mode, the Amazon builder will save the
   177  private key in the current directory and will output the DNS or IP information
   178  as well. You can use this information to access the instance as it is
   179  running.
   180  
   181  ## AMI Block Device Mappings Example
   182  
   183  Here is an example using the optional AMI block device mappings. This will add
   184  the /dev/sdb and /dev/sdc block device mappings to the finished AMI.
   185  
   186  <pre class="prettyprint">
   187  {
   188    "type": "amazon-ebs",
   189    "access_key": "YOUR KEY HERE",
   190    "secret_key": "YOUR SECRET KEY HERE",
   191    "region": "us-east-1",
   192    "source_ami": "ami-de0d9eb7",
   193    "instance_type": "t1.micro",
   194    "ssh_username": "ubuntu",
   195    "ami_name": "packer-quick-start {{timestamp}}",
   196    "ami_block_device_mappings": [
   197        {
   198            "device_name": "/dev/sdb",
   199            "virtual_name": "ephemeral0"
   200        },
   201        {
   202            "device_name": "/dev/sdc",
   203            "virtual_name": "ephemeral1"
   204        }
   205    ]
   206  }
   207  </pre>
   208  
   209  ## Tag Example
   210  
   211  Here is an example using the optional AMI tags. This will add the tags
   212  "OS_Version" and "Release" to the finished AMI.
   213  
   214  <pre class="prettyprint">
   215  {
   216    "type": "amazon-ebs",
   217    "access_key": "YOUR KEY HERE",
   218    "secret_key": "YOUR SECRET KEY HERE",
   219    "region": "us-east-1",
   220    "source_ami": "ami-de0d9eb7",
   221    "instance_type": "t1.micro",
   222    "ssh_username": "ubuntu",
   223    "ami_name": "packer-quick-start {{timestamp}}",
   224    "tags": {
   225      "OS_Version": "Ubuntu",
   226      "Release": "Latest"
   227    }
   228  }
   229  </pre>