github.com/jerryclinesmith/packer@v0.3.7/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"
    65    (bool), "no\_device" (bool), 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_regions` (array of string) - A list of regions to copy the AMI to.
    79    Tags and attributes are copied along with the AMI. AMI copying takes time
    80    depending on the size of the AMI, but will generally take many minutes.
    81  
    82  * `ami_users` (array of string) - A list of account IDs that have access
    83    to launch the resulting AMI(s). By default no additional users other than the user
    84    creating the AMI has permissions to launch it.
    85  
    86  * `iam_instance_profile` (string) - The name of an
    87    [IAM instance profile](http://docs.aws.amazon.com/IAM/latest/UserGuide/instance-profiles.html)
    88    to launch the EC2 instance with.
    89  
    90  * `launch_block_device_mappings` (array of block device mappings) - Add the
    91    block device mappings to the launch instance. The block device mappings are
    92    the same as `ami_block_device_mappings` above.
    93  
    94  * `security_group_id` (string) - The ID (_not_ the name) of the security
    95    group to assign to the instance. By default this is not set and Packer
    96    will automatically create a new temporary security group to allow SSH
    97    access. Note that if this is specified, you must be sure the security
    98    group allows access to the `ssh_port` given below.
    99  
   100  * `ssh_port` (int) - The port that SSH will be available on. This defaults
   101    to port 22.
   102  
   103  * `ssh_timeout` (string) - The time to wait for SSH to become available
   104    before timing out. The format of this value is a duration such as "5s"
   105    or "5m". The default SSH timeout is "1m", or one minute.
   106  
   107  * `subnet_id` (string) - If using VPC, the ID of the subnet, such as
   108    "subnet-12345def", where Packer will launch the EC2 instance.
   109  
   110  * `tags` (object of key/value strings) - Tags applied to the AMI.
   111  
   112  * `user_data` (string) - User data to apply when launching the instance.
   113    Note that you need to be careful about escaping characters due to the
   114    templates being JSON. It is often more convenient to use `user_data_file`,
   115    instead.
   116  
   117  * `user_data_file` (string) - Path to a file that will be used for the
   118    user data when launching the instance.
   119  
   120  * `vpc_id` (string) - If launching into a VPC subnet, Packer needs the
   121    VPC ID in order to create a temporary security group within the VPC.
   122  
   123  ## Basic Example
   124  
   125  Here is a basic example. It is completely valid except for the access keys:
   126  
   127  <pre class="prettyprint">
   128  {
   129    "type": "amazon-ebs",
   130    "access_key": "YOUR KEY HERE",
   131    "secret_key": "YOUR SECRET KEY HERE",
   132    "region": "us-east-1",
   133    "source_ami": "ami-de0d9eb7",
   134    "instance_type": "t1.micro",
   135    "ssh_username": "ubuntu",
   136    "ami_name": "packer-quick-start {{timestamp}}",
   137  }
   138  </pre>
   139  
   140  <div class="alert alert-block alert-info">
   141  <strong>Note:</strong> Packer can also read the access key and secret
   142  access key from environmental variables. See the configuration reference in
   143  the section above for more information on what environmental variables Packer
   144  will look for.
   145  </div>
   146  
   147  ## Accessing the Instance to Debug
   148  
   149  If you need to access the instance to debug for some reason, run the builder
   150  with the `-debug` flag. In debug mode, the Amazon builder will save the
   151  private key in the current directory and will output the DNS or IP information
   152  as well. You can use this information to access the instance as it is
   153  running.
   154  
   155  ## AMI Block Device Mappings Example
   156  
   157  Here is an example using the optional AMI block device mappings. This will add
   158  the /dev/sdb and /dev/sdc block device mappings to the finished AMI.
   159  
   160  <pre class="prettyprint">
   161  {
   162    "type": "amazon-ebs",
   163    "access_key": "YOUR KEY HERE",
   164    "secret_key": "YOUR SECRET KEY HERE",
   165    "region": "us-east-1",
   166    "source_ami": "ami-de0d9eb7",
   167    "instance_type": "t1.micro",
   168    "ssh_username": "ubuntu",
   169    "ami_name": "packer-quick-start {{timestamp}}",
   170    "ami_block_device_mappings": [
   171        {
   172            "device_name": "/dev/sdb",
   173            "virtual_name": "ephemeral0"
   174        },
   175        {
   176            "device_name": "/dev/sdc",
   177            "virtual_name": "ephemeral1"
   178        }
   179    ]
   180  }
   181  </pre>
   182  
   183  ## Tag Example
   184  
   185  Here is an example using the optional AMI tags. This will add the tags
   186  "OS_Version" and "Release" to the finished AMI.
   187  
   188  <pre class="prettyprint">
   189  {
   190    "type": "amazon-ebs",
   191    "access_key": "YOUR KEY HERE",
   192    "secret_key": "YOUR SECRET KEY HERE",
   193    "region": "us-east-1",
   194    "source_ami": "ami-de0d9eb7",
   195    "instance_type": "t1.micro",
   196    "ssh_username": "ubuntu",
   197    "ami_name": "packer-quick-start {{timestamp}}",
   198    "tags": {
   199      "OS_Version": "Ubuntu",
   200      "Release": "Latest"
   201    }
   202  }
   203  </pre>