App Lifecycle Manager lets you isolate customer infrastructure, access policies, and
quotas in dedicated *tenant projects*. You can configure producer and tenant
projects, create tenant resources to organize deployed units, and pass
tenant project variables during provisioning or upgrades.

For an overview of tenants and tenant projects, see
[Tenants and tenant projects](https://docs.cloud.google.com/app-lifecycle-manager/tenants.md.txt).

## Before you begin

Before you create tenant projects or resources:

1. Create a Terraform configuration, an Artifact Registry repository, and an artifact containing your SaaS application in your producer project. To learn how to create and upload a blueprint, see [Create and upload a blueprint](https://docs.cloud.google.com/app-lifecycle-manager/create-upload-blueprint.md.txt). To learn how to set up a SaaS offering, see [Quickstart: Deploy an application with App Lifecycle Manager](https://docs.cloud.google.com/app-lifecycle-manager/quickstart.md.txt).
2. Enable the APIs required by App Lifecycle Manager.


   <br />

   **Roles required to enable APIs**


   To enable APIs, you need the `serviceusage.services.enable` permission. If you
   created the project, then you likely already have this permission through the
   Owner role (`roles/owner`). Otherwise, you can get this permission through the
   Service Usage Admin role (`roles/serviceusage.serviceUsageAdmin`).
   [Learn how to grant roles](https://docs.cloud.google.com/iam/docs/granting-changing-revoking-access.md.txt).

   [Enable the APIs](https://console.cloud.google.com/apis/enableflow?apiid=saasservicemgmt.googleapis.com,artifactregistry.googleapis.com,config.googleapis.com,developerconnect.googleapis.com,cloudbuild.googleapis.com,storage.googleapis.com)

   <br />

3. Verify that the required service accounts are created and that the necessary
   Identity and Access Management roles are granted in the producer project. This includes the
   user-created service account and the roles granted to the
   `service-PROJECT_NUMBER@gcp-sa-saasservicemgmt.iam.gserviceaccount.com`
   service agent on the producer project, where
   `PROJECT_NUMBER` is the project number of your producer project.

## Set up a tenant project

When you provision your tenant's resources into separate projects, your
resources, IAM policies, quotas, and network configurations are
separated for each of your tenants, making it less likely for breaches or
misconfigurations with one tenant to affect your others.

You need the following:

- One producer project
- One tenant project for each tenant

### Console

To set up tenant and producer projects by using the Google Cloud console:

1. [Create a producer project and a tenant project for each of your tenants](https://console.cloud.google.com/home/dashboard).
2. [Enable billing on your tenant and producer projects](https://docs.cloud.google.com/billing/docs/how-to/verify-billing-enabled.md.txt#confirm_billing_is_enabled_on_a_project).
3. Enable the APIs required by App Lifecycle Manager in your tenant projects.


   <br />

   **Roles required to enable APIs**


   To enable APIs, you need the `serviceusage.services.enable` permission. If you
   created the project, then you likely already have this permission through the
   Owner role (`roles/owner`). Otherwise, you can get this permission through the
   Service Usage Admin role (`roles/serviceusage.serviceUsageAdmin`).
   [Learn how to grant roles](https://docs.cloud.google.com/iam/docs/granting-changing-revoking-access.md.txt).

   [Enable the APIs](https://console.cloud.google.com/apis/enableflow?apiid=saasservicemgmt.googleapis.com,artifactregistry.googleapis.com,config.googleapis.com,developerconnect.googleapis.com,cloudbuild.googleapis.com,storage.googleapis.com)

   <br />

4. Verify that your tenant projects have actuation service accounts with the
   required permissions.

   For details, see [App Lifecycle Manager service accounts](https://docs.cloud.google.com/app-lifecycle-manager/service-accounts.md.txt#actuation-sa).

After you create and enable billing for your producer and tenant projects,
you can create tenant resources and associate units with tenants.

### gcloud

To set up producer and tenant projects by using the Google Cloud CLI:

1. Create your producer project and a tenant project for each of your
   tenants:

   ```bash
   gcloud projects create \
       PRODUCER_PROJECT_ID \
       --name="SaaS producer project"
   gcloud projects create \
       TENANT_PROJECT_ID \
       --name="SaaS tenant A project"
   ```

   Replace the following:
   - `PRODUCER_PROJECT_ID`: the producer project ID
   - `TENANT_PROJECT_ID`: the tenant project ID
2. Enable billing for your tenant and producer projects:

   ```bash
   gcloud billing projects link \
       PRODUCER_PROJECT_ID \
       --billing-account=BILLING_ACCOUNT_ID
   gcloud billing projects link \
       TENANT_PROJECT_ID \
       --billing-account=BILLING_ACCOUNT_ID
   ```

   Replace the following:
   - `BILLING_ACCOUNT_ID`: the ID of the billing account that you want to associate with the specified projects
3. Enable the APIs required by App Lifecycle Manager in your tenant projects:

   ```bash
   gcloud services enable \
       saasservicemgmt.googleapis.com \
       artifactregistry.googleapis.com \
       config.googleapis.com \
       developerconnect.googleapis.com \
       cloudbuild.googleapis.com \
       storage.googleapis.com \
       --project=TENANT_PROJECT_ID
   ```
4. Grant the actuation service account the necessary IAM roles for
   each tenant project:

   ```bash
   gcloud projects add-iam-policy-binding \
       TENANT_PROJECT_ID \
       --member='serviceAccount:SERVICE_ACCOUNT_ID@PRODUCER_PROJECT_ID.iam.gserviceaccount.com' \
       --role=ROLE
   ```

   Replace the following:
   - `SERVICE_ACCOUNT_ID`: the ID of the actuation service account
   - `ROLE`: the IAM role to grant (for example, `roles/compute.admin`)

   Run `gcloud projects add-iam-policy-binding` for each role that you want
   to grant to the specified service account.

After you create and enable billing for your producer and tenant projects,
you can create tenant resources and associate units with tenants.

## Create a tenant resource

Create a *tenant* resource in your SaaS offering to represent your customer:

1. In the Google Cloud console, go to App Lifecycle Manager \> Tenants.

   [Go to Tenants](https://console.cloud.google.com/saas/tenants)
2. Click **Create**.

3. In the **Tenant name** field, enter a name for your tenant resource.

4. Optional: In the **Consumer resource** field, enter a consumer resource with
   consumer-defined settings for integration.

5. In the **SaaS offering** list, select the SaaS offering that you want to
   associate your tenant with.

6. From the **Region** list, select a region where tenant metadata is stored.

7. Optional: Click **Add label** to add a
   label to your tenant as a key-value pair.

8. Click **Create**.

## Associate a unit with a tenant

After you create a tenant and deploy a unit, you can link them to each other.
This association primarily serves as an organizational tag that helps you
organize which units belong to which tenant.

For more information about deploying units, see [Deploy a SaaS offering](https://docs.cloud.google.com/app-lifecycle-manager/deploy-saas-offering.md.txt).

To associate a unit with a tenant:

1. In the Google Cloud console, go to App Lifecycle Manager \> Tenants.

   [Go to Tenants](https://console.cloud.google.com/saas/tenants)
2. Click the name of the tenant that you want to associate with a unit.

3. Click **Edit**.

4. Under **Select a unit to be included in the tenant.** , click
   **Add unit**.

5. In the **Unit** list, select the unit that you want to associate with this
   tenant.

6. Click **Done**.

7. Click **Save**.

The selected units are associated with the indicated tenant.

## Provision a new unit with tenant project variables

When you provision a unit associated with a tenant, you must provide the
`tenant_project_id` and `tenant_project_number` variables.

1. In the Google Cloud console, go to App Lifecycle Manager \> Units.

   [Go to Units](https://console.cloud.google.com/saas/units)
2. Create a new unit associated with your unit kind.

3. Click **Provision**.

4. Select the **Release** to provision to your tenant unit.

5. Under **Actuation service account** , in the **Service account** list, select
   the service account that you granted roles to in your tenant project. Follow
   the principle of least privilege and grant only the necessary roles for the
   resources being managed.

6. In the **Other input variables** section:

   1. Click **Add tenant project variables** , and then select your tenant project to populate the `tenant_project_id` and `tenant_project_number` variables.
   2. Optional: Click **Add input variable** to enter other input variables defined in your Terraform configuration.
7. Click **Provision**.

App Lifecycle Manager triggers Infrastructure Manager by using the specified
actuation service account. Infrastructure Manager reads the `tenant_project_id`
and `tenant_project_number` variables and provisions the Terraform resources
inside that tenant project.

> [!NOTE]
> **Note:** If provisioning fails, verify that the required APIs are enabled and your permissions are correctly configured.

## Re-provision a unit with a new release

When you re-provision an existing unit with a new release, you must provide
the `tenant_project_id` and `tenant_project_number` variables.

1. In the Google Cloud console, go to App Lifecycle Manager \> Units.

   [Go to Units](https://console.cloud.google.com/saas/units)
2. Select the unit associated with your unit kind.

3. Click **Upgrade**.

4. Select the **Release** that you created with the updated Terraform configuration.

5. Under **Actuation service account** , in the **Service account** list, select
   the service account that you granted roles to in your tenant project. Follow
   the principle of least privilege and grant only the necessary roles for the
   resources being managed.

6. In the **Other input variables** section:

   1. Click **Add tenant project variables** , and then select your tenant project to populate the `tenant_project_id` and `tenant_project_number` variables.
   2. Optional: Click **Add input variable** to enter other input variables defined in your Terraform configuration.
7. Click **Upgrade**.

App Lifecycle Manager triggers Infrastructure Manager by using the specified
actuation service account. Infrastructure Manager reads the `tenant_project_id`
and `tenant_project_number` variables and updates the Terraform resources inside
that tenant project.

> [!NOTE]
> **Note:** If provisioning fails, verify that the required APIs are enabled and your permissions are correctly configured.

## What's next

- Explore [managing dependencies between units](https://docs.cloud.google.com/app-lifecycle-manager/variables.md.txt#dependencies).
- Learn more about [using variables and variable mapping](https://docs.cloud.google.com/app-lifecycle-manager/variables.md.txt).
- Review [permissions required for service accounts](https://docs.cloud.google.com/app-lifecycle-manager/service-accounts.md.txt#actuation-sa).