github.com/dahs81/otto@v0.2.1-0.20160126165905-6400716cf085/website/source/docs/appfile/import.html.md (about)

     1  ---
     2  layout: "docs"
     3  page_title: "Import - Appfile"
     4  sidebar_current: "docs-appfile-import"
     5  description: |-
     6    The `import` statement can be used within an Appfile to import fragments
     7    of an Appfile from other sources, including the local filesystem and
     8    remote URLs.
     9  ---
    10  
    11  # Importing Appfile Fragments
    12  
    13  The `import` statement can be used within an Appfile to import fragments
    14  of an Appfile from other sources, including the local filesystem and
    15  remote URLs.
    16  
    17  Imports are an important concept for
    18  [collaborating](/docs/concepts/collaboration.html)
    19  on applications with Otto. They are the recommended way to share
    20  configurations for Appfiles, especially the `project` and
    21  `infrastructure` blocks.
    22  
    23  This page assumes you're familiar with the
    24  [Appfile syntax](/docs/appfile/syntax.html) already.
    25  
    26  ## Example
    27  
    28  Imports look like the following:
    29  
    30  ```
    31  import "github.com/hashicorp/otto-shared/database" {}
    32  ```
    33  
    34  ## Description
    35  
    36  `import` blocks fetch and copy contents from another Appfile into this
    37  Appfile. While it is similar to copying and pasting the contents of another
    38  Appfile, this isn't exactly correct, since imported contents are merged
    39  after the entire Appfile is loaded. This means the location of the
    40  `import` statement doesn't matter.
    41  
    42  Multiple `import` statements can be specified. In this case, their contents
    43  are merged in the order they were specified within the original Appfile.
    44  
    45  Due to the syntax of HCL, you must specify a trailing `{}` at the end of
    46  the import statement. There is no inner configuration allowed for imports.
    47  
    48  The URL allowed for imports is identical to the
    49  [allowed sources for dependencies](/docs/appfile/dep-sources.html).
    50  Within the source, Otto loads the "Appfile" and merges it. You cannot
    51  specify an alternate filename. To store multiple Appfiles in a single
    52  source, use folders.
    53  
    54  ## Syntax
    55  
    56  The full syntax is:
    57  
    58  ```
    59  import URL {}
    60  ```