--- description: | The amazon-ebsvolume Packer builder is like the EBS builder, but is intended to create EBS volumes rather than a machine image. layout: docs page_title: 'Amazon EBS Volume - Builders' sidebar_current: 'docs-builders-amazon-ebsvolume' --- # EBS Volume Builder Type: `amazon-ebsvolume` The `amazon-ebsvolume` Packer builder is able to create Amazon Elastic Block Store volumes which are prepopulated with filesystems or data. This builder builds EBS volumes by launching an EC2 instance from a source AMI, provisioning that running machine, and then destroying the source machine, keeping the volumes intact. 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. The builder does *not* manage EBS Volumes. Once it creates volumes and stores it in your account, it is up to you to use, delete, etc. the volumes. -> **Note:** Temporary resources are, by default, all created with the prefix `packer`. This can be useful if you want to restrict the security groups and key pairs Packer is able to operate on. ## Configuration Reference There are many configuration options available for the builder. They are segmented below into two categories: required and optional parameters. Within each category, the available configuration keys are alphabetized. In addition to the options listed here, a [communicator](/docs/templates/communicator.html) can be configured for this builder. ### Required: <%= partial "partials/builder/amazon/common/AccessConfig-required" %> <%= partial "partials/builder/amazon/common/RunConfig-required" %> ### Optional: <%= partial "partials/builder/amazon/common/AccessConfig-not-required" %> <%= partial "partials/builder/amazon/common/RunConfig-not-required" %> <%= partial "partials/builder/amazon/ebsvolume/Config-not-required" %> <%= partial "partials/builder/amazon/common/RunConfig-not-required" %> <%= partial "partials/helper/communicator/Config-not-required" %> ## Basic Example ``` json { "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" : [ { "volume_type" : "gp2", "device_name" : "/dev/xvdf", "delete_on_termination" : false, "tags" : { "zpool" : "data", "Name" : "Data1" }, "volume_size" : 10 }, { "volume_type" : "gp2", "device_name" : "/dev/xvdg", "tags" : { "zpool" : "data", "Name" : "Data2" }, "delete_on_termination" : false, "volume_size" : 10 }, { "volume_size" : 10, "tags" : { "Name" : "Data3", "zpool" : "data" }, "delete_on_termination" : false, "device_name" : "/dev/xvdh", "volume_type" : "gp2" } ] } ``` -> **Note:** Packer can also read the access key and secret access key from 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 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). ## 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 In configuration directives marked as a template engine above, the following variables are available: - `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. - `SourceAMIName` - The source AMI Name (for example `ubuntu/images/ebs-ssd/ubuntu-xenial-16.04-amd64-server-20180306`) used to build the AMI. - `SourceAMITags` - The source AMI Tags, as a `map[string]string` object. -> **Note:** Packer uses pre-built AMIs as the source for building images. These source AMIs may include volumes that are not flagged to be destroyed on termination of the instance building the new image. In addition to those volumes created by this builder, any volumes inn the source AMI which are not marked for deletion on termination will remain in your account. <%= partial "partials/builders/aws-ssh-differentiation-table" %>