github.com/hashicorp/packer@v1.14.3/website/content/docs/templates/legacy_json_templates/builders.mdx (about)

     1  ---
     2  description: >
     3    The `builders` block contains builders that create machines and generate images. Learn how to configure the `builders` block in JSON templates for Packer.
     4  page_title: builders reference for JSON templates
     5  ---
     6  
     7  # `builders` reference for JSON templates
     8  
     9  This topic provides reference information about the `builders` block in JSON templates.
    10  
    11  `@include 'from-1.5/legacy-json-warning.mdx'`
    12  
    13  ## Introduction
    14  
    15  The `builders` block contains an array of all the builders
    16  that Packer should use to generate machine images for the template.
    17  
    18  Builders create machines and generate images from them
    19  for various platforms. For example, there are separate builders for EC2,
    20  VMware, VirtualBox, etc. Packer comes with many builders by default, and can
    21  also be extended to add new builders.
    22  
    23  This documentation page will cover how to configure a builder in a template.
    24  The specific configuration options available for each builder, however, must be
    25  referenced from the documentation for that specific builder.
    26  
    27  Within a template, a section of builder definitions looks like this:
    28  
    29  ```json
    30  {
    31    "builders": [
    32      // ... one or more builder definitions here
    33    ]
    34  }
    35  ```
    36  
    37  ## Builder Definition
    38  
    39  A single builder definition maps to exactly one
    40  [build](/packer/docs/terminology#builds). A builder definition is a
    41  JSON object that requires at least a `type` key. The `type` is the name of the
    42  builder that will be used to create a machine image for the build.
    43  
    44  In addition to the `type`, other keys configure the builder itself. For
    45  example, the AWS builder requires an `access_key`, `secret_key`, and some other
    46  settings. These are placed directly within the builder definition.
    47  
    48  An example builder definition is shown below, in this case configuring the AWS
    49  builder:
    50  
    51  ```json
    52  {
    53    "type": "amazon-ebs",
    54    "access_key": "...",
    55    "secret_key": "..."
    56  }
    57  ```
    58  
    59  ## Named Builds
    60  
    61  Each build in Packer has a name. By default, the name is just the name of the
    62  builder being used. In general, this is good enough. Names only serve as an
    63  indicator in the output of what is happening. If you want, however, you can
    64  specify a custom name using the `name` key within the builder definition.
    65  
    66  This is particularly useful if you have multiple builds defined that use the
    67  same underlying builder. In this case, you must specify a name for at least one
    68  of them since the names must be unique.
    69  
    70  ## Communicators
    71  
    72  Every build is associated with a single
    73  [communicator](/packer/docs/templates/legacy_json_templates/communicator). Communicators are used to
    74  establish a connection for provisioning a remote machine (such as an AWS
    75  instance or local virtual machine).
    76  
    77  All the examples for the various builders show some communicator (usually SSH),
    78  but the communicators are highly customizable so we recommend reading the
    79  [communicator documentation](/packer/docs/templates/legacy_json_templates/communicator).