Variable Interpolation

Variables within variables


Oftentimes, you will need to define variables whose values depend on other variables.
To do this, you can use Value interpolation.

Starting with some examples always works best in these cases.

Some Examples

  • An environment variable identifier containing a complete identifier for your Bunnyshell environment.
    {{ }} : {{ }} : {{ }}

  • A variable that is using the identifier variable to create a logging content prefix.
    {{ "now"|date("m/d/Y") }} {{ env.var.identifier|lower }}

  • A variable that interpolates a conditional value
    {% if env.type == 'ephemeral' %}true{% else %}false{% endif %}

Where to use value interpolation

Available interpolation values

  • Organization variables
    • org.unique
  • Project variables
  • Environment variables
    • env.unique
    • env.type - primary / ephemeral
    • env.base_domain
    • env.k8s.namespace
    • env.vars.NAME
  • Components variables
    • components.COMPONENT_NAME.gitBranch
    • components.COMPONENT_NAME.ingress.hosts[*]
      The * must be replaced with the index, eg. 0 for the first host listed under the hosts attribute , 1 for the second host and so on.
    • components.COMPONENT_NAME.vars.NAME
    • components.COMPONENT_NAME.image1
    • components.COMPONENT_NAME.imageName1
    • components.COMPONENT_NAME.imageTag1
    • components.COMPONENT_NAME.exported.VAR_NAME (only for Helm, Kubernetes, Terraform and Generic components)


      Inside a component definition you can use directly component.* instead of components.COMPONENT_NAME.* where COMPONENT_NAMEis the current component name. This is also shorter to write, and very handy in case you will rename the component and you want some values to be strictly tied to component name, like host.hostname='{{ }}-{{ env.base_domain }}

  • Component containers variables
    • components.COMPONENT_NAME.containers.CONTAINER_NAME.vars.VAR_NAME

1 Helm, Kubernetes Manifest and Terraform components don’t have these. Generic component has these only when they have set or .dockerCompose.image