github.com/danp/terraform@v0.9.5-0.20170426144147-39d740081351/website/source/docs/enterprise/packer/builds/build-environment.html.md (about)

     1  ---
     2  layout: "enterprise"
     3  page_title: "Build Environment - Packer Builds - Terraform Enterprise"
     4  sidebar_current: "docs-enterprise-packerbuilds-environment"
     5  description: |-
     6    This page outlines the environment that Packer runs in within Terraform Enterprise.
     7  ---
     8  
     9  # Packer Build Environment
    10  
    11  This page outlines the environment that Packer runs in within Terraform
    12  Enterprise.
    13  
    14  ### Supported Builders
    15  
    16  Terraform Enterprise currently supports running the following Packer builders:
    17  
    18  - amazon-chroot
    19  - amazon-ebs
    20  - amazon-instance
    21  - digitalocean
    22  - docker
    23  - googlecompute
    24  - null
    25  - openstack
    26  - qemu
    27  - virtualbox-iso
    28  - vmware-iso
    29  
    30  ### Files
    31  
    32  All files in the uploading package (via [Packer push or GitHub](/docs/enterprise/packer/builds/starting.html)),
    33  and the application from the build pipeline are available on the filesystem
    34  of the build environment.
    35  
    36  You can use the file icon on the running build to show a list of
    37  available files.
    38  
    39  Files can be copied to the destination image Packer is provisioning
    40  with [Packer Provisioners](https://packer.io/docs/templates/provisioners.html).
    41  
    42  An example of this with the Shell provisioner is below.
    43  
    44  ```json
    45  {
    46    "provisioners": [
    47      {
    48        "type": "shell",
    49        "scripts": [
    50          "scripts/vagrant.sh",
    51          "scripts/dependencies.sh",
    52          "scripts/cleanup.sh"
    53        ]
    54      }
    55    ]
    56  }
    57  ```
    58  
    59  We encourage use of relative paths over absolute paths to maintain portability
    60  between Terraform Enterprise and local builds.
    61  
    62  The total size of all files in the package being uploaded via
    63  [Packer push or GitHub](/docs/enterprise/packer/builds/starting.html) must be 5 GB or less.
    64  
    65  If you need to upload objects that are larger, such as dmgs, see the
    66  [`packer push` "Limits" documentation](https://packer.io/docs/command-line/push.html)
    67  for ways around this limitation.
    68  
    69  ### Hardware Limitations
    70  
    71  Currently, each builder defined in the Packer template receives
    72  the following hardware resources. This is subject to change.
    73  
    74  - 1 CPU core
    75  - 2 GB of memory
    76  - 20 GBs of disk space
    77  
    78  ### Environment Variables
    79  
    80  You can set any number of environment variables that will be injected
    81  into your build environment at runtime. These variables can be
    82  used to configure your build with secrets or other key value configuration.
    83  
    84  Variables are encrypted and stored securely.
    85  
    86  Additionally, the following environment variables are automatically injected. All injected environment variables will be prefixed with `ATLAS_`
    87  
    88  - `ATLAS_TOKEN` - This is a unique, per-build token that expires at the end of
    89    build execution (e.g. `"abcd.atlasv1.ghjkl..."`)
    90  - `ATLAS_BUILD_ID` - This is a unique identifier for this build (e.g. `"33"`)
    91  - `ATLAS_BUILD_NUMBER` - This is a unique identifier for all builds in the same
    92    scope (e.g. `"12"`)
    93  - `ATLAS_BUILD_NAME` - This is the name of the build (e.g. `"mybuild"`).
    94  - `ATLAS_BUILD_SLUG` - This is the full name of the build
    95    (e.g. `"company/mybuild"`).
    96  - `ATLAS_BUILD_USERNAME` - This is the username associated with the build
    97    (e.g. `"sammy"`)
    98  - `ATLAS_BUILD_CONFIGURATION_VERSION` - This is the unique, auto-incrementing
    99    version for the [Packer build configuration](/docs/enterprise/glossary/index.html) (e.g. `"34"`).
   100  - `ATLAS_BUILD_GITHUB_BRANCH` - This is the name of the branch
   101    that the associated Packer build configuration version was ingressed from
   102    (e.g. `master`).
   103  - `ATLAS_BUILD_GITHUB_COMMIT_SHA` - This is the full commit hash
   104    of the commit that the associated Packer build configuration version was
   105    ingressed from (e.g. `"abcd1234..."`).
   106  - `ATLAS_BUILD_GITHUB_TAG` - This is the name of the tag
   107    that the associated Packer build configuration version was ingressed from
   108    (e.g. `"v0.1.0"`).
   109  
   110  If the build was triggered by a new application version, the following
   111  environment variables are also available:
   112  
   113  - `ATLAS_APPLICATION_NAME` - This is the name of the application connected to
   114    the Packer build (e.g. `"myapp"`).
   115  - `ATLAS_APPLICATION_SLUG` - This is the full name of the application connected
   116    to the Packer build (e.g. `"company/myapp"`).
   117  - `ATLAS_APPLICATION_USERNAME` - This is the username associated with the
   118    application connected to the Packer build (e.g. `"sammy"`)
   119  - `ATLAS_APPLICATION_VERSION` - This is the version of the application connected
   120    to the Packer build (e.g. `"2"`).
   121  - `ATLAS_APPLICATION_GITHUB_BRANCH` - This is the name of the branch that the
   122    associated application version was ingressed from (e.g. `master`).
   123  - `ATLAS_APPLICATION_GITHUB_COMMIT_SHA` - This is the full commit hash
   124    of the commit that the associated application version was ingressed from
   125    (e.g. `"abcd1234..."`).
   126  - `ATLAS_APPLICATION_GITHUB_TAG` - This is the name of the tag that the
   127    associated application version was ingressed from (e.g. `"v0.1.0"`).
   128  
   129  For any of the `GITHUB_` attributes, the value of the environment variable will
   130  be the empty string (`""`) if the resource is not connected to GitHub or if the
   131  resource was created outside of GitHub (like using `packer push` or
   132  `vagrant push`).
   133  
   134  
   135  ### Base Artifact Variable Injection
   136  
   137  A base artifact can be selected on the "Settings" page for a build
   138  configuration. During each build, the latest artifact version will have it's
   139  external ID (such as an AMI for AWS) injected as an environment variable for the
   140  environment.
   141  
   142  The keys for the following artifact types will be injected:
   143  
   144  - `aws.ami`: `ATLAS_BASE_ARTIFACT_AWS_AMI_ID`
   145  - `amazon.ami`: `ATLAS_BASE_ARTIFACT_AMAZON_AMI_ID`
   146  - `amazon.image`: `ATLAS_BASE_ARTIFACT_AMAZON_IMAGE_ID`
   147  - `google.image`: `ATLAS_BASE_ARTIFACT_GOOGLE_IMAGE_ID`
   148  
   149  You can then reference this artifact in your Packer template, like this
   150  AWS example:
   151  
   152  ```json
   153  {
   154    "variables": {
   155        "base_ami": "{{env `ATLAS_BASE_ARTIFACT_AWS_AMI_ID`}}"
   156    },
   157    "builders": [
   158      {
   159        "type": "amazon-ebs",
   160        "access_key": "",
   161        "secret_key": "",
   162        "region": "us-east-1",
   163        "source_ami": "{{user `base_ami`}}"
   164      }
   165    ]
   166  }
   167  ```
   168  
   169  ## Notes on Security
   170  
   171  Packer environment variables in Terraform Enterprise are encrypted using [Vault](https://vaultproject.io)
   172  and closely guarded and audited. If you have questions or concerns
   173  about the safety of your configuration, please contact our security team
   174  at [security@hashicorp.com](mailto:security@hashicorp.com).