Platform.sh YAML tags
In addition to the basic functions you should be familiar with, YAML allows for special tags. Platform.sh accepts certain custom tags to facilitate working with configuration files.
These tags work with Platform.sh configuration files, but may not elsewhere.
!include tag to embed external files within a given YAML file.
The tag requires two properties:
||See the descriptions of strings, binaries, and YAML. Defaults to
||The path to the file to include, relative to the directory the YAML file is in.|
string to include an external file inline in the YAML file as if entered as a multi-line string.
For example, if you have a build hook like the following:
hooks: build: | set -e cp a.txt b.txt
You could create a file for the script:
set -e cp a.txt b.txt
And replace the hook with an include tag for an identical result:
hooks: build: !include type: string path: build.sh
This helps you break longer configuration like build scripts out into a separate file for easier maintenance.
binary to include an external binary file inline in the YAML file.
The file is base64 encoded.
For example, you could include a
favicon.ico file in the same folder as your app configuration.
Then you can include it as follows:
properties: favicon: !include type: binary path: favicon.ico
yaml to include an external YAML file inline as if entered directly.
yaml is the default, you can use it without specifying the type.
For example, you could have your configuration for works defined in a
size: S commands: start: python queue-worker.py variables: env: type: worker
Then the following three configurations are exactly equivalent:
workers: queue1: !include "worker.yaml"
workers: queue1: !include type: yaml path: 'worker.yaml'
workers: queue1: size: S commands: start: python queue-worker.py variables: env: type: worker
This can help simplify more complex files.
!archive tag for a reference to an entire directory specified relative to where the YAML file is.
For example, you might want to define a configuration directory for your Solr service. You might do so as follows:
mysearch: type: solr:8.0 disk: 1024 configuration: conf_dir: !archive "solr/conf"
!archive tag means that the value for
conf_dir isn’t the string
solr/conf but the entire
This directory is in the
.platform directory, since that’s where the
services.yaml file is.
solr/conf directory is then copied into the Platform.sh management system to use with the service.