New Interested in participating in the HCP Waypoint Private Beta Program? Apply here
  • Infrastructure
    • terraform
    • packer
  • Networking
    • consul
  • Security
    • vault
    • boundary
  • Applications
    • nomad
    • waypoint
    • vagrant
  • HashiCorp Cloud Platform

    A fully managed platform to automate infrastructure on any cloud with HashiCorp products.

    • consul
    • terraform
    • vault
    • packerbeta
    Visit cloud.hashicorp.com
  • Overview
  • Tutorials
  • Docs
  • CLI
  • Plugins
  • Community
GitHub
Download
    • Overview
      • Overview
      • Helm
      • Heroku, Vercel, etc.
      • Kubernetes
  • Getting Started
    • Overview
    • Compatibility Promise
    • Protocol Version Table
    • Release Notifications
      • Overview
      • Upgrade to 0.2.0
      • Upgrade to 0.3.0
      • Upgrade to 0.4.0
      • Upgrade to 0.5.0
      • Upgrade to 0.6.0
      • Upgrade to 0.7.0
      • Upgrade to 0.8.0

    • Install
    • Externally Built Images
    • Building Container Images
    • Helm Deployment
    • YAML-Free Deployment
    • YAML Directory Deployment
    • Resource Status
    • ConfigMaps and Secrets

    • Overview
    • Git Integration
    • Remote Operations
    • Overview
    • Build
    • Deploy
    • Release
    • Hooks
    • Labels
    • Workspace and Label Scoping
    • Overview
      • Overview
      • Input Variables
      • External Data
      • artifact
      • deploy
      • entrypoint
      • labels
      • path
      • workspace
      • Overview
      • Full Reference
      • Templating
      • Overview
      • Expressions
      • JSON Syntax
    • app
    • build
    • config
    • deploy
    • hook
    • plugin
    • registry
    • release
    • runner
    • url
    • use
    • variable
  • URL Service
  • Logs
  • Exec
    • Overview
    • Dynamic Values
    • Files
    • Internal Values
    • Workspace and Label Scoping
    • Overview
      • Overview
      • OIDC
      • Tokens
      • Overview
      • Maintenance
      • Production
      • Security
    • Express Server Install
    • Overview
    • Configuration
    • Profiles
    • On-Demand Runner
    • Additional Runners
  • Workspaces
  • Plugins
  • Triggers

    • Overview
      • Overview
      • Registering Plugin Components
      • Handling Configuration
      • Implementing the Builder Interface
      • Compiling the Plugin
      • Creating an Example Application
      • Testing the Plugin
    • Initializing the SDK
    • Passing Values Between Components
      • Overview
      • Authenticator
      • ConfigSourcer
      • Configurable
      • ConfigurableNotify
      • Builder
      • Registry
      • Platform
      • ReleaseManager
      • Destroy
      • Status
      • Default Parameters
      • Overview
    • Overview
    • Disable
    • Overview
    • GitHub Actions
    • GitLab CI/CD
    • CircleCI
    • Jenkins
  • Troubleshooting
  • Glossary

    • Overview
    • Architecture
    • Operation Execution
  • Roadmap
Type '/' to Search

»Templating Functions

Waypoint has a set of functions for templating strings, files, and directories with both predefined and custom variable values. These templates can use conditionals, loops, and more to dynamically generate content.

Waypoint has three templating functions documented below: templatefile, templatedir, and templatestring. All of these functions use the same templating syntax. The templates have access to all the same variables and functions that are available at the function call-site (where the function such as templatedir is called). Custom variables can also be provided to the template.

»Syntax

Template syntax uses HCL string templates. This supports conditionals, loops, function calls, etc.

»templatefile

templatefile(path[, vars...]) path
templatefile(path[, vars...]) path

templatefile takes a path to a file and optionally one or more maps of variables for the template, renders the template at path, and returns the path to the rendered template. The returned path is a copy of the original template in a temporary location. This function does not modify the original file.

Reminder: This function returns a file path, not the rendered contents of the file. If you want the contents of the rendered file, you can wrap this function with file.

This function is useful for parameters that expect file paths. The example below shows using this function with Docker to template the Dockerfile:

app "web" {
  build {
    use "docker" {
      dockerfile = templatefile("${path.app}/Dockerfile.tpl", {
        theme = "rainbow"
      })
    }
  }
}
app "web" {
  build {
    use "docker" {
      dockerfile = templatefile("${path.app}/Dockerfile.tpl", {
        theme = "rainbow"
      })
    }
  }
}

»templatedir

templatedir(path[, vars...]) path
templatedir(path[, vars...]) path

templatedir is similar to templatefile, except it takes a path to a directory, treats all files within that directory as a template, copies the results to a new temporary directory, and returns the temporary directory path.

This function will recursively render all files in path.

This function is useful for parameters that expect directory paths, such as specifying a directory of YAML files for Kubernetes.

»templatestring

templatestring(string[, vars...]) string
templatestring(string[, vars...]) string

templatestring renders a string as a template directly and returns the rendered contents.

If you have a static template string, you probably want to use string literals instead. This function is primarily for dynamically sourced templates (such as reading a file or the contents of some other variable). If you have a static string you can use HCL interpolations directly, for example: "Port: ${deploy.port}"

Example, rendering a template file and returning the contents directly:

userdata = templatestring(file("${path.app}/userdata.tpl"))
userdata = templatestring(file("${path.app}/userdata.tpl"))
github logoEdit this page

Using Waypoint

The best way to understand what Waypoint can enable for your projects is to give it a try.

Waypoint tutorials
Waypoint documentation
Tutorial

Get Started - Kubernetes

Build, deploy, and release applications to a Kubernetes cluster.

View
Tutorial

Introduction to Waypoint

Waypoint enables you to publish any application to any platform with a single file and a single command.

View

Waypoint is maintained by HashiCorp, Inc.

View Code of Conduct
DocumentationCLI ReferenceTutorialsIntegrations
All systems normal