github.com/daniellockard/packer@v0.7.6-0.20141210173435-5a9390934716/website/source/docs/builders/amazon-ebs.html.markdown (about)

     1  ---
     2  layout: "docs"
     3  page_title: "Amazon AMI Builder (EBS backed)"
     4  description: |-
     5    The `amazon-ebs` Packer builder is able to create Amazon AMIs backed by EBS volumes for use in EC2. For more information on the difference betwen EBS-backed instances and instance-store backed instances, see the storage for the root device section in the EC2 documentation.
     6  ---
     7  
     8  # AMI Builder (EBS backed)
     9  
    10  Type: `amazon-ebs`
    11  
    12  The `amazon-ebs` Packer builder is able to create Amazon AMIs backed by EBS
    13  volumes for use in [EC2](http://aws.amazon.com/ec2/). For more information
    14  on the difference betwen EBS-backed instances and instance-store backed
    15  instances, see the
    16  ["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).
    17  
    18  This builder builds an AMI by launching an EC2 instance from a source AMI,
    19  provisioning that running machine, and then creating an AMI from that machine.
    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
    22  the instance while the image is being created. This simplifies configuration
    23  quite a bit.
    24  
    25  The builder does _not_ manage AMIs. Once it creates an AMI and stores it
    26  in your account, it is up to you to use, delete, etc. the AMI.
    27  
    28  ## Configuration Reference
    29  
    30  There are many configuration options available for the builder. They are
    31  segmented below into two categories: required and optional parameters. Within
    32  each category, the available configuration keys are alphabetized.
    33  
    34  ### Required:
    35  
    36  * `access_key` (string) - The access key used to communicate with AWS.
    37    If not specified, Packer will use the environment variables
    38    `AWS_ACCESS_KEY_ID` or `AWS_ACCESS_KEY` (in that order), if set.
    39  
    40  * `ami_name` (string) - The name of the resulting AMI that will appear
    41    when managing AMIs in the AWS console or via APIs. This must be unique.
    42    To help make this unique, use a function like `timestamp` (see
    43    [configuration templates](/docs/templates/configuration-templates.html) for more info)
    44  
    45  * `instance_type` (string) - The EC2 instance type to use while building
    46    the AMI, such as "m1.small".
    47  
    48  * `region` (string) - The name of the region, such as "us-east-1", in which
    49    to launch the EC2 instance to create the AMI.
    50  
    51  * `secret_key` (string) - The secret key used to communicate with AWS.
    52    If not specified, Packer will use the environment variables
    53    `AWS_SECRET_ACCESS_KEY` or `AWS_SECRET_KEY` (in that order), if set.
    54  
    55  * `source_ami` (string) - The initial AMI used as a base for the newly
    56    created machine.
    57  
    58  * `ssh_username` (string) - The username to use in order to communicate
    59    over SSH to the running machine.
    60  
    61  ### Optional:
    62  
    63  * `ami_block_device_mappings` (array of block device mappings) - Add the block
    64    device mappings to the AMI. The block device mappings allow for keys:
    65    "device\_name" (string), "virtual\_name" (string), "snapshot\_id" (string),
    66    "volume\_type" (string), "volume\_size" (integer), "delete\_on\_termination"
    67    (boolean), "encrypted" (boolean), "no\_device" (boolean), and "iops"
    68    (integer).
    69  
    70  * `ami_description` (string) - The description to set for the resulting
    71    AMI(s). By default this description is empty.
    72  
    73  * `ami_groups` (array of strings) - A list of groups that have access
    74    to launch the resulting AMI(s). By default no groups have permission
    75    to launch the AMI. `all` will make the AMI publicly accessible.
    76  
    77  * `ami_product_codes` (array of strings) - A list of product codes to
    78    associate with the AMI. By default no product codes are associated with
    79    the AMI.
    80  
    81  * `ami_regions` (array of strings) - A list of regions to copy the AMI to.
    82    Tags and attributes are copied along with the AMI. AMI copying takes time
    83    depending on the size of the AMI, but will generally take many minutes.
    84  
    85  * `ami_users` (array of strings) - A list of account IDs that have access
    86    to launch the resulting AMI(s). By default no additional users other than the user
    87    creating the AMI has permissions to launch it.
    88  
    89  * `associate_public_ip_address` (boolean) - If using a non-default VPC, public
    90    IP addresses are not provided by default. If this is toggled, your new
    91    instance will get a Public IP.
    92  
    93  * `availability_zone` (string) - Destination availability zone to launch instance in.
    94    Leave this empty to allow Amazon to auto-assign.
    95  
    96  * `enhanced_networking` (boolean) - Enable enhanced networking (SriovNetSupport) on
    97    HVM-compatible AMIs.
    98  
    99  * `iam_instance_profile` (string) - The name of an
   100    [IAM instance profile](http://docs.aws.amazon.com/IAM/latest/UserGuide/instance-profiles.html)
   101    to launch the EC2 instance with.
   102  
   103  * `launch_block_device_mappings` (array of block device mappings) - Add the
   104    block device mappings to the launch instance. The block device mappings are
   105    the same as `ami_block_device_mappings` above.
   106  
   107  * `run_tags` (object of key/value strings) - Tags to apply to the instance
   108    that is _launched_ to create the AMI. These tags are _not_ applied to
   109    the resulting AMI unless they're duplicated in `tags`.
   110  
   111  * `security_group_id` (string) - The ID (_not_ the name) of the security
   112    group to assign to the instance. By default this is not set and Packer
   113    will automatically create a new temporary security group to allow SSH
   114    access. Note that if this is specified, you must be sure the security
   115    group allows access to the `ssh_port` given below.
   116  
   117  * `security_group_ids` (array of strings) - A list of security groups as
   118    described above. Note that if this is specified, you must omit the
   119    `security_group_id`.
   120  
   121  * `spot_price` (string) - The maximum hourly price to launch a spot instance
   122    to create the AMI. It is a type of instances that EC2 starts when the maximum
   123    price that you specify exceeds the current spot price. Spot price will be
   124    updated based on available spot instance capacity and current spot Instance
   125    requests. It may save you some costs. You can set this to "auto" for
   126    Packer to automatically discover the best spot price.
   127  
   128  * `spot_price_auto_product` (string) - Required if `spot_price` is set to
   129    "auto". This tells Packer what sort of AMI you're launching to find the best
   130     spot price. This must be one of: `Linux/UNIX`, `SUSE Linux`, `Windows`,
   131     `Linux/UNIX (Amazon VPC)`, `SUSE Linux (Amazon VPC)`, `Windows (Amazon VPC)`
   132  
   133  * `ssh_port` (integer) - The port that SSH will be available on. This defaults
   134    to port 22.
   135  
   136  * `ssh_private_key_file` (string) - Use this ssh private key file instead of
   137    a generated ssh key pair for connecting to the instance.
   138  
   139  * `ssh_private_ip` (bool) - If true, then SSH will always use the private
   140    IP if available.
   141  
   142  * `ssh_timeout` (string) - The time to wait for SSH to become available
   143    before timing out. The format of this value is a duration such as "5s"
   144    or "5m". The default SSH timeout is "5m", or five minutes.
   145  
   146  * `subnet_id` (string) - If using VPC, the ID of the subnet, such as
   147    "subnet-12345def", where Packer will launch the EC2 instance.
   148  
   149  * `tags` (object of key/value strings) - Tags applied to the AMI.
   150  
   151  * `temporary_key_pair_name` (string) - The name of the temporary keypair
   152    to generate. By default, Packer generates a name with a UUID.
   153  
   154  * `token` (string) - The access token to use. This is different from
   155    the access key and secret key. If you're not sure what this is, then you
   156    probably don't need it. This will also be read from the `AWS_SECURITY_TOKEN`
   157    environmental variable.
   158  
   159  * `user_data` (string) - User data to apply when launching the instance.
   160    Note that you need to be careful about escaping characters due to the
   161    templates being JSON. It is often more convenient to use `user_data_file`,
   162    instead.
   163  
   164  * `user_data_file` (string) - Path to a file that will be used for the
   165    user data when launching the instance.
   166  
   167  * `vpc_id` (string) - If launching into a VPC subnet, Packer needs the
   168    VPC ID in order to create a temporary security group within the VPC.
   169  
   170  ## Basic Example
   171  
   172  Here is a basic example. It is completely valid except for the access keys:
   173  
   174  ```javascript
   175  {
   176    "type": "amazon-ebs",
   177    "access_key": "YOUR KEY HERE",
   178    "secret_key": "YOUR SECRET KEY HERE",
   179    "region": "us-east-1",
   180    "source_ami": "ami-de0d9eb7",
   181    "instance_type": "t1.micro",
   182    "ssh_username": "ubuntu",
   183    "ami_name": "packer-quick-start {{timestamp}}"
   184  }
   185  ```
   186  
   187  -> **Note:** Packer can also read the access key and secret
   188  access key from environmental variables. See the configuration reference in
   189  the section above for more information on what environmental variables Packer
   190  will look for.
   191  
   192  ## Accessing the Instance to Debug
   193  
   194  If you need to access the instance to debug for some reason, run the builder
   195  with the `-debug` flag. In debug mode, the Amazon builder will save the
   196  private key in the current directory and will output the DNS or IP information
   197  as well. You can use this information to access the instance as it is
   198  running.
   199  
   200  ## AMI Block Device Mappings Example
   201  
   202  Here is an example using the optional AMI block device mappings. This will add
   203  the /dev/sdb and /dev/sdc block device mappings to the finished AMI.
   204  
   205  ```javascript
   206  {
   207    "type": "amazon-ebs",
   208    "access_key": "YOUR KEY HERE",
   209    "secret_key": "YOUR SECRET KEY HERE",
   210    "region": "us-east-1",
   211    "source_ami": "ami-de0d9eb7",
   212    "instance_type": "t1.micro",
   213    "ssh_username": "ubuntu",
   214    "ami_name": "packer-quick-start {{timestamp}}",
   215    "ami_block_device_mappings": [
   216      {
   217        "device_name": "/dev/sdb",
   218        "virtual_name": "ephemeral0"
   219      },
   220      {
   221        "device_name": "/dev/sdc",
   222        "virtual_name": "ephemeral1"
   223      }
   224    ]
   225  }
   226  ```
   227  
   228  ## Tag Example
   229  
   230  Here is an example using the optional AMI tags. This will add the tags
   231  "OS_Version" and "Release" to the finished AMI.
   232  
   233  ```javascript
   234  {
   235    "type": "amazon-ebs",
   236    "access_key": "YOUR KEY HERE",
   237    "secret_key": "YOUR SECRET KEY HERE",
   238    "region": "us-east-1",
   239    "source_ami": "ami-de0d9eb7",
   240    "instance_type": "t1.micro",
   241    "ssh_username": "ubuntu",
   242    "ami_name": "packer-quick-start {{timestamp}}",
   243    "tags": {
   244      "OS_Version": "Ubuntu",
   245      "Release": "Latest"
   246    }
   247  }
   248  ```