github.com/hhrutter/nomad@v0.6.0-rc2.0.20170723054333-80c4b03f0705/website/source/api/json-jobs.html.md (about)

     1  ---
     2  layout: api
     3  page_title: JSON Job Specification - HTTP API
     4  sidebar_current: api-jobs
     5  description: |-
     6    Jobs can also be specified via the HTTP API using a JSON format. This guide
     7    discusses the job specification in JSON format.
     8  ---
     9  
    10  # JSON Job Specification
    11  
    12  This guide covers the JSON syntax for submitting jobs to Nomad. A useful command
    13  for generating valid JSON versions of HCL jobs is:
    14  
    15  ```shell
    16  $ nomad run -output my-job.nomad
    17  ```
    18  
    19  ## Syntax
    20  
    21  Below is an example of a JSON object that submits a `periodic` job to Nomad:
    22  
    23  ```json
    24  {
    25    "Job": {
    26      "Region": "global",
    27      "ID": "example",
    28      "Name": "example",
    29      "Type": "batch",
    30      "Priority": 50,
    31      "AllAtOnce": false,
    32      "Datacenters": [
    33        "dc1"
    34      ],
    35      "Constraints": [
    36        {
    37          "LTarget": "${attr.kernel.name}",
    38          "RTarget": "linux",
    39          "Operand": "="
    40        }
    41      ],
    42      "TaskGroups": [
    43        {
    44          "Name": "cache",
    45          "Count": 1,
    46          "Constraints": null,
    47          "Tasks": [
    48            {
    49              "Name": "redis",
    50              "Driver": "docker",
    51              "User": "foo-user",
    52              "Config": {
    53                "image": "redis:latest",
    54                "port_map": [
    55                  {
    56                    "db": 6379
    57                  }
    58                ]
    59              },
    60              "Constraints": null,
    61              "Env": {
    62                "foo": "bar",
    63                "baz": "pipe"
    64              },
    65              "Services": [
    66                {
    67                  "Name": "cache-redis",
    68                  "Tags": [
    69                    "global",
    70                    "cache"
    71                  ],
    72                  "PortLabel": "db",
    73                  "Checks": [
    74                    {
    75                      "Id": "",
    76                      "Name": "alive",
    77                      "Type": "tcp",
    78                      "Command": "",
    79                      "Args": null,
    80                      "Path": "",
    81                      "Protocol": "",
    82                      "Interval": 10000000000,
    83                      "Timeout": 2000000000
    84                    }
    85                  ]
    86                }
    87              ],
    88              "Vault": {
    89                "Policies": [
    90                  "policy-name"
    91                ],
    92                "Env": true,
    93                "ChangeMode": "restart",
    94                "ChangeSignal": ""
    95              },
    96              "Resources": {
    97                "CPU": 500,
    98                "MemoryMB": 256,
    99                "IOPS": 0,
   100                "Networks": [
   101                  {
   102                    "ReservedPorts": [
   103                      {
   104                        "Label": "rpc",
   105                        "Value": 25566
   106                      }
   107                    ],
   108                    "DynamicPorts": [
   109                      {
   110                        "Label": "db"
   111                      }
   112                    ],
   113                    "MBits": 10
   114                  }
   115                ]
   116              },
   117              "Meta": {
   118                "foo": "bar",
   119                "baz": "pipe"
   120              },
   121              "KillTimeout": 5000000000,
   122              "LogConfig": {
   123                "MaxFiles": 10,
   124                "MaxFileSizeMB": 10
   125              },
   126              "Templates": [
   127                {
   128                  "SourcePath": "local/config.conf.tpl",
   129                  "DestPath": "local/config.conf",
   130                  "EmbeddedTmpl": "",
   131                  "ChangeMode": "signal",
   132                  "ChangeSignal": "SIGUSR1",
   133                  "Splay": 5000000000
   134                }
   135              ],
   136              "Artifacts": [
   137                {
   138                  "GetterSource": "http://foo.com/artifact.tar.gz",
   139                  "GetterOptions": {
   140                    "checksum": "md5:c4aa853ad2215426eb7d70a21922e794"
   141                  },
   142                  "RelativeDest": "local/"
   143                }
   144              ],
   145              "DispatchPayload": {
   146                "File": "config.json"
   147              }
   148            }
   149          ],
   150          "RestartPolicy": {
   151            "Interval": 300000000000,
   152            "Attempts": 10,
   153            "Delay": 25000000000,
   154            "Mode": "delay"
   155          },
   156          "Meta": {
   157            "foo": "bar",
   158            "baz": "pipe"
   159          }
   160        }
   161      ],
   162      "Update": {
   163        "Stagger": 10000000000,
   164        "MaxParallel": 1
   165      },
   166      "Periodic": {
   167        "Enabled": true,
   168        "Spec": "- *",
   169        "SpecType": "cron",
   170        "ProhibitOverlap": true
   171      },
   172      "Meta": {
   173        "foo": "bar",
   174        "baz": "pipe"
   175      },
   176      "ParameterizedJob": {
   177        "Payload": "required",
   178        "MetaRequired": [
   179          "foo"
   180        ],
   181        "MetaOptional": [
   182          "bar"
   183        ]
   184      },
   185      "Payload": null
   186    }
   187  }
   188  ```
   189  
   190  ## Syntax Reference
   191  
   192  Following is a syntax reference for the possible keys that are supported and
   193  their default values if any for each type of object.
   194  
   195  ### Job
   196  
   197  The `Job` object supports the following keys:
   198  
   199  - `AllAtOnce` - Controls if the entire set of tasks in the job must
   200    be placed atomically or if they can be scheduled incrementally.
   201    This should only be used for special circumstances. Defaults to `false`.
   202  
   203  - `Constraints` - A list to define additional constraints where a job can be
   204    run. See the constraint reference for more details.
   205  
   206  - `Datacenters` - A list of datacenters in the region which are eligible
   207    for task placement. This must be provided, and does not have a default.
   208  
   209  - `TaskGroups` - A list to define additional task groups. See the task group
   210    reference for more details.
   211  
   212  - `Meta` - Annotates the job with opaque metadata.
   213  
   214  - `ParameterizedJob` - Specifies the job as a parameterized job such that it can
   215    be dispatched against. The `ParamaterizedJob` object supports the following
   216    attributes:
   217  
   218    - `MetaOptional` - Specifies the set of metadata keys that may be provided
   219      when dispatching against the job as a string array.
   220  
   221    - `MetaRequired` - Specifies the set of metadata keys that must be provided
   222      when dispatching against the job as a string array.
   223  
   224    - `Payload` - Specifies the requirement of providing a payload when
   225      dispatching against the parameterized job. The options for this field are
   226      "optional", "required" and "forbidden". The default value is "optional".
   227  
   228  - `Payload` - The payload may not be set when submitting a job but may appear in
   229    a dispatched job. The `Payload` will be a base64 encoded string containing the
   230    payload that the job was dispatched with. The `payload` has a **maximum size
   231    of 16 KiB**.
   232  
   233  - `Priority` - Specifies the job priority which is used to prioritize
   234    scheduling and access to resources. Must be between 1 and 100 inclusively,
   235    and defaults to 50.
   236  
   237  - `Region` - The region to run the job in, defaults to "global".
   238  
   239  - `Type` - Specifies the job type and switches which scheduler
   240    is used. Nomad provides the `service`, `system` and `batch` schedulers,
   241    and defaults to `service`. To learn more about each scheduler type visit
   242    [here](/docs/runtime/schedulers.html)
   243  
   244  - `Update` - Specifies the task's update strategy. When omitted, rolling
   245    updates are disabled. The `Update` object supports the following attributes:
   246  
   247    - `MaxParallel` - `MaxParallel` is given as an integer value and specifies
   248    the number of tasks that can be updated at the same time.
   249  
   250    - `Stagger` - `Stagger` introduces a delay between sets of task updates and
   251    is given in nanoseconds.
   252  
   253      An example `Update` block:
   254  
   255      ```json
   256      {
   257        "Update": {
   258          "MaxParallel" : 3,
   259          "Stagger" : 10000000000
   260        }
   261      }
   262      ```
   263  
   264  -   `Periodic` - `Periodic` allows the job to be scheduled at fixed times, dates
   265      or intervals. The periodic expression is always evaluated in the UTC
   266      timezone to ensure consistent evaluation when Nomad Servers span multiple
   267      time zones. The `Periodic` object is optional and supports the following attributes:
   268  
   269      - `Enabled` - `Enabled` determines whether the periodic job will spawn child
   270      jobs.
   271  
   272      - `time_zone` - Specifies the time zone to evaluate the next launch interval
   273        against. This is useful when wanting to account for day light savings in
   274        various time zones. The time zone must be parsable by Golang's
   275        [LoadLocation](https://golang.org/pkg/time/#LoadLocation). The default is
   276        UTC.
   277  
   278      - `SpecType` - `SpecType` determines how Nomad is going to interpret the
   279        periodic expression. `cron` is the only supported `SpecType` currently.
   280  
   281      - `Spec` - A cron expression configuring the interval the job is launched
   282      at. Supports predefined expressions such as "@daily" and "@weekly" See
   283      [here](https://github.com/gorhill/cronexpr#implementation) for full
   284      documentation of supported cron specs and the predefined expressions.
   285  
   286      - <a id="prohibit_overlap">`ProhibitOverlap`</a> - `ProhibitOverlap` can
   287        be set to true to enforce that the periodic job doesn't spawn a new
   288        instance of the job if any of the previous jobs are still running. It is
   289        defaulted to false.
   290  
   291      An example `periodic` block:
   292  
   293      ```json
   294      {
   295        "Periodic": {
   296            "Spec": "*/15 - *"
   297            "SpecType": "cron",
   298            "Enabled": true,
   299            "ProhibitOverlap": true
   300        }
   301      }
   302      ```
   303  
   304  ### Task Group
   305  
   306  `TaskGroups` is a list of `TaskGroup` objects, each supports the following
   307  attributes:
   308  
   309  - `Constraints` - This is a list of `Constraint` objects. See the constraint
   310    reference for more details.
   311  
   312  - `Count` - Specifies the number of the task groups that should
   313    be running. Must be non-negative, defaults to one.
   314  
   315  - `Meta` - A key-value map that annotates the task group with opaque metadata.
   316  
   317  - `Name` - The name of the task group. Must be specified.
   318  
   319  - `RestartPolicy` - Specifies the restart policy to be applied to tasks in this group.
   320    If omitted, a default policy for batch and non-batch jobs is used based on the
   321    job type. See the [restart policy reference](#restart_policy) for more details.
   322  
   323  - `EphemeralDisk` - Specifies the group's ephemeral disk requirements. See the
   324    [ephemeral disk reference](#ephemeral_disk) for more details.
   325  
   326  - `Tasks` - A list of `Task` object that are part of the task group.
   327  
   328  ### Task
   329  
   330  The `Task` object supports the following keys:
   331  
   332  - `Artifacts` - `Artifacts` is a list of `Artifact` objects which define
   333    artifacts to be downloaded before the task is run. See the artifacts
   334    reference for more details.
   335  
   336  - `Config` - A map of key-value configuration passed into the driver
   337    to start the task. The details of configurations are specific to
   338    each driver.
   339  
   340  - `Constraints` - This is a list of `Constraint` objects. See the constraint
   341    reference for more details.
   342  
   343  - `DispatchPayload` - Configures the task to have access to dispatch payloads.
   344    The `DispatchPayload` object supports the following attributes:
   345  
   346    - `File` - Specifies the file name to write the content of dispatch payload
   347      to. The file is written relative to the task's local directory.
   348  
   349  - `Driver` - Specifies the task driver that should be used to run the
   350    task. See the [driver documentation](/docs/drivers/index.html) for what
   351    is available. Examples include `docker`, `qemu`, `java`, and `exec`.
   352  
   353  -   `Env` - A map of key-value representing environment variables that
   354      will be passed along to the running process. Nomad variables are
   355      interpreted when set in the environment variable values. See the table of
   356      interpreted variables [here](/docs/runtime/interpolation.html).
   357  
   358      For example the below environment map will be reinterpreted:
   359  
   360      ```json
   361      {
   362        "Env": {
   363          "NODE_CLASS" : "${nomad.class}"
   364        }
   365      }
   366      ```
   367  
   368  - `KillTimeout` - `KillTimeout` is a time duration in nanoseconds. It can be
   369    used to configure the time between signaling a task it will be killed and
   370    actually killing it. Drivers first sends a task the `SIGINT` signal and then
   371    sends `SIGTERM` if the task doesn't die after the `KillTimeout` duration has
   372    elapsed. The default `KillTimeout` is 5 seconds.
   373  
   374  - `leader` - Specifies whether the task is the leader task of the task group. If
   375    set to true, when the leader task completes, all other tasks within the task
   376    group will be gracefully shutdown.
   377  
   378  - `LogConfig` - This allows configuring log rotation for the `stdout` and `stderr`
   379    buffers of a Task. See the log rotation reference below for more details.
   380  
   381  - `Meta` - Annotates the task group with opaque metadata.
   382  
   383  - `Name` - The name of the task. This field is required.
   384  
   385  - `Resources` - Provides the resource requirements of the task.
   386    See the resources reference for more details.
   387  
   388  - `Services` - `Services` is a list of `Service` objects. Nomad integrates with
   389    Consul for service discovery. A `Service` object represents a routable and
   390    discoverable service on the network. Nomad automatically registers when a task
   391    is started and de-registers it when the task transitions to the dead state.
   392    [Click here](/docs/service-discovery/index.html) to learn more about
   393    services. Below is the fields in the `Service` object:
   394  
   395       - `Name`: An explicit name for the Service. Nomad will replace `${JOB}`,
   396         `${TASKGROUP}` and `${TASK}` by the name of the job, task group or task,
   397         respectively. `${BASE}` expands to the equivalent of
   398         `${JOB}-${TASKGROUP}-${TASK}`, and is the default name for a Service.
   399         Each service defined for a given task must have a distinct name, so if
   400         a task has multiple services only one of them can use the default name
   401         and the others must be explicitly named. Names must adhere to
   402         [RFC-1123 ยง2.1](https://tools.ietf.org/html/rfc1123#section-2) and are
   403         limited to alphanumeric and hyphen characters (i.e. `[a-z0-9\-]`), and be
   404         less than 64 characters in length.
   405  
   406       - `Tags`: A list of string tags associated with this Service. String
   407         interpolation is supported in tags.
   408  
   409       - `PortLabel`: `PortLabel` is an optional string and is used to associate
   410         a port with the service.  If specified, the port label must match one
   411         defined in the resources block.  This could be a label of either a
   412         dynamic or a static port.
   413  
   414       - `Checks`: `Checks` is an array of check objects. A check object defines a
   415         health check associated with the service. Nomad supports the `script`,
   416         `http` and `tcp` Consul Checks. Script checks are not supported for the
   417         qemu driver since the Nomad client doesn't have access to the file system
   418         of a task using the Qemu driver.
   419  
   420           - `Type`:  This indicates the check types supported by Nomad. Valid
   421             options are currently `script`, `http` and `tcp`.
   422  
   423           - `Name`: The name of the health check.
   424  
   425           - `Interval`: This indicates the frequency of the health checks that
   426             Consul will perform.
   427  
   428           - `Timeout`: This indicates how long Consul will wait for a health
   429             check query to succeed.
   430  
   431           - `Path`: The path of the HTTP endpoint which Consul will query to query
   432             the health of a service if the type of the check is `http`. Nomad
   433             will add the IP of the service and the port, users are only required
   434             to add the relative URL of the health check endpoint.
   435  
   436           - `Protocol`: This indicates the protocol for the HTTP checks. Valid
   437             options are `http` and `https`. We default it to `http`.
   438  
   439           - `Command`: This is the command that the Nomad client runs for doing
   440             script based health check.
   441  
   442           - `Args`: Additional arguments to the `command` for script based health
   443             checks.
   444  
   445  	 - `TLSSkipVerify`: If true, Consul will not attempt to verify the
   446  	   certificate when performing HTTPS checks. Requires Consul >= 0.7.2.
   447  
   448  - `Templates` - Specifies the set of [`Template`](#template) objects to render for the task.
   449    Templates can be used to inject both static and dynamic configuration with
   450    data populated from environment variables, Consul and Vault.
   451  
   452  - `User` - Set the user that will run the task. It defaults to the same user
   453    the Nomad client is being run as. This can only be set on Linux platforms.
   454  
   455  ### Resources
   456  
   457  The `Resources` object supports the following keys:
   458  
   459  - `CPU` - The CPU required in MHz.
   460  
   461  - `IOPS` - The number of IOPS required given as a weight between 10-1000.
   462  
   463  - `MemoryMB` - The memory required in MB.
   464  
   465  - `Networks` - A list of network objects.
   466  
   467  The Network object supports the following keys:
   468  
   469  - `MBits` - The number of MBits in bandwidth required.
   470  
   471  Nomad can allocate two types of ports to a task - Dynamic and Static/Reserved
   472  ports. A network object allows the user to specify a list of `DynamicPorts` and
   473  `ReservedPorts`. Each object supports the following attributes:
   474  
   475  - `Value` - The port number for static ports. If the port is dynamic, then this
   476    attribute is ignored.
   477  - `Label` - The label to annotate a port so that it can be referred in the
   478    service discovery block or environment variables.
   479  
   480  <a id="ephemeral_disk"></a>
   481  
   482  ### Ephemeral Disk
   483  
   484  The `EphemeralDisk` object supports the following keys:
   485  
   486  - `Migrate` - Specifies that the Nomad client should make a best-effort attempt
   487    to migrate the data from a remote machine if placement cannot be made on the
   488    original node. During data migration, the task will block starting until the
   489    data migration has completed. Value is a boolean and the default is false.
   490  
   491  - `SizeMB` - Specifies the size of the ephemeral disk in MB. Default is 300.
   492  
   493  - `Sticky` - Specifies that Nomad should make a best-effort attempt to place the
   494    updated allocation on the same machine. This will move the `local/` and
   495    `alloc/data` directories to the new allocation. Value is a boolean and the
   496    default is false.
   497  
   498  <a id="restart_policy"></a>
   499  
   500  ### Restart Policy
   501  
   502  The `RestartPolicy` object supports the following keys:
   503  
   504  - `Attempts` - `Attempts` is the number of restarts allowed in an `Interval`.
   505  
   506  - `Interval` - `Interval` is a time duration that is specified in nanoseconds.
   507    The `Interval` begins when the first task starts and ensures that only
   508    `Attempts` number of restarts happens within it. If more than `Attempts`
   509    number of failures happen, behavior is controlled by `Mode`.
   510  
   511  - `Delay` - A duration to wait before restarting a task. It is specified in
   512    nanoseconds. A random jitter of up to 25% is added to the delay.
   513  
   514  -   `Mode` - `Mode` is given as a string and controls the behavior when the task
   515      fails more than `Attempts` times in an `Interval`. Possible values are listed
   516      below:
   517  
   518      - `delay` - `delay` will delay the next restart until the next `Interval` is
   519        reached.
   520  
   521      - `fail` - `fail` will not restart the task again.
   522  
   523  ### Constraint
   524  
   525  The `Constraint` object supports the following keys:
   526  
   527  - `LTarget` - Specifies the attribute to examine for the
   528    constraint. See the table of attributes [here](/docs/runtime/interpolation.html#interpreted_node_vars).
   529  
   530  - `RTarget` - Specifies the value to compare the attribute against.
   531    This can be a literal value, another attribute or a regular expression if
   532    the `Operator` is in "regexp" mode.
   533  
   534  - `Operand` - Specifies the test to be performed on the two targets. It takes on the
   535    following values:
   536  
   537    - `regexp` - Allows the `RTarget` to be a regular expression to be matched.
   538  
   539    - `set_contains` - Allows the `RTarget` to be a comma separated list of values
   540      that should be contained in the LTarget's value.
   541  
   542    - `distinct_host` - If set, the scheduler will not co-locate any task groups on the same
   543          machine. This can be specified as a job constraint which applies the
   544          constraint to all task groups in the job, or as a task group constraint which
   545          scopes the effect to just that group. The constraint may not be
   546          specified at the task level.
   547  
   548          Placing the constraint at both the job level and at the task group level is
   549          redundant since when placed at the job level, the constraint will be applied
   550          to all task groups. When specified, `LTarget` and `RTarget` should be
   551          omitted.
   552  
   553    - `distinct_property` - If set, the scheduler selects nodes that have a
   554          distinct value of the specified property for each allocation. This can
   555          be specified as a job constraint which applies the constraint to all
   556          task groups in the job, or as a task group constraint which scopes the
   557          effect to just that group. The constraint may not be specified at the
   558          task level.
   559  
   560          Placing the constraint at both the job level and at the task group level is
   561          redundant since when placed at the job level, the constraint will be applied
   562          to all task groups. When specified, `LTarget` should be the property
   563          that should be distinct and and `RTarget` should be omitted.
   564  
   565    - Comparison Operators - `=`, `==`, `is`, `!=`, `not`, `>`, `>=`, `<`, `<=`. The
   566      ordering is compared lexically.
   567  
   568  ### Log Rotation
   569  
   570  The `LogConfig` object configures the log rotation policy for a task's `stdout` and
   571  `stderr`. The `LogConfig` object supports the following attributes:
   572  
   573  - `MaxFiles` - The maximum number of rotated files Nomad will retain for
   574    `stdout` and `stderr`, each tracked individually.
   575  
   576  - `MaxFileSizeMB` - The size of each rotated file. The size is specified in
   577    `MB`.
   578  
   579  If the amount of disk resource requested for the task is less than the total
   580  amount of disk space needed to retain the rotated set of files, Nomad will return
   581  a validation error when a job is submitted.
   582  
   583  ```json
   584  {
   585    "LogConfig": {
   586      "MaxFiles": 3,
   587      "MaxFileSizeMB": 10
   588    }
   589  }
   590  ```
   591  
   592  In the above example we have asked Nomad to retain 3 rotated files for both
   593  `stderr` and `stdout` and size of each file is 10 MB. The minimum disk space that
   594  would be required for the task would be 60 MB.
   595  
   596  ### Artifact
   597  
   598  Nomad downloads artifacts using
   599  [`go-getter`](https://github.com/hashicorp/go-getter). The `go-getter` library
   600  allows downloading of artifacts from various sources using a URL as the input
   601  source. The key-value pairs given in the `options` block map directly to
   602  parameters appended to the supplied `source` URL. These are then used by
   603  `go-getter` to appropriately download the artifact. `go-getter` also has a CLI
   604  tool to validate its URL and can be used to check if the Nomad `artifact` is
   605  valid.
   606  
   607  Nomad allows downloading `http`, `https`, and `S3` artifacts. If these artifacts
   608  are archives (zip, tar.gz, bz2, etc.), these will be unarchived before the task
   609  is started.
   610  
   611  The `Artifact` object supports the following keys:
   612  
   613  - `GetterSource` - The path to the artifact to download.
   614  
   615  - `RelativeDest` - An optional path to download the artifact into relative to the
   616    root of the task's directory. If omitted, it will default to `local/`.
   617  
   618  - `GetterOptions` - A `map[string]string` block of options for `go-getter`.
   619    Full documentation of supported options are available
   620    [here](https://github.com/hashicorp/go-getter/tree/ef5edd3d8f6f482b775199be2f3734fd20e04d4a#protocol-specific-options-1).
   621    An example is given below:
   622  
   623  ```json
   624  {
   625    "GetterOptions": {
   626      "checksum": "md5:c4aa853ad2215426eb7d70a21922e794",
   627  
   628      "aws_access_key_id": "<id>",
   629      "aws_access_key_secret": "<secret>",
   630      "aws_access_token": "<token>"
   631    }
   632  }
   633  ```
   634  
   635  An example of downloading and unzipping an archive is as simple as:
   636  
   637  ```json
   638  {
   639    "Artifacts": [
   640      {
   641        "GetterSource": "https://example.com/my.zip",
   642        "GetterOptions": {
   643          "checksum": "md5:7f4b3e3b4dd5150d4e5aaaa5efada4c3"
   644        }
   645      }
   646    ]
   647  }
   648  ```
   649  
   650  #### S3 examples
   651  
   652  S3 has several different types of addressing and more detail can be found
   653  [here](http://docs.aws.amazon.com/AmazonS3/latest/dev/UsingBucket.html#access-bucket-intro)
   654  
   655  S3 region specific endpoints can be found
   656  [here](http://docs.aws.amazon.com/general/latest/gr/rande.html#s3_region)
   657  
   658  Path based style:
   659  
   660  ```json
   661  {
   662    "Artifacts": [
   663      {
   664        "GetterSource": "https://s3-us-west-2.amazonaws.com/my-bucket-example/my_app.tar.gz",
   665      }
   666    ]
   667  }
   668  ```
   669  
   670  or to override automatic detection in the URL, use the S3-specific syntax
   671  
   672  ```json
   673  {
   674    "Artifacts": [
   675      {
   676        "GetterSource": "s3::https://s3-eu-west-1.amazonaws.com/my-bucket-example/my_app.tar.gz",
   677      }
   678    ]
   679  }
   680  ```
   681  
   682  Virtual hosted based style
   683  
   684  ```json
   685  {
   686    "Artifacts": [
   687      {
   688        "GetterSource": "my-bucket-example.s3-eu-west-1.amazonaws.com/my_app.tar.gz",
   689      }
   690    ]
   691  }
   692  ```
   693  
   694  ### Template
   695  
   696  The `Template` block instantiates an instance of a template renderer. This
   697  creates a convenient way to ship configuration files that are populated from
   698  environment variables, Consul data, Vault secrets, or just general
   699  configurations within a Nomad task.
   700  
   701  Nomad utilizes a tool called [Consul Template][ct]. Since Nomad v0.5.3, the
   702  template can reference [Nomad's runtime environment variables][env]. For a full
   703  list of the API template functions, please refer to the [Consul Template
   704  README][ct].
   705  
   706  
   707  `Template` object supports following attributes:
   708  
   709  - `ChangeMode` - Specifies the behavior Nomad should take if the rendered
   710    template changes. The default value is `"restart"`. The possible values are:
   711  
   712    - `"noop"` - take no action (continue running the task)
   713    - `"restart"` - restart the task
   714    - `"signal"` - send a configurable signal to the task
   715  
   716  - `ChangeSignal` - Specifies the signal to send to the task as a string like
   717    "SIGUSR1" or "SIGINT". This option is required if the `ChangeMode` is
   718    `signal`.
   719  
   720  - `DestPath` - Specifies the location where the resulting template should be
   721    rendered, relative to the task directory.
   722  
   723  - `EmbeddedTmpl` -  Specifies the raw template to execute. One of `SourcePath`
   724    or `EmbeddedTmpl` must be specified, but not both. This is useful for smaller
   725    templates, but we recommend using `SourcePath` for larger templates.
   726  
   727  - `LeftDelim` - Specifies the left delimiter to use in the template. The default
   728    is "{{" for some templates, it may be easier to use a different delimiter that
   729    does not conflict with the output file itself.
   730  
   731  - `Perms` - Specifies the rendered template's permissions. File permissions are
   732    given as octal of the Unix file permissions rwxrwxrwx.
   733  
   734  - `RightDelim` - Specifies the right delimiter to use in the template. The default
   735    is "}}" for some templates, it may be easier to use a different delimiter that
   736    does not conflict with the output file itself.
   737  
   738  - `SourcePath` - Specifies the path to the template to be rendered. `SourcePath`
   739    is mutually exclusive with `EmbeddedTmpl` attribute. The source can be fetched
   740    using an [`Artifact`](#artifact) resource. The template must exist on the
   741    machine prior to starting the task; it is not possible to reference a template
   742    inside of a Docker container, for example.
   743  
   744  - `Splay` - Specifies a random amount of time to wait between 0 ms and the given
   745    splay value before invoking the change mode. Should be specified in
   746    nanoseconds.
   747  
   748  
   749  ```json
   750  {
   751    "Templates": [
   752      {
   753        "SourcePath": "local/config.conf.tpl",
   754        "DestPath": "local/config.conf",
   755        "EmbeddedTmpl": "",
   756        "ChangeMode": "signal",
   757        "ChangeSignal": "SIGUSR1",
   758        "Splay": 5000000000
   759      }
   760    ]
   761  }
   762  
   763  ```
   764  
   765  [ct]: https://github.com/hashicorp/consul-template "Consul Template by HashiCorp"
   766  [env]: /docs/runtime/environment.html "Nomad Runtime Environment"