# Deploy an application with App Lifecycle Manager

App Lifecycle Manager lets you automate the deployment and lifecycle management of
multi-component applications, which helps you provision consistent environments
across Google Cloud. In this quickstart, you model a composite application
template with Cloud Run and Cloud Storage in
Application Design Center, and then provision a live unit.

## Before you begin

> [!NOTE]
> In this quickstart, the user-managed service account that you create in the
> prerequisites serves as the
> [actuation service account](https://docs.cloud.google.com/app-lifecycle-manager/overview.md.txt#actuation-sa).
> Infrastructure Manager uses this account to provision the
> Cloud Run service and Cloud Storage bucket for your
> unit. When you model the composite template directly in
> App Design Center, App Lifecycle Manager packages the
> Terraform blueprint and generates the unit kind and release automatically. A
> separate
> [artifact creation
> service account](https://docs.cloud.google.com/app-lifecycle-manager/overview#artifact-creation-sa) is not required.

1. Grant the [App Lifecycle Manager
   service account](https://docs.cloud.google.com/app-lifecycle-manager/service-accounts#app-lifecycle-manager-sa) the required permissions:
   1. In the Google Cloud console, go to **App Lifecycle Manager** \>
      **Overview** \> **Get started**.

      [Go to Get started with App Lifecycle Manager](https://console.cloud.google.com/saas/overview/get-started)
   2. If the banner with the message **The required permissions for App Lifecycle Manager
      account haven't been granted** appears, click **Grant permissions**.

<br />

## Model your offering by using a composite template

Use App Lifecycle Manager and Application Design Center to model a composite
template (`run-storage-quickstart`) that connects a Cloud Run
service to a Cloud Storage bucket.

### Configure your SaaS offering

1. In Google Cloud console, go to **App Lifecycle Manager** \> **SaaS offering**.

   [Go to SaaS offering](https://console.cloud.google.com/saas/saasOfferings)
2. Click **Create**.

3. In the **SaaS offering name** field, enter
   `run-storage-quickstart-offering`.

4. In the **Region** list, select the following regions, and then click **OK**:

   - `us-central1`
   - `us-east1`
   - `us-east5`
5. Click **Create** . Creating `run-storage-quickstart-offering` takes a few
   minutes.

   When the SaaS offering is created, the **SaaS offering details** page opens.

### Create a composite template

1. On the **SaaS offering details** page, click **Create new template**.
2. On the **Create a new composite template** page, configure the template:

   1. In the **Template ID** field, enter `run-storage-quickstart`.
   2. Click **Create template**.

      When App Lifecycle Manager finishes creating the composite template, its
      details appear in the **Connected application template** section of the
      **SaaS offering details** page.
3. In the **Connected application template** section, click **Manage
   template** , and then click **Configure in canvas**.

   App Design Center opens in the Google Cloud console.
4. In the **Components** area, add the following components to the design
   canvas:

   1. Click **Cloud Run (Service)** to add a `cloud-run-1` component to the canvas.
   2. Click **Cloud Storage** to add a `cloud-storage-1` component to the canvas.
5. On the canvas, drag from the **cloud-run-1** component to the
   **cloud-storage-1** component to create a connection.

   Connecting the components passes the Cloud Run service account
   to the Cloud Storage bucket's IAM binding with the
   `roles/storage.objectAdmin` role.
6. On the canvas, click the **cloud-run-1** component to open the
   **Configuration** panel:

   1. In the **Containers** area, expand **Container 1**.
   2. In the **Container Image** field, enter the public sample container image `us-docker.pkg.dev/cloudrun/container/hello:latest`.
   3. Click **Save**.
7. Click **Continue** \> **Deploy at scale with App Lifecycle Manager**.

   App Lifecycle Manager opens in the Google Cloud console.
8. In the **Connected application template** section, click **Update template
   revision**.

9. On the **Update template revision** page, select `r-2` in the **Revision**
   list, and then click **Update**.

   The **Connected application template** section displays **Importing
   Application Template** . When the import finishes, the **Unit kinds** tab
   lists the generated `u-native-components` unit kind.

## Provision the application by using App Lifecycle Manager

1. On the **SaaS offering details** page of `run-storage-quickstart-offering`,
   click **Provision**.

   The **Provision** page opens.
2. On the **Provision** page, select `us-central1` in the **Region** list, and
   then click **Add**.

3. On the **Add unit to provision** panel, configure the unit:

   1. In the **Unit name** field, enter `run-storage-quickstart-unit-1`.
   2. In the **Unit kind** list, select the `u-native-components` unit kind.
   3. In the **Release** list, select the generated release for your template revision.
   4. In the **Service account** list, select the actuation service account that you created in the [Before you begin](https://docs.cloud.google.com/app-lifecycle-manager/quickstart.md.txt#before-you-begin) section. Infra Manager uses this service account to provision the Cloud Run service and Cloud Storage bucket.
4. Click **Add tenant project variables**, and then select your project, which
   App Lifecycle Manager uses to provision the resources.

5. In the **Other input variables** area, click **Add input variable** and enter
   values for the following component input variables:

   - **Name** : `cloud-run-1_project_id`, **Variable type** : `String`, and **Variable value**: your project ID
   - **Name** : `cloud-run-1_location`, **Variable type** : `String`, and **Variable value** : `us-central1`
   - **Name** : `cloud-run-1_service_name`, **Variable type** : `String`, and **Variable value** : `quickstart-web`
   - **Name** : `cloud-storage-1_project_id`, **Variable type** : `String`, and **Variable value**: your project ID
   - **Name** : `cloud-storage-1_location`, **Variable type** : `String`, and **Variable value** : `us-central1`
   - **Name** : `cloud-storage-1_name`, **Variable type** : `String`, and **Variable value** : a globally unique bucket name, such as `PROJECT_ID-quickstart-bkt`
6. Click **Add** . The `run-storage-quickstart-unit-1` unit appears in the
   **Units to be provisioned** table.

7. Click **Provision** to deploy `run-storage-quickstart-unit-1`.

   The Cloud Run service and Cloud Storage bucket take
   a few minutes to provision.
8. To provision additional units in other regions, select the region from the
   **Region** list and then click **Add**.

## View the deployed unit

Verify that App Lifecycle Manager provisioned your unit and its resources.

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

   [Go to Units](https://console.cloud.google.com/saas/units)
2. Click **run-storage-quickstart-unit-1** to open the **Unit details** page.

3. On the **Unit details** page, check the **State** field:

   - **Ready**: The Cloud Run service and Cloud Storage bucket are provisioned.
   - **Provisioning**: The deployment operation is still in progress.

## Clean up


To avoid incurring charges to your Google Cloud account for
the resources used on this page, follow these steps.

### Delete the project

If you deployed the application resources in a new Google Cloud project, and if you
no longer need the project, then delete it by completing the following steps:

> [!CAUTION]
> **Caution:** If you delete a project, all the resources in the project are permanently deleted.

1. In the Google Cloud console, go to the **Manage resources** page.

   [Go to Manage resources](https://console.cloud.google.com/iam-admin/projects)
2. In the project list, select the project that you want to delete, and then click **Delete**.
3. At the prompt, enter the project ID, and then click **Shut down**.

## What's next

- To model and package units of deployment, see [Model and package units of deployment](https://docs.cloud.google.com/app-lifecycle-manager/model-saas-offering.md.txt).
- To learn more about App Lifecycle Manager, see [App Lifecycle Manager overview](https://docs.cloud.google.com/app-lifecycle-manager/overview.md.txt).
- To get started with App Lifecycle Manager, begin with [Create a SaaS offering](https://docs.cloud.google.com/app-lifecycle-manager/create-saas-offering.md.txt).
- To learn about service account architecture and permissions across App Lifecycle Manager, see [App Lifecycle Manager service accounts](https://docs.cloud.google.com/app-lifecycle-manager/service-accounts.md.txt).
- For the steps to update the release, see [Update a SaaS offering](https://docs.cloud.google.com/app-lifecycle-manager/update-saas-offering.md.txt).