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

# Provision Stacks with Spacelift

> Provision stacks using a Spacelift Blueprint or the Terraform provider.

<Note>Spacelift support for install stacks is gated behind a feature flag. [Reach out to Nuon](https://nuon.co/demo-request) to enable it for your org.</Note>

If a customer wants to manage their install stack using Spacelift, Nuon can generate code for them to use. There are two ways to install a Spacelift stack. Which one your customer uses depends on whether they want to use the Spacelift Web UI or Terraform.

* **[Blueprint](https://docs.spacelift.io/concepts/blueprint)** — publish a Spacelift blueprint and use the web UI to provision the stack.
* **[Terraform](https://registry.terraform.io/providers/spacelift-io/spacelift/latest/docs)** — apply a generated `spacelift.tf` and use the Terraform provider to provision the stack.

Both paths use the [`nuonco/install-stacks`](https://github.com/nuonco/install-stacks) modules over **raw Git**, so no Spacelift VCS integration or GitHub App install is required.

## How it works

Provisioning with Spacelift is a hand-off between you and your customer:

1. You create the install. The install workflow pauses at the **await install stack** step.
2. On that step's **Spacelift** tab, you copy the blueprint YAML or download the Terraform files.
3. You send them to your customer.
4. Your customer provisions the stack in their Spacelift account, into their cloud account.
5. The stack boots up the runner. Once the runner connects, the await install stack step completes and the
   install proceeds — no further action needed on your side.

## Prerequisites

Your customer will need the following in order to use Spacelift.

* A [Spacelift](https://spacelift.io/) account with permission to create blueprints and stacks.
* The [cloud integration](https://docs.spacelift.io/integrations/cloud-providers) set up for the cloud account they want to install your app in.

## Using a blueprint

Follow these steps to provision a stack using a Spacelift Blueprint.

<Steps>
  <Step title="Create an install">
    Create an install as you usually would, and wait for the provision workflow to get to the **await install stack** step.
  </Step>

  <Step title="Send your customer the blueprint">
    On the **await install stack** step, open the **Spacelift** tab and copy or download the blueprint YAML.
    Send this to your customer.

    The remaining steps are for your customer.
  </Step>

  <Step title="Create the blueprint">
    In Spacelift, go to **Blueprints → Create blueprint** and paste the YAML from your vendor as the template body.
    The template is configured to put the stack in the `root` space by default.
    Edit the `space:` line while it's a draft if the stack should live elsewhere.
  </Step>

  <Step title="Publish it">
    Click **Publish** to move the blueprint from draft to published.
    Once published, the blueprint cannot be edited.
  </Step>

  <Step title="Create a stack and fill in the inputs">
    On the published blueprint, click **Create stack** and fill in the inputs and secrets.
    Click **Create** to create the stack.
  </Step>

  <Step title="Attach cloud credentials">
    Open the new stack's **Settings → Integrations**. Attach the [cloud integration](https://docs.spacelift.io/integrations/cloud-providers) to grant Spacelift access to the cloud account.
  </Step>

  <Step title="Provision the stack">
    Trigger a run.
    This will provision the Nuon stack.
    Once the runner phones home, the await install stack step in Nuon will complete.
  </Step>
</Steps>

## Using terraform

Follow these steps to provision a Nuon install stack using the Spacelift Terraform provider.

<Steps>
  <Step title="Send your customer the files">
    Click **Download all (.zip)** on the **Spacelift** tab to get `spacelift.tf`, `inputs.auto.tfvars`, and
    `secrets.auto.tfvars` as a single zip (or download them individually), then send them to your customer.

    The remaining steps are for your customer.
  </Step>

  <Step title="Configure `spacelift.tf`">
    Unpack all three files into one directory. In `spacelift.tf`, set the `space_id` variable's `default` to the
    Spacelift space this stack should live in.
  </Step>

  <Step title="Authenticate with GCP">
    By default, the config attaches Spacelift's GCP integration to the stack — a dedicated service account created
    during the apply. If you already manage your own GCP integration, set `attach_gcp_service_account`'s
    default to `false` in `spacelift.tf`.
  </Step>

  <Step title="Configure `inputs.auto.tfvars`">
    Fill in the inputs in the `inputs.auto.tfvars` file.
    Leave this file alongside the stack if you want to manage these values in version control.
    Alternatively, you can save the contents to a mounted, non-secret file in Spacelift.
  </Step>

  <Step title="Configure `secrets.auto.tfvars`">
    If saving this as a secret mounted file, fill in the secrets in `secrets.auto.tfvars`.
    Alternatively, store the secret values in a secret store and pass them to terraform using environment variables.
  </Step>

  <Step title="Authenticate the Spacelift provider">
    The [`spacelift-io/spacelift`](https://registry.terraform.io/providers/spacelift-io/spacelift/latest/docs)
    provider needs Spacelift API credentials.
    If the terraform is being run within Spacelift, then these will automatically be populated in the environment.
    Otherwise, [configure authentication for the Spacelift provider](https://registry.terraform.io/providers/spacelift-io/spacelift/latest/docs#authentication).
  </Step>

  <Step title="Apply the stack">
    Initialize the terraform workspace and apply.

    ```bash theme={null}
    terraform init && terraform apply
    ```
  </Step>

  <Step title="Trigger the first run">
    Trigger the first run.
    This will provision the Nuon stack.
    Once the runner phones home, the await install stack step in Nuon completes.
  </Step>
</Steps>
