> ## Documentation Index
> Fetch the complete documentation index at: https://docs.layerform.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Provisioning layer definitions

> Provision an S3 back-end with the Elastic Stack layer definitions so that developers can use them to spin up development environments later.

<div className="flex justify-center items-center">
  <img src="https://mintcdn.com/ergomake-83/br_QNJl4feQWyGIg/images/cat-spawn.png?fit=max&auto=format&n=br_QNJl4feQWyGIg&q=85&s=4618ad3b821deb8d6d264d65faae1db2" width="384px" data-path="images/cat-spawn.png" />
</div>

In this page you'll learn what it means to "provision" a Layerform back-end and how to provision an S3 bucket with layer definitions. That way, everyone in your team will be able to use your layer definitions to spin up environments.

## What is "provisioning"?

Every time you *provision* a Layerform back-end, you'll upload a `json` file containing the name of each layer, its dependencies and contents (Terraform files). The term *provisioning* refers to the act of uploading the definition file and the Terraform files it refers to.

<img src="https://mintcdn.com/ergomake-83/br_QNJl4feQWyGIg/images/backend-process.png?fit=max&auto=format&n=br_QNJl4feQWyGIg&q=85&s=a7706b3c5b6d0b7c8438512570138e05" alt="" width="2115" height="772" data-path="images/backend-process.png" />

In the previous part of this tutorial, you have already provisioned a local Layerform back-end with layer definitions. In that case, you used the `local` back-end (your filesystem) to store the `json` file with the layer definitions.

The problem with using the `local` back-end to store layer definitions is that you're the only one who can use those definitions to create an environment. If you want *everyone* in your team to be able to use your layer definitions, you must use a remote back-end, like an S3 bucket.

<img src="https://mintcdn.com/ergomake-83/br_QNJl4feQWyGIg/images/backend-pull.png?fit=max&auto=format&n=br_QNJl4feQWyGIg&q=85&s=18d38876eb1fd44e3cc35249e2556336" alt="" width="2185" height="1183" data-path="images/backend-pull.png" />

## Provisioning an S3 bucket

To define layers, you should create a `layers.json` file and use the format below.

```json theme={null}
{
    "layers": [
        {
            "name": "base_example",
            "files": ["layers/base.tf", "layers/base/**"]
        },
        {
            "name": "your_top_layer",
            "files": ["layers/example.tf", "layers/example/**"],
            "dependencies": ["base_example"]
        }
    ]
}
```

After creating a JSON file like this, configure the Layerform CLI to use a remote S3 bucket by writing to the `config.yml` file in the `~/.layerform` directory.

```yaml theme={null}
currentContext: example-context
contexts:
    example-context:
        type: s3
        bucket: layerform-bucket-example
        region: us-east-1
```

Now, run `layerform configure` to provision these layers to your S3 bucket.

<Warning>
  Please create a bucket exclusively for Layerform when using an S3 bucket as a back-end.

  Layerform should always have its own bucket for storing layer states and definitions. Otherwise, it may overwrite existing files.
</Warning>

Once you have configured the `layerform` provider to use an S3 bucket as back-end, every time you run `layerform configure` again, you'll update the layer definitions in the bucket.

Now, whoever uses `layerform spawn` to create a layer will use definitions within the S3 bucket. That way, you'll ensure everyone in the team is spawning the latest version of your layers, as long as they have the same config file.

<Note>
  Whenever you update a layer, you can run `layerform configure` again to
  update the definitions in the cloud's S3 bucket.
</Note>
