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

# Quick start: Terraform/OpenTofu

This quick start guide explains how to use Tensor9 BYOC to deploy your Terraform/OpenTofu (**TF**) app as a private appliance.

![Your Terraform/OpenTofu workspace is compiled by Tensor9 BYOC for the selected form factor. Existing target examples include Amazon Web Services, Google Cloud, Microsoft Azure, neo-clouds, Kubernetes and on-premises. The result is a deployment workspace for the selected customer environment; arrows show compilation choices.](https://mintcdn.com/tensor9/r0grNOtjS7x3P7Z-/images/diagrams/terraform-workspace-targets-wide-dark.svg?fit=max\&auto=format\&n=r0grNOtjS7x3P7Z-\&q=85\&s=b3cba15d9e5e9bb9106453b98504d3f0)

![Your Terraform/OpenTofu workspace is compiled by Tensor9 BYOC for the selected form factor. Existing target examples include Amazon Web Services, Google Cloud, Microsoft Azure, neo-clouds, Kubernetes and on-premises. The result is a deployment workspace for the selected customer environment; arrows show compilation choices.](https://mintcdn.com/tensor9/r0grNOtjS7x3P7Z-/images/diagrams/terraform-workspace-targets-wide-light.svg?fit=max\&auto=format\&n=r0grNOtjS7x3P7Z-\&q=85\&s=fce6bfa336bd3727d28ba2daf46e34c8)

![Your Terraform/OpenTofu workspace is compiled by Tensor9 BYOC for the selected form factor. Existing target examples include Amazon Web Services, Google Cloud, Microsoft Azure, neo-clouds, Kubernetes and on-premises. The result is a deployment workspace for the selected customer environment; arrows show compilation choices.](https://mintcdn.com/tensor9/r0grNOtjS7x3P7Z-/images/diagrams/terraform-workspace-targets-stacked-dark.svg?fit=max\&auto=format\&n=r0grNOtjS7x3P7Z-\&q=85\&s=1f129609d16320beb75c5895237cf7d7)

![Your Terraform/OpenTofu workspace is compiled by Tensor9 BYOC for the selected form factor. Existing target examples include Amazon Web Services, Google Cloud, Microsoft Azure, neo-clouds, Kubernetes and on-premises. The result is a deployment workspace for the selected customer environment; arrows show compilation choices.](https://mintcdn.com/tensor9/r0grNOtjS7x3P7Z-/images/diagrams/terraform-workspace-targets-stacked-light.svg?fit=max\&auto=format\&n=r0grNOtjS7x3P7Z-\&q=85\&s=b981aa5824ccd1a2d3ad3b90ce443973)

Tensor9 BYOC compiles the published Terraform/OpenTofu workspace using the selected customer form factor. The target categories are examples; the result is a deployment workspace for the selected environment. Application execution follows the selected deployment workflow.

As you follow this guide, you will:

* Create your Tensor9 account and set up a Tensor9 BYOC control plane in your AWS account.
* Create an app and bind a TF workspace as its origin stack.
* Onboard a customer and release your app to their appliance.
* Release infrastructure changes.

## Prerequisites

* A Google account to sign up for Tensor9.
* Create an AWS account for Tensor9 BYOC. We will refer to this as the Tensor9 BYOC AWS account.

  **Important:**

  * Your Tensor9 BYOC AWS account should be a dedicated AWS account used only for Tensor9 BYOC. This reduces the risk of conflicts between your app deployed in a Tensor9 BYOC appliance and any other software, infrastructure, or resources you might have in a general-purpose AWS account.
  * Tensor9 BYOC sets up your control plane in the AWS `us-west-2` (US West, Oregon) region. Other regions are not available yet.
* Install [AWS CLI](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-getting-started.html) in your environment, and [set up an AWS CLI profile](https://docs.aws.amazon.com/cli/v1/userguide/cli-configure-files.html) that has admin permissions to your new AWS account. This guide calls it `my-vendor-aws`.
* A second AWS account to act as your first customer. You will open the customer setup link while signed in to this account.

## Install OpenTofu or Terraform

In your environment, you'll need to install Terraform/OpenTofu CLI.

This guide assumes you are using OpenTofu and uses the `tofu` command throughout.

## Create your account and control plane

1. Follow [Get a Tensor9 API key](https://docs.tensor9.com/byoc/getting-started/api-key.md) to sign up and install the `tensor9` CLI.

2. Export your API key and set up your control plane in your new AWS account (about 10 minutes):

```bash theme={null}
export T9_API_KEY=<your API key>
tensor9 vendor setup -awsProfile my-vendor-aws
```

Add `-region us-west-2` if your AWS configuration defaults to another region. Setup makes its controller profile your CLI default, so the commands below need no API key or profile options.

3. Create a new Tensor9 BYOC **app**.

```bash theme={null}
tensor9 app create -name tofu-quickstart -displayName "Tofu example app"
```

**Note:** The length of the `displayName` field must be 32 characters or fewer.

## Publish your TF and bind it to your new app

Tensor9 BYOC works by compiling your TF for each appliance you want to deploy to. So, your next step is to **publish** your TF to your Tensor9 BYOC control plane and **bind** it to your app. `tensor9 stack publish-direct` does both in one step:

```bash theme={null}
tensor9 stack publish-direct \
  -appName tofu-quickstart \
  -stackType TerraformWorkspace \
  -stackName your-stack \
  -dir <PATH_TO_YOUR_TF_ROOT>
```

The command bundles the `.tf` files in `-dir`, uploads them through your control plane and binds the stack to `tofu-quickstart` under the name `your-stack`. It authenticates with your controller profile, so it needs no AWS credentials. When it finishes, it prints a summary such as:

```
Published stack:
    name:       your-stack
    id:         <STACK_ID>
    bound:      yes
    app stacks: 1
```

This registers your stack with your app so that you can release your app/stack combination to appliances. When you publish again with the same `-stackName`, the command updates the stack and keeps the existing binding.

## Onboard a customer

Customers install your app in their own cloud accounts through a setup link. In this guide, your second AWS account acts as the customer.

1. Create a form factor that lets customers install your app in AWS:

```bash theme={null}
tensor9 form-factor create \
  -appName tofu-quickstart \
  -formFactorName aws-connected \
  -env Aws \
  -connectivity Connected
```

2. Create a setup link for your customer:

```bash theme={null}
tensor9 app setup -appName tofu-quickstart -customerName acme-corp
```

The command creates the customer `acme-corp` if it does not exist yet and prints the customer's setup link.

3. Sign in to the AWS console of your customer AWS account, then open the setup link in the same browser. Follow the setup wizard to choose the environment, then download and apply the infrastructure templates in the customer account. The [customer installation guide](https://docs.tensor9.com/byoc/customer/installation/overview.md) describes each step.

4. View the output of `tensor9 report` to determine when the customer's appliance is ready for a release. While the appliance is creating, `tensor9 report` displays output such as:

![](https://mintcdn.com/tensor9/9tUKxC213r1hPfEX/images/screenshots/appliance-create-inprogress-tf.png?fit=max\&auto=format\&n=9tUKxC213r1hPfEX\&q=85\&s=5533f0f48ecac4b14a603303bd89c554)

When the appliance is ready, `tensor9 report` displays output such as:

![](https://mintcdn.com/tensor9/9tUKxC213r1hPfEX/images/screenshots/appliance-create-complete-tf.png?fit=max\&auto=format\&n=9tUKxC213r1hPfEX\&q=85\&s=d82a3fe092bbe241c5ed2c3d4464c182)

## Release to your customer

1. Create a release for your customer:

```bash theme={null}
tensor9 stack release create \
  -appName tofu-quickstart \
  -customerName acme-corp \
  -vendorVersion "1.0.0" \
  -description "First release of my origin stack via Tensor9" \
  -notes "By engineer@vendor.co"
```

The release compiles your stack for the customer's appliance and downloads its deployment stack into `<APPLIANCE_NAME>/your-stack/`, using the appliance name and the `-stackName` you published with. The release output prints the directory.

2. Change into the new directory that contains the deployment stack for your customer's appliance:

```bash theme={null}
cd <APPLIANCE_NAME>/your-stack
```

3. Deploy as normal by running `tofu init` followed by `tofu apply`.

The tensor9 provider in the deployment stack authenticates with your Tensor9 API key, which it reads from the `T9_API_KEY` environment variable. In the workspace directory, enter the key at a hidden prompt, apply the stack, then unset the variable:

> [tab] Bash
>
> ```bash theme={null}
> set +x
> IFS= read -r -s -p 'Tensor9 API key: ' T9_API_KEY
> printf '\n'
> export T9_API_KEY
> tofu init
> tofu apply
> unset T9_API_KEY
> ```

> [tab] Zsh
>
> ```zsh theme={null}
> set +x
> IFS= read -r -s 'T9_API_KEY?Tensor9 API key: '
> printf '\n'
> export T9_API_KEY
> tofu init
> tofu apply
> unset T9_API_KEY
> ```

Use the API key you downloaded from [sandbox.tensor9.com](https://sandbox.tensor9.com/). Unset `T9_API_KEY` as soon as the apply finishes: while it is set, `tensor9` CLI commands use the key instead of your controller profile. Do not put the key in a command, a shell profile or a source file.

4. Run `tofu show` to review the resulting created resources.

### Debug a service-adapter request in the customer appliance

If the deployed application uses an origin-cloud API through a service adapter, record the app, appliance, release, selected service mapping and operation, then follow [Debugging Service Adapters](https://docs.tensor9.com/byoc/service-adapters/debugging/overview.md). Inspect the directed profile before sending another request, and use a hypothetical explanation where the selected operation supports it. Do not repeat a mutating request until you have checked whether the first request changed the target resource.

## Release an infrastructure change

You can release infrastructure changes to your stack at any time.

1. Update your origin stack with any desired change. For example, you could enable versioning on the AWS S3 bucket that was created when initially publishing your origin stack.

**Important:** The next step will overwrite the previous origin stack. All new releases will come from the most recently published version of your origin stack.

2. **Re-publish** the origin stack to Tensor9 BYOC, with the same `-stackName`:

```bash theme={null}
tensor9 stack publish-direct \
  -appName tofu-quickstart \
  -stackType TerraformWorkspace \
  -stackName your-stack \
  -dir <PATH_TO_YOUR_TF_ROOT>
```

The command reports that the stack is already bound to your app, so you do not need to bind it again.

3. Create a new release:

```bash theme={null}
tensor9 stack release create \
  -appName tofu-quickstart \
  -customerName acme-corp \
  -vendorVersion "1.0.1" \
  -description "Turning on versioning for the main bucket" \
  -notes "By engineer@vendor.co"
```

The updated deployment stack downloads into `<APPLIANCE_NAME>/your-stack/`. Run the commands below from the directory where you created the release.

4. Change into the directory that contains the deployment stack for your customer's appliance:

```bash theme={null}
cd <APPLIANCE_NAME>/your-stack
```

5. Deploy as normal by running `tofu init` followed by `tofu apply`, with your API key in `T9_API_KEY` for this step only, as in the first release:

The tensor9 provider in the deployment stack authenticates with your Tensor9 API key, which it reads from the `T9_API_KEY` environment variable. In the workspace directory, enter the key at a hidden prompt, apply the stack, then unset the variable:

> [tab] Bash
>
> ```bash theme={null}
> set +x
> IFS= read -r -s -p 'Tensor9 API key: ' T9_API_KEY
> printf '\n'
> export T9_API_KEY
> tofu init
> tofu apply
> unset T9_API_KEY
> ```

> [tab] Zsh
>
> ```zsh theme={null}
> set +x
> IFS= read -r -s 'T9_API_KEY?Tensor9 API key: '
> printf '\n'
> export T9_API_KEY
> tofu init
> tofu apply
> unset T9_API_KEY
> ```

Use the API key you downloaded from [sandbox.tensor9.com](https://sandbox.tensor9.com/). Unset `T9_API_KEY` as soon as the apply finishes: while it is set, `tensor9` CLI commands use the key instead of your controller profile. Do not put the key in a command, a shell profile or a source file.

6. Run `tofu show` to review the resulting created resources.

## Clean up

When you finish with this guide, remove what you created. You can do the following yourself today:

1. Remove the resources that your release deployed in the customer's appliance. From the directory that contains the deployment stack, `<APPLIANCE_NAME>/your-stack`, run `tofu destroy` with your API key in `T9_API_KEY` for this step only:

> [tab] Bash
>
> ```bash theme={null}
> set +x
> IFS= read -r -s -p 'Tensor9 API key: ' T9_API_KEY
> printf '\n'
> export T9_API_KEY
> tofu destroy
> unset T9_API_KEY
> ```

> [tab] Zsh
>
> ```zsh theme={null}
> set +x
> IFS= read -r -s 'T9_API_KEY?Tensor9 API key: '
> printf '\n'
> export T9_API_KEY
> tofu destroy
> unset T9_API_KEY
> ```

Review the plan that `tofu destroy` shows before you confirm it. Unset `T9_API_KEY` as soon as the command finishes, so that `tensor9` commands keep using your controller profile.

2. Unbind the stack from your app, so that no new releases are made from it:

```bash theme={null}
tensor9 stack unbind -appName tofu-quickstart -stackName your-stack
```

Unbinding does not remove anything already deployed, which is why you destroy the deployment first.

Some steps currently need Tensor9 support. To remove the customer's appliance or to remove your control plane from your AWS account, email [hello@tensor9.com](mailto:hello@tensor9.com) with your vendor ID, which `tensor9 whoami` reports, and the app and customer names. Do not delete control plane resources from your AWS account by hand.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.