Learn what are layer definitions and how they work.
layerform.json
file in the root folder of your project. It’s in that folder that you’ll run layerform configure
to provision layers to the back-end.
In that file, each object within the layers
array contains a layer definition with a name, list of files, and, optionally, a list of dependencies.
name
: an unique name for this layer definition. You’ll use this name in the CLI to spawn instances of this layer definition.files
: a list of Terraform files included in this layer. Layerform will run these files to provision infrastructure for an instance of this layer definition.dependencies
: a list layer definition names upon which instances of the current layer will be placed.layerform.json
file, you should run layerform configure
to upload the layer definitions to your Layerform back-end.
elastic_stack
layer, you’d have kibana.tf
and elasticsearch.tf
files within a folder called elastic_stack
. That folder would also have any necessary inputs and outputs in inputs.tf
and outputs.tf
files.
layerform.json
, make sure to include both the entrypoint and all the files in the module’s folder.
elastic_stack
layer must take an input
which comes from the eks
module which is part of the underlying eks
layer.
eks
layer references values from the elastic_stack
layer on top of it.
dependencies
list to fetch state for any underlying layers.
To use a layer definition, you must configure your CLI with the back-end containing the desired definition. For that, you must edit the config.yaml
file within ~/.layerform
.
In that file, you should configure a context with the desired type and its settings. Then, you should set `currentContext to the desired context’s name.
layerform spawn <layer_definition_name> <desired_id>
. The layerform spawn
command will pull the matching definition from the specified context and run its Terraform files.
layerform configure
again. That will cause the Layerform CLI to update the back-end with your updated files.
To delete a particular layer definition, you can simply remove the corresponding entry from your layerform.json
file and run layerform configure
again.