---
title: "Terraform variables"
url: "https://docs.alisx.com/reference/dbd/terraform-variables/"
---
# Terraform variables

The variables Deploy injects into a service's `infra/` Terraform module on every deploy, how your own environment variables reach it, and the image reference format.

## Injected variables

Declare each variable you use in `variables.tf`, for example `variable "ALIS_OS_PROJECT" {}`. You do not have to declare them all.

| Variable | Meaning |
|---|---|
| `ALIS_OS_VERSION` | The service version being deployed, for example `1.2.4`. |
| `ALIS_OS_PROJECT` | The deployment environment's Google Cloud project id: the project the deploy lands in. |
| `ALIS_PROJECT_NR` | The deployment environment's Google Cloud project number. |
| `ALIS_REGION` | The deployment environment's default region. |
| `ALIS_OS_ORG_PROJECT` | The build environment's (organisation's) Google Cloud project id. |
| `ALIS_OS_PRODUCT_PROJECT` | The product's Google Cloud project id, which hosts the image registry and the package registries. |
| `ALIS_PRODUCT_REGION` | The product's default region, where the image registry lives. |
| `ALIS_OS_DOMAIN` | The build environment's buckets domain (`alis.build` by default), for naming storage buckets. |
| `ALIS_OS_NEURON` | The service id, for example `orders-v1`. |
| `ALIS_OS_NEURON_VERSION_COMMIT_SHA` | The build-repo commit the version was built from; the tag of every image of the version. |
| `ALIS_OS_ORG_BACKEND_PRODUCT_PREFIX` | The prefix under which this deployment's Terraform state is kept. |
| `ALIS_RUN_HASH` | The hash and region suffix Cloud Run appends to service URLs in the deployment environment's project, for composing the URL of another Cloud Run service there. |
| `ALIS_MANAGED_SPANNER_PROJECT` | The project of the managed Spanner database, when the product or deployment environment has one. |
| `ALIS_MANAGED_SPANNER_INSTANCE` | The managed Spanner instance. |
| `ALIS_MANAGED_SPANNER_DB` | The managed Spanner database name. |
| `ALIS_PRODUCT_CONFIG` | The product configuration (name, id, project id and number, IAM roles), base64-encoded, for Alis client libraries. |
| `ALIS_BETA_VERSION` | The beta version of the deployment, when one exists. |
| `ALIS_BETA_VERSION_COMMIT_SHA` | The commit of the beta version, when one exists. |

## Your environment variables

Every variable set on the deployment environment (`alis environment set`, or the console's **Variables** pages) is passed to the module as an input variable of the same name. Declare it to use it:

```hcl
variable "API_URL" {}
```

| Case | Behaviour |
|---|---|
| A variable with the same name as an injected one | Yours overrides the injected value. |
| A variable stored in Secret Manager (`--secret`) | Left out of the deploy. Read the secret named after the variable in the deployment environment's project, for example with `data "google_secret_manager_secret_version"`. |
| A variable changed after the last deploy | Takes effect at the next deploy; `alis environment set --deploy` triggers one. |

Terraform variables are not visible to the running container. Pass what your code needs as container `env` blocks.

## Backend

```hcl
backend "gcs" {
  bucket = "provided_at_runtime_by_alis"
  prefix = "provided_at_runtime_by_alis"
}
```

The bucket and prefix are replaced at deploy time. Set the Google provider's `project` to `var.ALIS_OS_PROJECT`.

## Image reference

```hcl
image = "${var.ALIS_PRODUCT_REGION}-docker.pkg.dev/${var.ALIS_OS_PRODUCT_PROJECT}/neurons/${var.ALIS_OS_NEURON}:${var.ALIS_OS_NEURON_VERSION_COMMIT_SHA}"
```

Append `/<folder>` or `/<name>` before the tag for additional images, as listed in [Dockerfile detection](https://docs.alisx.com/reference/dbd/dockerfile-detection.md).

## Service account

Deployments in the platform and in customer products run their Cloud Run services as the deployment environment's Alis-provisioned service account:

```hcl
service_account = "alis-build@${var.ALIS_OS_PROJECT}.iam.gserviceaccount.com"
```
