github.com/StackPointCloud/packer@v0.10.2-0.20180716202532-b28098e0f79b/website/source/docs/builders/amazon-instance.html.md (about)

     1  ---
     2  description: |
     3      The amazon-instance Packer builder is able to create Amazon AMIs backed by
     4      instance storage as the root device. For more information on the difference
     5      between instance storage and EBS-backed instances, see the storage for the
     6      root device section in the EC2 documentation.
     7  layout: docs
     8  page_title: 'Amazon instance-store - Builders'
     9  sidebar_current: 'docs-builders-amazon-instance'
    10  ---
    11  
    12  # AMI Builder (instance-store)
    13  
    14  Type: `amazon-instance`
    15  
    16  The `amazon-instance` Packer builder is able to create Amazon AMIs backed by
    17  instance storage as the root device. For more information on the difference
    18  between instance storage and EBS-backed instances, see the ["storage for the
    19  root device" section in the EC2
    20  documentation](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ComponentsAMIs.html#storage-for-the-root-device).
    21  
    22  This builder builds an AMI by launching an EC2 instance from an existing
    23  instance-storage backed AMI, provisioning that running machine, and then
    24  bundling and creating a new AMI from that machine. This is all done in your own
    25  AWS account. The builder will create temporary key pairs, security group rules,
    26  etc. that provide it temporary access to the instance while the image is being
    27  created. This simplifies configuration quite a bit.
    28  
    29  The builder does *not* manage AMIs. Once it creates an AMI and stores it in
    30  your account, it is up to you to use, delete, etc. the AMI.
    31  
    32  -> **Note:** Temporary resources are, by default, all created with the prefix
    33  `packer`. This can be useful if you want to restrict the security groups and
    34  key pairs packer is able to operate on.
    35  
    36  -> **Note:** This builder requires that the [Amazon EC2 AMI
    37  Tools](https://aws.amazon.com/developertools/368) are installed onto the
    38  machine. This can be done within a provisioner, but must be done before the
    39  builder finishes running.
    40  
    41  ~> Instance builds are not supported for Windows. Use [`amazon-ebs`](amazon-ebs.html) instead.
    42  
    43  ## Configuration Reference
    44  
    45  There are many configuration options available for the builder. They are
    46  segmented below into two categories: required and optional parameters. Within
    47  each category, the available configuration keys are alphabetized.
    48  
    49  In addition to the options listed here, a
    50  [communicator](/docs/templates/communicator.html) can be configured for this
    51  builder.
    52  
    53  ### Required:
    54  
    55  -   `access_key` (string) - The access key used to communicate with AWS. [Learn
    56      how to set this.](/docs/builders/amazon.html#specifying-amazon-credentials)
    57  
    58  -   `account_id` (string) - Your AWS account ID. This is required for bundling
    59      the AMI. This is *not the same* as the access key. You can find your account
    60      ID in the security credentials page of your AWS account.
    61  
    62  -   `ami_name` (string) - The name of the resulting AMI that will appear when
    63      managing AMIs in the AWS console or via APIs. This must be unique. To help
    64      make this unique, use a function like `timestamp` (see [configuration
    65      templates](/docs/templates/engine.html) for more info)
    66  
    67  -   `instance_type` (string) - The EC2 instance type to use while building the
    68      AMI, such as `m1.small`.
    69  
    70  -   `region` (string) - The name of the region, such as `us-east-1`, in which to
    71      launch the EC2 instance to create the AMI.
    72  
    73  -   `s3_bucket` (string) - The name of the S3 bucket to upload the AMI. This
    74      bucket will be created if it doesn't exist.
    75  
    76  -   `secret_key` (string) - The secret key used to communicate with AWS. [Learn
    77      how to set this.](/docs/builders/amazon.html#specifying-amazon-credentials)
    78  
    79  -   `source_ami` (string) - The initial AMI used as a base for the newly
    80      created machine.
    81  
    82  -   `x509_cert_path` (string) - The local path to a valid X509 certificate for
    83      your AWS account. This is used for bundling the AMI. This X509 certificate
    84      must be registered with your account from the security credentials page in
    85      the AWS console.
    86  
    87  -   `x509_key_path` (string) - The local path to the private key for the X509
    88      certificate specified by `x509_cert_path`. This is used for bundling
    89      the AMI.
    90  
    91  ### Optional:
    92  
    93  -   `ami_block_device_mappings` (array of block device mappings) - Add one or
    94      more [block device mappings](http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/block-device-mapping-concepts.html)
    95      to the AMI. These will be attached when booting a new instance from your
    96      AMI. To add a block device during the Packer build see
    97      `launch_block_device_mappings` below. Your options here may vary depending
    98      on the type of VM you use. The block device mappings allow for the following
    99      configuration:
   100  
   101      -   `delete_on_termination` (boolean) - Indicates whether the EBS volume is
   102          deleted on instance termination. Default `false`. **NOTE**: If this
   103          value is not explicitly set to `true` and volumes are not cleaned up by
   104          an alternative method, additional volumes will accumulate after
   105          every build.
   106  
   107      -   `device_name` (string) - The device name exposed to the instance (for
   108          example, `/dev/sdh` or `xvdh`). Required when specifying `volume_size`.
   109  
   110      -   `encrypted` (boolean) - Indicates whether to encrypt the volume or not
   111  
   112      -   `iops` (number) - The number of I/O operations per second (IOPS) that the
   113          volume supports. See the documentation on
   114          [IOPs](https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_EbsBlockDevice.html)
   115          for more information
   116  
   117      -   `no_device` (boolean) - Suppresses the specified device included in the
   118          block device mapping of the AMI
   119  
   120      -   `snapshot_id` (string) - The ID of the snapshot
   121  
   122      -   `virtual_name` (string) - The virtual device name. See the documentation on
   123          [Block Device
   124          Mapping](https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_BlockDeviceMapping.html)
   125          for more information
   126  
   127      -   `volume_size` (number) - The size of the volume, in GiB. Required if not
   128          specifying a `snapshot_id`
   129  
   130      -   `volume_type` (string) - The volume type. `gp2` for General Purpose (SSD)
   131          volumes, `io1` for Provisioned IOPS (SSD) volumes, and `standard` for Magnetic
   132          volumes
   133  
   134  -   `ami_description` (string) - The description to set for the
   135      resulting AMI(s). By default this description is empty. This is a
   136      [template engine](/docs/templates/engine.html),
   137      see [Build template data](#build-template-data) for more information.
   138  
   139  -   `ami_groups` (array of strings) - A list of groups that have access to
   140      launch the resulting AMI(s). By default no groups have permission to launch
   141      the AMI. `all` will make the AMI publicly accessible. AWS currently doesn't
   142      accept any value other than `all`.
   143  
   144  -   `ami_product_codes` (array of strings) - A list of product codes to
   145      associate with the AMI. By default no product codes are associated with
   146      the AMI.
   147  
   148  -   `ami_regions` (array of strings) - A list of regions to copy the AMI to.
   149      Tags and attributes are copied along with the AMI. AMI copying takes time
   150      depending on the size of the AMI, but will generally take many minutes.
   151  
   152  -   `ami_users` (array of strings) - A list of account IDs that have access to
   153      launch the resulting AMI(s). By default no additional users other than the
   154      user creating the AMI has permissions to launch it.
   155  
   156  -   `ami_virtualization_type` (string) - The type of virtualization for the AMI
   157      you are building. This option is required to register HVM images. Can be
   158      `paravirtual` (default) or `hvm`.
   159  
   160  -   `associate_public_ip_address` (boolean) - If using a non-default VPC, public
   161      IP addresses are not provided by default. If this is toggled, your new
   162      instance will get a Public IP.
   163  
   164  -   `availability_zone` (string) - Destination availability zone to launch
   165      instance in. Leave this empty to allow Amazon to auto-assign.
   166  
   167  -   `bundle_destination` (string) - The directory on the running instance where
   168      the bundled AMI will be saved prior to uploading. By default this is `/tmp`.
   169      This directory must exist and be writable.
   170  
   171  -   `bundle_prefix` (string) - The prefix for files created from bundling the
   172      root volume. By default this is `image-{{timestamp}}`. The `timestamp`
   173      variable should be used to make sure this is unique, otherwise it can
   174      collide with other created AMIs by Packer in your account.
   175  
   176  -   `bundle_upload_command` (string) - The command to use to upload the
   177      bundled volume. See the "custom bundle commands" section below for
   178      more information.
   179  
   180  -   `bundle_vol_command` (string) - The command to use to bundle the volume. See
   181      the "custom bundle commands" section below for more information.
   182  
   183  -   `custom_endpoint_ec2` (string) - This option is useful if you use a cloud
   184      provider whose API is compatible with aws EC2. Specify another endpoint
   185      like this `https://ec2.custom.endpoint.com`.
   186  
   187  -   `ebs_optimized` (boolean) - Mark instance as [EBS
   188      Optimized](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/EBSOptimized.html).
   189      Default `false`.
   190  
   191  -   `ena_support` (boolean) - Enable enhanced networking (ENA but not SriovNetSupport)
   192      on HVM-compatible AMIs. If true, add `ec2:ModifyInstanceAttribute` to your AWS IAM policy.
   193      Note: you must make sure enhanced networking is enabled on your instance. See [Amazon's
   194      documentation on enabling enhanced networking](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/enhanced-networking.html#enabling_enhanced_networking). Default `false`.
   195  
   196  -   `enable_t2_unlimited` (boolean) - Enabling T2 Unlimited allows the source
   197      instance to burst additional CPU beyond its available [CPU Credits]
   198      (https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/t2-credits-baseline-concepts.html)
   199      for as long as the demand exists.
   200      This is in contrast to the standard configuration that only allows an
   201      instance to consume up to its available CPU Credits.
   202      See the AWS documentation for [T2 Unlimited]
   203      (https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/t2-unlimited.html)
   204      and the 'T2 Unlimited Pricing' section of the [Amazon EC2 On-Demand
   205      Pricing](https://aws.amazon.com/ec2/pricing/on-demand/) document for more
   206      information.
   207      By default this option is disabled and Packer will set up a [T2
   208      Standard](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/t2-std.html)
   209      instance instead.
   210  
   211      To use T2 Unlimited you must use a T2 instance type e.g. t2.micro.
   212      Additionally, T2 Unlimited cannot be used in conjunction with Spot
   213      Instances e.g. when the `spot_price` option has been configured.
   214      Attempting to do so will cause an error.
   215  
   216      !> **Warning!** Additional costs may be incurred by enabling T2
   217      Unlimited - even for instances that would usually qualify for the
   218      [AWS Free Tier](https://aws.amazon.com/free/).
   219  
   220  -   `force_deregister` (boolean) - Force Packer to first deregister an existing
   221      AMI if one with the same name already exists. Defaults to `false`.
   222  
   223  -   `force_delete_snapshot` (boolean) - Force Packer to delete snapshots associated with
   224      AMIs, which have been deregistered by `force_deregister`. Defaults to `false`.
   225  
   226  -   `iam_instance_profile` (string) - The name of an [IAM instance
   227      profile](https://docs.aws.amazon.com/IAM/latest/UserGuide/instance-profiles.html)
   228      to launch the EC2 instance with.
   229  
   230  -   `launch_block_device_mappings` (array of block device mappings) - Add one
   231      or more block devices before the Packer build starts. If you add instance
   232      store volumes or EBS volumes in addition to the root device volume, the
   233      created AMI will contain block device mapping information for those
   234      volumes. Amazon creates snapshots of the source instance's root volume and
   235      any other EBS volumes described here. When you launch an instance from this
   236      new AMI, the instance automatically launches with these additional volumes,
   237      and will restore them from snapshots taken from the source instance.
   238  
   239  -   `mfa_code` (string) - The MFA [TOTP](https://en.wikipedia.org/wiki/Time-based_One-time_Password_Algorithm)
   240      code. This should probably be a user variable since it changes all the time.
   241  
   242  -   `profile` (string) - The profile to use in the shared credentials file for
   243      AWS. See Amazon's documentation on [specifying
   244      profiles](https://docs.aws.amazon.com/sdk-for-go/v1/developer-guide/configuring-sdk.html#specifying-profiles)
   245      for more details.
   246  
   247  -   `region_kms_key_ids` (map of strings) - a map of regions to copy the ami to,
   248      along with the custom kms key id to use for encryption for that region.
   249      Keys must match the regions provided in `ami_regions`. If you just want to
   250      encrypt using a default ID, you can stick with `kms_key_id` and `ami_regions`.
   251      If you want a region to be encrypted with that region's default key ID, you can
   252      use an empty string `""` instead of a key id in this map. (e.g. `"us-east-1": ""`)
   253      However, you cannot use default key IDs if you are using this in conjunction with
   254      `snapshot_users` -- in that situation you must use custom keys.
   255  
   256  -   `run_tags` (object of key/value strings) - Tags to apply to the instance
   257      that is *launched* to create the AMI. These tags are *not* applied to the
   258      resulting AMI unless they're duplicated in `tags`. This is a
   259      [template engine](/docs/templates/engine.html),
   260      see [Build template data](#build-template-data) for more information.
   261  
   262  -   `security_group_id` (string) - The ID (*not* the name) of the security group
   263      to assign to the instance. By default this is not set and Packer will
   264      automatically create a new temporary security group to allow SSH access.
   265      Note that if this is specified, you must be sure the security group allows
   266      access to the `ssh_port` given below.
   267  
   268  -   `security_group_ids` (array of strings) - A list of security groups as
   269      described above. Note that if this is specified, you must omit the
   270      `security_group_id`.
   271  
   272  -   `temporary_security_group_source_cidr` (string) - An IPv4 CIDR block to be authorized
   273      access to the instance, when packer is creating a temporary security group.
   274      The default is `0.0.0.0/0` (ie, allow any IPv4 source). This is only used
   275      when `security_group_id` or `security_group_ids` is not specified.
   276  
   277  -   `skip_region_validation` (boolean) - Set to true if you want to skip
   278      validation of the region configuration option. Defaults to `false`.
   279  
   280  -   `snapshot_groups` (array of strings) - A list of groups that have access to
   281      create volumes from the snapshot(s). By default no groups have permission to create
   282      volumes form the snapshot(s). `all` will make the snapshot publicly accessible.
   283  
   284  -   `snapshot_users` (array of strings) - A list of account IDs that have access to
   285      create volumes from the snapshot(s). By default no additional users other than the
   286      user creating the AMI has permissions to create volumes from the backing snapshot(s).
   287  
   288  -   `source_ami_filter` (object) - Filters used to populate the `source_ami` field.
   289      Example:
   290  
   291      ``` json
   292      {
   293        "source_ami_filter": {
   294          "filters": {
   295            "virtualization-type": "hvm",
   296            "name": "ubuntu/images/*ubuntu-xenial-16.04-amd64-server-*",
   297            "root-device-type": "ebs"
   298          },
   299          "owners": ["099720109477"],
   300          "most_recent": true
   301        }
   302      }
   303      ```
   304  
   305      This selects the most recent Ubuntu 16.04 HVM EBS AMI from Canonical.
   306      NOTE: This will fail unless *exactly* one AMI is returned. In the above
   307      example, `most_recent` will cause this to succeed by selecting the newest image.
   308  
   309      -   `filters` (map of strings) - filters used to select a `source_ami`.
   310          NOTE: This will fail unless *exactly* one AMI is returned.
   311          Any filter described in the docs for [DescribeImages](http://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_DescribeImages.html)
   312          is valid.
   313  
   314      -   `owners` (array of strings) - This scopes the AMIs to certain Amazon account IDs.
   315          This is helpful to limit the AMIs to a trusted third party, or to your own account.
   316  
   317      -   `most_recent` (boolean) - Selects the newest created image when true.
   318          This is most useful for selecting a daily distro build.
   319  
   320      You may set this in place of `source_ami` or in conjunction with it. If you
   321      set this in conjunction with `source_ami`, the `source_ami` will be added to
   322      the filter. The provided `source_ami` must meet all of the filtering criteria
   323      provided in `source_ami_filter`; this pins the AMI returned by the filter,
   324      but will cause Packer to fail if the `source_ami` does not exist.
   325  
   326  -   `snapshot_tags` (object of key/value strings) - Tags to apply to snapshot.
   327      They will override AMI tags if already applied to snapshot.
   328  
   329  -   `spot_price` (string) - The maximum hourly price to launch a spot instance
   330      to create the AMI. It is a type of instances that EC2 starts when the
   331      maximum price that you specify exceeds the current spot price. Spot price
   332      will be updated based on available spot instance capacity and current spot
   333      Instance requests. It may save you some costs. You can set this to `auto`
   334      for Packer to automatically discover the best spot price or to `0` to use
   335      an on-demand instance (default).
   336  
   337  -   `spot_price_auto_product` (string) - Required if `spot_price` is set
   338      to `auto`. This tells Packer what sort of AMI you're launching to find the
   339      best spot price. This must be one of: `Linux/UNIX`, `SUSE Linux`, `Windows`,
   340      `Linux/UNIX (Amazon VPC)`, `SUSE Linux (Amazon VPC)`, `Windows (Amazon VPC)`
   341  
   342  -   `spot_tags` (object of key/value strings) - Requires `spot_price` to
   343      be set. This tells Packer to apply tags to the spot request that is
   344      issued.
   345  
   346  -   `sriov_support` (boolean) - Enable enhanced networking (SriovNetSupport but not ENA)
   347      on HVM-compatible AMIs. If true, add `ec2:ModifyInstanceAttribute` to your AWS IAM
   348      policy. Note: you must make sure enhanced networking is enabled on your instance. See [Amazon's
   349      documentation on enabling enhanced networking](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/enhanced-networking.html#enabling_enhanced_networking).
   350      Default `false`.
   351  
   352  -   `ssh_keypair_name` (string) - If specified, this is the key that will be
   353      used for SSH with the machine. The key must match a key pair name loaded
   354      up into Amazon EC2. By default, this is blank, and Packer will
   355      generate a temporary key pair unless
   356      [`ssh_password`](/docs/templates/communicator.html#ssh_password) is used.
   357      [`ssh_private_key_file`](/docs/templates/communicator.html#ssh_private_key_file)
   358      or `ssh_agent_auth` must be specified when `ssh_keypair_name` is utilized.
   359  
   360  -   `ssh_agent_auth` (boolean) - If true, the local SSH agent will be used to
   361      authenticate connections to the source instance. No temporary key pair will
   362      be created, and the values of `ssh_password` and `ssh_private_key_file` will
   363      be ignored. To use this option with a key pair already configured in the source
   364      AMI, leave the `ssh_keypair_name` blank. To associate an existing key pair
   365      in AWS with the source instance, set the `ssh_keypair_name` field to the name
   366      of the key pair.
   367  
   368  -   `ssh_private_ip` (boolean) - No longer supported. See
   369      [`ssh_interface`](#ssh_interface). A fixer exists to migrate.
   370  
   371  -   `ssh_interface` (string) - One of `public_ip`, `private_ip`,
   372      `public_dns` or `private_dns`. If set, either the public IP address,
   373      private IP address, public DNS name or private DNS name will used as the host for SSH.
   374      The default behaviour if inside a VPC is to use the public IP address if available,
   375      otherwise the private IP address will be used. If not in a VPC the public DNS name
   376      will be used. Also works for WinRM.
   377  
   378      Where Packer is configured for an outbound proxy but WinRM traffic should be direct,
   379      `ssh_interface` must be set to `private_dns` and `<region>.compute.internal` included
   380      in the `NO_PROXY` environment variable.
   381  
   382  -   `subnet_id` (string) - If using VPC, the ID of the subnet, such as
   383      `subnet-12345def`, where Packer will launch the EC2 instance. This field is
   384      required if you are using an non-default VPC.
   385  
   386  -   `tags` (object of key/value strings) - Tags applied to the AMI. This is a
   387      [template engine](/docs/templates/engine.html),
   388      see [Build template data](#build-template-data) for more information.
   389  
   390  -   `temporary_key_pair_name` (string) - The name of the temporary key pair
   391      to generate. By default, Packer generates a name that looks like
   392      `packer_<UUID>`, where &lt;UUID&gt; is a 36 character unique identifier.
   393  
   394  -   `user_data` (string) - User data to apply when launching the instance. Note
   395      that you need to be careful about escaping characters due to the templates
   396      being JSON. It is often more convenient to use `user_data_file`, instead.
   397  
   398  -   `user_data_file` (string) - Path to a file that will be used for the user
   399      data when launching the instance.
   400  
   401  -   `vpc_id` (string) - If launching into a VPC subnet, Packer needs the VPC ID
   402      in order to create a temporary security group within the VPC. Requires `subnet_id`
   403      to be set. If this field is left blank, Packer will try to get the VPC ID from the
   404      `subnet_id`.
   405  
   406  -   `x509_upload_path` (string) - The path on the remote machine where the X509
   407      certificate will be uploaded. This path must already exist and be writable.
   408      X509 certificates are uploaded after provisioning is run, so it is perfectly
   409      okay to create this directory as part of the provisioning process. Defaults to
   410      `/tmp`.
   411  
   412  -   `windows_password_timeout` (string) - The timeout for waiting for a Windows
   413      password for Windows instances. Defaults to 20 minutes. Example value: `10m`
   414  
   415  ## Basic Example
   416  
   417  Here is a basic example. It is completely valid except for the access keys:
   418  
   419  ``` json
   420  {
   421    "type": "amazon-instance",
   422    "access_key": "YOUR KEY HERE",
   423    "secret_key": "YOUR SECRET KEY HERE",
   424    "region": "us-east-1",
   425    "source_ami": "ami-d9d6a6b0",
   426    "instance_type": "m1.small",
   427    "ssh_username": "ubuntu",
   428  
   429    "account_id": "0123-4567-0890",
   430    "s3_bucket": "packer-images",
   431    "x509_cert_path": "x509.cert",
   432    "x509_key_path": "x509.key",
   433    "x509_upload_path": "/tmp",
   434  
   435    "ami_name": "packer-quick-start {{timestamp}}"
   436  }
   437  ```
   438  
   439  -&gt; **Note:** Packer can also read the access key and secret access key from
   440  environmental variables. See the configuration reference in the section above
   441  for more information on what environmental variables Packer will look for.
   442  
   443  ## Accessing the Instance to Debug
   444  
   445  If you need to access the instance to debug for some reason, run the builder
   446  with the `-debug` flag. In debug mode, the Amazon builder will save the private
   447  key in the current directory and will output the DNS or IP information as well.
   448  You can use this information to access the instance as it is running.
   449  
   450  ## Build template data
   451  
   452  The available variables are:
   453  
   454  - `BuildRegion` - The region (for example `eu-central-1`) where Packer is building the AMI.
   455  - `SourceAMI` - The source AMI ID (for example `ami-a2412fcd`) used to build the AMI.
   456  - `SourceAMIName` - The source AMI Name (for example `ubuntu/images/ebs-ssd/ubuntu-xenial-16.04-amd64-server-20180306`) used to build the AMI.
   457  - `SourceAMITags` - The source AMI Tags, as a `map[string]string` object.
   458  
   459  ## Custom Bundle Commands
   460  
   461  A lot of the process required for creating an instance-store backed AMI involves
   462  commands being run on the actual source instance. Specifically, the
   463  `ec2-bundle-vol` and `ec2-upload-bundle` commands must be used to bundle the
   464  root filesystem and upload it, respectively.
   465  
   466  Each of these commands have a lot of available flags. Instead of exposing each
   467  possible flag as a template configuration option, the instance-store AMI builder
   468  for Packer lets you customize the entire command used to bundle and upload the
   469  AMI.
   470  
   471  These are configured with `bundle_vol_command` and `bundle_upload_command`. Both
   472  of these configurations are [configuration
   473  templates](/docs/templates/engine.html) and have support for
   474  their own set of template variables.
   475  
   476  ### Bundle Volume Command
   477  
   478  The default value for `bundle_vol_command` is shown below. It is split across
   479  multiple lines for convenience of reading. The bundle volume command is
   480  responsible for executing `ec2-bundle-vol` in order to store and image of the
   481  root filesystem to use to create the AMI.
   482  
   483  ``` text
   484  sudo -i -n ec2-bundle-vol \
   485    -k {{.KeyPath}}  \
   486    -u {{.AccountId}} \
   487    -c {{.CertPath}} \
   488    -r {{.Architecture}} \
   489    -e {{.PrivatePath}}/* \
   490    -d {{.Destination}} \
   491    -p {{.Prefix}} \
   492    --batch \
   493    --no-filter
   494  ```
   495  
   496  The available template variables should be self-explanatory based on the
   497  parameters they're used to satisfy the `ec2-bundle-vol` command.
   498  
   499  ~&gt; **Warning!** Some versions of ec2-bundle-vol silently ignore all .pem and
   500  .gpg files during the bundling of the AMI, which can cause problems on some
   501  systems, such as Ubuntu. You may want to customize the bundle volume command to
   502  include those files (see the `--no-filter` option of `ec2-bundle-vol`).
   503  
   504  ### Bundle Upload Command
   505  
   506  The default value for `bundle_upload_command` is shown below. It is split across
   507  multiple lines for convenience of reading. Access key and secret key are omitted
   508  if using instance profile. The bundle upload command is responsible for taking
   509  the bundled volume and uploading it to S3.
   510  
   511  ``` text
   512  sudo -i -n ec2-upload-bundle \
   513    -b {{.BucketName}} \
   514    -m {{.ManifestPath}} \
   515    -a {{.AccessKey}} \
   516    -s {{.SecretKey}} \
   517    -d {{.BundleDirectory}} \
   518    --batch \
   519    --region {{.Region}} \
   520    --retry
   521  ```
   522  
   523  The available template variables should be self-explanatory based on the
   524  parameters they're used to satisfy the `ec2-upload-bundle` command.
   525  Additionally, `{{.Token}}` is available when overriding this command. You must
   526  create your own bundle command with the addition of `-t {{.Token}} ` if you are
   527  assuming a role.
   528  
   529  #### Bundle Upload Permissions
   530  
   531  The `ec2-upload-bundle` requires a policy document that looks something like this:
   532  
   533  ```json
   534  {
   535      "Version": "2012-10-17",
   536      "Statement": [
   537          {
   538              "Effect": "Allow",
   539              "Action": [
   540                  "s3:PutObject",
   541                  "s3:GetObject",
   542                  "s3:ListBucket",
   543                  "s3:GetBucketLocation",
   544                  "s3:PutObjectAcl"
   545              ],
   546              "Resource": "*"
   547          }
   548      ]
   549  }
   550  ```
   551  
   552  You may wish to constrain the resource to a specific bucket.