Files
Packer-Cn/website/pages/docs/builders/amazon/ebsvolume.mdx
T

203 lines
6.4 KiB
Plaintext
Raw Normal View History

2016-10-31 16:44:41 -05:00
---
2017-06-14 18:04:16 -07:00
description: |
2020-03-18 18:46:47 -04:00
The amazon-ebsvolume Packer builder is like the EBS builder, but is
intended to create EBS volumes rather than a machine image.
2016-10-31 16:44:41 -05:00
layout: docs
2020-03-18 18:46:47 -04:00
page_title: Amazon EBS Volume - Builders
2020-04-02 19:39:47 -04:00
sidebar_title: EBS Volume
---
2016-10-31 16:44:41 -05:00
# EBS Volume Builder
Type: `amazon-ebsvolume`
2016-10-31 16:44:41 -05:00
The `amazon-ebsvolume` Packer builder is able to create Amazon Elastic Block
Store volumes which are prepopulated with filesystems or data.
2016-10-31 16:44:41 -05:00
This builder creates EBS volumes by launching an EC2 instance from a source
2019-09-20 15:04:01 +02:00
AMI. One or more EBS volumes are attached to the running instance, allowing
them to be provisioned into from the running machine. Once provisioning is
complete the source machine is destroyed. The provisioned volumes are kept
intact.
2016-10-31 16:44:41 -05:00
This is all done in your own AWS account. The builder will create temporary key
pairs, security group rules, etc. that provide it temporary access to the
instance while the image is being created.
2016-10-31 16:44:41 -05:00
2020-03-18 18:46:47 -04:00
The builder does _not_ manage EBS Volumes. Once it creates volumes and stores
2018-10-26 17:02:51 -07:00
it in your account, it is up to you to use, delete, etc. the volumes.
2016-10-31 16:44:41 -05:00
2020-03-23 20:02:12 -04:00
-> **Note:** Temporary resources are, by default, all created with the
2018-10-26 17:02:51 -07:00
prefix `packer`. This can be useful if you want to restrict the security groups
and key pairs Packer is able to operate on.
2017-02-10 19:51:43 -08:00
2016-10-31 16:44:41 -05:00
## Configuration Reference
2019-06-19 11:50:40 +02:00
There are many configuration options available for the builder. In addition to
the items listed here, you will want to look at the general configuration
references for [AMI](#ami-configuration),
[BlockDevices](#block-devices-configuration),
2019-11-06 01:15:19 -08:00
[Access](#access-configuration),
2019-06-19 11:50:40 +02:00
[Run](#run-configuration) and
[Communicator](#communicator-configuration)
configuration references, which are
necessary for this build to succeed and can be found further down the page.
2016-10-31 16:44:41 -05:00
### Optional:
2020-03-23 20:02:12 -04:00
@include 'builder/amazon/ebsvolume/Config-not-required.mdx'
2019-06-19 11:50:40 +02:00
2019-11-06 01:15:19 -08:00
### Access Configuration
2019-06-19 11:50:40 +02:00
#### Required:
2020-03-23 20:02:12 -04:00
@include 'builder/amazon/common/AccessConfig-required.mdx'
2019-06-19 11:50:40 +02:00
#### Optional:
2020-03-23 20:02:12 -04:00
@include 'builder/amazon/common/AccessConfig-not-required.mdx'
2019-06-19 11:50:40 +02:00
### AMI Configuration
#### Optional:
2020-03-18 18:46:47 -04:00
- `snapshot_groups` (array of strings) - A list of groups that have access to
create volumes from the snapshot(s). By default no groups have permission
to create volumes from the snapshot(s). `all` will make the snapshot
publicly accessible.
2020-03-18 18:46:47 -04:00
- `snapshot_users` (array of strings) - A list of account IDs that have
access to create volumes from the snapshot(s). By default no additional
users other than the user creating the AMI has permissions to create
volumes from the backing snapshot(s).
2019-06-19 11:50:40 +02:00
### Block Devices Configuration
Block devices can be nested in the
[ebs_volumes](#ebs_volumes) array.
2020-03-23 20:02:12 -04:00
@include 'builder/amazon/common/BlockDevice.mdx'
2019-06-19 11:50:40 +02:00
#### Optional:
2020-03-18 18:46:47 -04:00
2020-03-23 20:02:12 -04:00
@include 'builder/amazon/common/BlockDevice-not-required.mdx'
2020-03-24 19:48:37 -04:00
2020-03-23 20:02:12 -04:00
@include 'builder/amazon/ebsvolume/BlockDevice-not-required.mdx'
2019-06-19 11:50:40 +02:00
### Run Configuration
#### Required:
2020-03-23 20:02:12 -04:00
@include 'builder/amazon/common/RunConfig-required.mdx'
2019-06-19 11:50:40 +02:00
#### Optional:
2020-03-23 20:02:12 -04:00
@include 'builder/amazon/common/RunConfig-not-required.mdx'
2019-06-19 11:50:40 +02:00
@include 'builders/aws-session-manager.mdx'
2019-06-19 11:50:40 +02:00
### Communicator Configuration
#### Optional:
2020-03-23 20:02:12 -04:00
@include 'helper/communicator/Config-not-required.mdx'
2020-03-24 19:48:37 -04:00
2020-03-23 20:02:12 -04:00
@include 'helper/communicator/SSH-not-required.mdx'
2016-10-31 16:44:41 -05:00
## Basic Example
```json
2016-10-31 16:44:41 -05:00
{
2020-03-18 18:46:47 -04:00
"type": "amazon-ebsvolume",
"secret_key": "YOUR SECRET KEY HERE",
"access_key": "YOUR KEY HERE",
"region": "us-east-1",
"ssh_username": "ubuntu",
"instance_type": "t2.medium",
"source_ami": "ami-40d28157",
"ebs_volumes": [
{
2020-03-18 18:46:47 -04:00
"volume_type": "gp2",
"device_name": "/dev/xvdf",
"delete_on_termination": false,
"tags": {
"zpool": "data",
"Name": "Data1"
2016-10-31 16:44:41 -05:00
},
2020-03-18 18:46:47 -04:00
"volume_size": 10
},
{
2020-03-18 18:46:47 -04:00
"volume_type": "gp2",
"device_name": "/dev/xvdg",
"tags": {
"zpool": "data",
"Name": "Data2"
2016-10-31 16:44:41 -05:00
},
2020-03-18 18:46:47 -04:00
"delete_on_termination": false,
"volume_size": 10
},
{
2020-03-18 18:46:47 -04:00
"volume_size": 10,
"tags": {
"Name": "Data3",
"zpool": "data"
},
2020-03-18 18:46:47 -04:00
"delete_on_termination": false,
"device_name": "/dev/xvdh",
"volume_type": "gp2"
}
]
2016-10-31 16:44:41 -05:00
}
```
2020-03-23 20:02:12 -04:00
-> **Note:** Packer can also read the access key and secret access key from
2016-10-31 16:44:41 -05:00
environmental variables. See the configuration reference in the section above
for more information on what environmental variables Packer will look for.
Further information on locating AMI IDs and their relationship to instance
2018-10-26 17:02:51 -07:00
types and regions can be found in the AWS EC2 Documentation [for
Linux](http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/finding-an-ami.html)
or [for
Windows](http://docs.aws.amazon.com/AWSEC2/latest/WindowsGuide/finding-an-ami.html).
2016-10-31 16:44:41 -05:00
## Accessing the Instance to Debug
If you need to access the instance to debug for some reason, run the builder
with the `-debug` flag. In debug mode, the Amazon builder will save the private
key in the current directory and will output the DNS or IP information as well.
You can use this information to access the instance as it is running.
## Build template data
2018-10-26 17:02:51 -07:00
In configuration directives marked as a template engine above, the following
variables are available:
2020-03-18 18:46:47 -04:00
- `BuildRegion` - The region (for example `eu-central-1`) where Packer is
building the AMI.
- `SourceAMI` - The source AMI ID (for example `ami-a2412fcd`) used to build
the AMI.
2020-05-22 07:17:38 -04:00
- `SourceAMICreationDate` - The source AMI creation date (for example `"2020-05-14T19:26:34.000Z"`).
2020-03-18 18:46:47 -04:00
- `SourceAMIName` - The source AMI Name (for example
`ubuntu/images/ebs-ssd/ubuntu-xenial-16.04-amd64-server-20180306`) used to
build the AMI.
- `SourceAMIOwner` - The source AMI owner ID.
- `SourceAMIOwnerName` - The source AMI owner alias/name (for example `amazon`).
- `SourceAMITags` - The source AMI Tags, as a `map[string]string` object.
2020-03-23 20:02:12 -04:00
-> **Note:** Packer uses pre-built AMIs as the source for building images.
2016-10-31 16:44:41 -05:00
These source AMIs may include volumes that are not flagged to be destroyed on
2018-10-26 17:02:51 -07:00
termination of the instance building the new image. In addition to those
volumes created by this builder, any volumes in the source AMI which are not
2018-10-26 17:02:51 -07:00
marked for deletion on termination will remain in your account.
## Build function template engine variables
2020-03-31 17:40:07 -04:00
For the build function of [template engine](/docs/templates/engine), the following
variables are available:
2020-03-18 18:46:47 -04:00
- `SourceAMIName` - The source AMI Name (for example
`ubuntu/images/ebs-ssd/ubuntu-xenial-16.04-amd64-server-20180306`) used to
build the AMI.
2020-03-23 20:02:12 -04:00
@include 'builders/aws-ssh-differentiation-table.mdx'