Create an App Hub application using a single project


App Hub enables you to manage and view infrastructure resources from Google Cloud projects through App Hub applications. To create these App Hub applications, you require an App Hub host project to which you can attach service projects that contain Google Cloud resources.

This tutorial shows you how to set up an App Hub application in a single project that acts as the App Hub host and service project. In a service project, you deploy a load balanced managed instance group (MIG) and attach the service project to the App Hub host project. Then, in an application on the App Hub host project, you register and monitor all the infrastructure resources from the service project as App Hub services and workloads.

This tutorial is intended for people who set up and administer App Hub. You should have some experience with Cloud Load Balancing.

Objectives

This tutorial shows you how to complete the following tasks:

  1. Create or select a Google Cloud project. This project is your App Hub host and service project. In this project, enable the App Hub API.
  2. In this project, use Terraform to deploy a VPC network, a regional external Application Load Balancer, and a MIG backend for the load balancer. The regional external Application Load Balancer includes the following resources:

    • HTTP health check
    • Forwarding rule
    • URL map
    • Target proxy
    • Backend service with a managed instance group as the backend
    • SSL certificate (for HTTPS)

    Only the forwarding rule, URL map, backend service, and MIG become available as discovered resources on App Hub. For more information, see concepts and data model.

  3. Provide the appropriate roles and permissions to this project to act as the App Hub host project.

  4. Attach the App Hub host project as an App Hub service project to discover Google Cloud resources from the service project as discovered services and workloads.

  5. Create a regional App Hub application in the App Hub host project.

  6. Register discovered services and a workload from the service project on the App Hub application and assign attributes.

  7. View details of the registered services and workloads on App Hub.

Costs

For an estimate of the cost of the Google Cloud resources that the load balanced managed VM solution uses, see the precalculated estimate in the Google Cloud Pricing Calculator.

Use the estimate as a starting point to calculate the cost of your deployment. You can modify the estimate to reflect any configuration changes that you plan to make for the resources that are used in the solution.

The precalculated estimate is based on assumptions for certain factors, including the following:

  • The Google Cloud locations where the resources are deployed.
  • The amount of time that the resources are used.

For more information on App Hub costs, see the Pricing page.

Before you begin

If you are the project creator, you are granted the basic Owner role (roles/owner). By default, this Identity and Access Management (IAM) role includes the permissions necessary for full access to most Google Cloud resources.

If you are not the project creator, required permissions must be granted on the project to the appropriate principal. For example, a principal can be a Google Account (for end users) or a service account (for applications and workloads).

To get the permissions that you need to complete this tutorial, ask your administrator to grant you the following IAM roles on your project:

For more information about granting roles, see Manage access to projects, folders, and organizations.

You might also be able to get the required permissions through custom roles or other predefined roles.

Console

  1. In the Google Cloud console, go to the project selector page.

    Go to project selector

  2. Select or create a Google Cloud project, to be your App Hub host project.

  3. Enable the App Hub, Cloud Resource Manager, Compute Engine, Infrastructure Manager, and Service Usage APIs.

    Enable the APIs

gcloud

  1. In the Google Cloud console, activate Cloud Shell.

    Activate Cloud Shell

    At the bottom of the Google Cloud console, a Cloud Shell session starts and displays a command-line prompt. Cloud Shell is a shell environment with the Google Cloud CLI already installed and with values already set for your current project. It can take a few seconds for the session to initialize.

  2. Make sure that the most recent version of Google Cloud CLI is installed. Run the following command from the Cloud Shell:

      gcloud components update

  3. Create or select a new project, HOST_PROJECT_ID, to be the host project for App Hub.

    • Create a Google Cloud project:

      gcloud projects create HOST_PROJECT_ID
    • Select the Google Cloud project that you created:

      gcloud config set project HOST_PROJECT_ID
  4. Enable the App Hub, Cloud Resource Manager, Compute Engine, Infrastructure Manager, and Service Usage APIs:

    gcloud services enable apphub.googleapis.com \
       cloudresourcemanager.googleapis.com \
       compute.googleapis.com \
       config.googleapis.com \
       serviceusage.googleapis.com

Preparing the environment

To help you deploy this solution with minimal effort, a Terraform configuration is provided in GitHub. The Terraform configuration defines all the Google Cloud resources that are required for the solution. Download the Terraform configuration from GitHub, optionally customize the code as necessary, and then deploy the solution by using the Terraform CLI. After you deploy the solution, you can continue to use Terraform to manage the solution.

App Hub workloads and services with a load balancer and managed instance group.
Figure 1. App Hub workloads and services with a load balancer and managed instance group.

The following is the request processing flow of the topology that the load balanced managed VM solution deploys.

  1. The user makes a request to the application, which is deployed on Compute Engine. Cloud Load Balancing receives this request.

  2. Cloud Load Balancing routes traffic to the Compute Engine managed instance groups, using information in the forwarding rule, URL map, and backend service.

Set up the Terraform client

You can run Terraform either in Cloud Shell or on your local host. This tutorial describes how to run Terraform in Cloud Shell, which has Terraform preinstalled and configured to authenticate with Google Cloud.

The Terraform code for this solution is available in a GitHub repository.

  1. In Cloud Shell, clone the GitHub repository to Cloud Shell.

    git clone https://github.com/terraform-google-modules/terraform-docs-samples
    
  2. In Cloud Shell, check whether the current working directory is terraform-docs-samples/lb/regional_external_http_load_balancer. This is the directory that contains the Terraform configuration files for the solution. If you need to change to that directory, run the following command:

    cd terraform-docs-samples/lb/regional_external_http_load_balancer 
    
  3. Initialize Terraform by running the following command:

    terraform init
    

    Wait until you see the following message:

    Terraform has been successfully initialized!
    

Validate and review the Terraform configuration

  1. Make sure that the current working directory is terraform-docs-samples/lb/regional_external_http_load_balancer. If it isn't, go to that directory.

  2. Verify that the Terraform configuration has no errors:

    terraform validate
    

    If the command returns any errors, make the required corrections in the configuration and then run the terraform validate command again. Repeat this step until the command returns the following message:

    Success! The configuration is valid.
    
  3. Review the resources that are defined in the configuration:

    terraform plan
    

    The output of the terraform plan command is a list of the resources that Terraform provisions when you apply the configuration.

    If you want to make any changes, edit the configuration and then run the terraform validate and terraform plan commands again.

Provision the resources

When no further changes are necessary in the Terraform configuration, deploy the resources.

  1. Make sure that the current working directory is terraform-docs-samples/lb/regional_external_http_load_balancer. If it isn't, go to that directory.

  2. Apply the Terraform configuration:

    terraform apply
    

    Terraform displays a list of the resources that will be created.

  3. When you're prompted to perform the actions, enter yes.

    Terraform displays messages showing the progress of the deployment.

    If the deployment can't be completed, Terraform displays the errors that caused the failure. Review the error messages and update the configuration to fix the errors. Then run the terraform apply command again.

    After all the resources are created, Terraform displays the following message:

    Apply complete!
    

Wait until Terraform displays the "Apply complete!" message.

Cloud Load Balancing distributes traffic to the forwarding rule, URL map, backend service, and a Compute Engine MIG. The backend service, URL map, and forwarding rules become discovered services in the App Hub host project. The Compute Engine MIG becomes a discovered workload in the App Hub host project.

When you no longer need the solution, you can delete the deployment to avoid continued billing for the Google Cloud resources. For more information, see Delete the deployment.

Grant IAM permissions

Provide the appropriate IAM roles and permissions to the App Hub host project.

Console

To get the permissions that you need to complete this tutorial, ask your administrator to grant you the required IAM roles on your project:

  1. In the Google Cloud console, go to the IAM page.

    Go to IAM

  2. Click Grant access. The Grant access pane opens.

  3. In the New principals field, enter the email address of the individual who will administer App Hub, the App Hub Admin role in the host project.

  4. Click Select a role and in the Filter field, enter App Hub.

  5. Select the App Hub Admin role.

  6. Click Add another role and from the Select a role list, select Monitoring Viewer.

  7. Click Save.

gcloud

  1. To grant the roles to individuals who will use App Hub, repeat the following command by replacing the IAM roles, as required. For more information, see App Hub roles and permissions.

    gcloud projects add-iam-policy-binding HOST_PROJECT_ID \
        --member='user:HOST_PROJECT_ADMIN' \
        --role='roles/apphub.admin'

    Replace HOST_PROJECT_ADMIN with the user who has the App Hub Admin role in the host project. This value has the format username@yourdomain, for example, 222larabrown@gmail.com.

  2. Grant the App Hub Admin role in the service project to the individuals who administer App Hub. They must have the App Hub Admin role to add service projects to the host project. You need at least one person with this role for each service project. In this example, the host project acts as the service project.

    gcloud projects add-iam-policy-binding SERVICE_PROJECT_ID \
       --member='user:HOST_PROJECT_ADMIN' \
       --role='roles/apphub.admin'

    Replace SERVICE_PROJECT_ID with the name of the HOST_PROJECT_ID.

  3. Grant the Monitoring Viewer role in the host project to the individuals who administer App Hub. They must have the Monitoring Viewer role on the host project to view metrics.

    gcloud projects add-iam-policy-binding SERVICE_PROJECT_ID \
       --member='user:HOST_PROJECT_ADMIN' \
       --role='roles/monitoring.viewer'

Attach a service project

Service projects are Google Cloud projects that contain infrastructure resources that you can register to an App Hub application. For more information, see Service projects. For this tutorial, since we only have a single project, attach the project on which you deployed the resources as the App Hub service project.

Console

  1. In the Google Cloud console, go to the App Hub Settings page.

    Go to Settings

  2. On the Settings page, click Attach projects.

  3. On the pane that opens, search for projects from the displayed list and select the checkboxes for the App Hub service projects.

  4. Click Select. The Attached Service Project(s) table displays the selected host project as the service project.

  5. Click Close.

gcloud

Add your host project as the service project to the App Hub host project.

gcloud apphub service-projects add HOST_PROJECT_ID \
  --project=HOST_PROJECT_ID

After you attach the service project to the App Hub host project, you can view all the Google Cloud resources from the attached service project as discovered App Hub services and workloads. For more information on how to view these discovered services and workloads, see View existing applications, services, and workloads.

Create an application

Create an application to be the container of your services and workloads. When you create an application, you can assign immutable properties such as a scope type or location from which you'd like to register resources and variable attributes such as criticality and environment. You can use the variable attributes to filter the applications. For more information, see Properties and attributes.

In this tutorial, you create a Regional application to manage resources from a specific region. If you have Google Cloud resources in the attached App Hub service projects that are deployed globally or across multiple regions, you can create a Global application and register these resources. For more information on how to create a global application, see Set up App Hub.

Console

  1. Make sure that you're in the App Hub host project.
  2. In the Google Cloud console, go to the App Hub Applications page.

    Go to Applications

  3. Click Create application.

  4. On the Create application page, in the Choose application region and name pane, select Regional.

  5. In the Region list, select us-west1.

  6. In the Application name field, enter tutorial-application. This name is a unique identifier and is immutable after you create the application.

  7. Enter a Display name, Tutorial and click Continue. This is a user-friendly name that you can update. For more information, see Update an existing application.

  8. In the Add attributes pane, from the Criticality list, select High. Criticality indicates how critical an application, service, or workload is to your business operations.

  9. In the Environment field, to indicate the stage of the software lifecycle, select Production.

  10. Click Continue.

  11. In the Add owners pane, add the following details for Developer Owners, Operator Owners, and Business Owners. Note that you must enter the owner's email address if you add a display name.

    1. Enter an owner's display name.
    2. Enter the owner's email address. This value must have the format username@yourdomain, for example, 222larabrown@gmail.com.
  12. Repeat these steps for each developer, operator, and business owner.

  13. Click Create.

The new application gets created and is listed on the Applications page. Note that only the forwarding rule, URL map, backend service, and managed instance group (MIG) become available as discovered resources on the App Hub application. For more information, see concepts and data model.

gcloud

  1. Select the App Hub host project that you created:

    gcloud config set project HOST_PROJECT_ID
  2. Create a new application called tutorial-application in the region, us-west1 and give it a display name, Tutorial. This application name, tutorial-application is a unique identifier and is immutable after you create the application. The display name,Tutorial is a user-friendly name that you can update. For more information, see Update an existing application.

    gcloud apphub applications create tutorial-application \
        --display-name='Tutorial' \
        --scope-type=REGIONAL \
        --project=HOST_PROJECT_ID \
        --location=us-west1
    
  3. List the applications in your App Hub host project:

    gcloud apphub applications list \
        --project=HOST_PROJECT_ID \
        --location=us-west1
    

    You see output similar to the following:

    ID                    DISPLAY_NAME  CREATE_TIME
    tutorial-application  Tutorial      2023-10-31T18:33:48
    
  4. Update your application with the criticality-type, environment-type, and owner attributes:

    gcloud apphub applications update tutorial-application \
      --criticality-type='HIGH' \
      --environment-type='PRODUCTION' \
      --developer-owners=display-name=DISPLAY-NAME-DEVELOPER,email=EMAIL-DEVELOPER \
      --operator-owners=display-name=DISPLAY-NAME-OPERATOR,email=EMAIL-OPERATOR \
      --business-owners=display-name=DISPLAY-NAME-BUSINESS,email=EMAIL-BUSINESS \
      --project=HOST_PROJECT_ID \
      --location=us-west1
    

    Replace the following:

    • DISPLAY-NAME-DEVELOPER, DISPLAY-NAME-OPERATOR, and DISPLAY-NAME-BUSINESS: display names of the developer, operator, and business owners, respectively.
    • EMAIL-NAME-DEVELOPER, EMAIL-NAME-OPERATOR, and EMAIL-NAME-BUSINESS: email addresses of the developer, operator, and business owners, respectively. These values must have the format username@yourdomain, for example, 222larabrown@gmail.com.

    Notes:

    • criticality-type: indicates how critical an application, service, or workload is to your business operations.
    • environment-type: indicates the stages of the software lifecycle.
  5. Get details for the application that you created:

    gcloud apphub applications describe tutorial-application \
      --project=HOST_PROJECT_ID \
      --location=us-west1
    

    The command returns information in YAML format, similar to the following:

    attributes:
    businessOwners:
    – displayName: [DISPLAY-NAME-BUSINESS]
      email: [EMAIL-BUSINESS]
    criticality:
      type: HIGH
    developerOwners:
    – displayName: [DISPLAY-NAME-DEVELOPER]
      email: [EMAIL-DEVELOPER]
    environment:
      type: PRODUCTION
    operatorOwners:
    – displayName: [DISPLAY-NAME-OPERATOR]
      email: [EMAIL-OPERATOR]
    createTime: '2023-10-31T18:33:48.199394108Z'
    displayName: Tutorial
    name: projects/HOST_PROJECT_ID/locations/us-west1/applications/tutorial-application
    scope:
      type: REGIONAL
    state: ACTIVE
    uid: 9d991a9d-5d8a-4c0d-b5fd-85e39fb58c73
    updateTime: '2023-10-31T18:33:48.343303819Z'
    

Register services and workloads

Registering services and workloads adds them to an application that lets you monitor the added resources.

Console

  1. In the Google Cloud console, go to the App Hub Applications page.

    Go to Applications

  2. Click the name of your application, Tutorial. The Services and workloads tab is displayed with a list of registered services and workloads that are in your App Hub service projects.

  3. Register a service:

    1. On the Services and workloads tab, click Register service/workload.
    2. On the Register service or workload page, in the Select resource pane, click Browse to select the service or workload as a Resource.
    3. In the Select resource pane, choose the Name of the service, l7-xlb-backend-service, and click Select.
    4. In the Select resource pane, enter the Name of the resource, tutorial-service-backend.
    5. Enter a Display name, Backend service and click Continue.
    6. In the Add attributes pane, in the Criticality list, to indicate the importance of the application, select High.
    7. In the Environment field, to indicate the stage of the software lifecycle, select Production.
    8. Click Continue.
    9. In the Add owners pane, add the following details as required for Developer Owners, Operator Owners, and Business Owners. Note that you must enter the owner's email address if you add a display name.
      1. Enter an owner's display name.
      2. Enter the owner's email address. This value must have the format username@yourdomain, for example, 222larabrown@gmail.com.
    10. Repeat these steps for each developer, operator, and business owner.
    11. Click Register.

    On the Services and workloads tab, in the Registered services and workloads section, you can see the new service added.

  4. Repeat the previous steps to register the other services as tutorial-service-forwarding-rule and tutorial-service-url-map, respectively.

  5. Register a workload by repeating the earlier steps to register a service with the following exceptions:

    1. In the Register service or workload pane, in the Choose service or workload section, select the Name of the workload, l7-xlb-backend-example, and click Continue.
    2. In the Select resource pane, enter the Name of the resource, tutorial-workload-mig.
    3. Enter a Display name, Workload instance group and click Continue. On the Services and workloads tab, in the Registered services and workloads section, you can see the new workload added.

gcloud

  1. Add an individual with App Hub Editor permissions:

    gcloud projects add-iam-policy-binding HOST_PROJECT_ID \
      --member='user:APP_HUB_EDITOR' \
      --role='roles/apphub.editor'
    

    Replace APP_HUB_EDITOR with the user who has the App Hub Editor role in the App Hub host project. This value has the format username@yourdomain, for example, 222larabrown@gmail.com.

  2. List all discovered services in the App Hub host project. This command returns services that are available to be registered to an application.

    gcloud apphub discovered-services list \
        --project=HOST_PROJECT_ID \
        --location=us-west1
    

    You see output similar to the following:

    ID                             SERVICE_REFERENCE                                                                                                              SERVICE_PROPERTIES
    BACKEND_SERVICE_ID          {'uri': '//compute.googleapis.com/projects/[SERVICE_PROJECT_NUMBER]/regions/us-west1/backendServices/l7-xlb-backend-service'}  {'gcpProject': 'projects/SERVICE_PROJECT_ID', 'location': 'us-west1'}
    FORWARDING_RULE_SERVICE_ID" {'uri': '//compute.googleapis.com/projects/[SERVICE_PROJECT_NUMBER]/regions/us-west1/forwardingRules/l7-xlb-forwarding-rule'}  {'gcpProject': 'projects/SERVICE_PROJECT_ID', 'location': 'us-west1'}
    URL_MAP_SERVICE_ID          {'uri': '//compute.googleapis.com/projects/[SERVICE_PROJECT_NUMBER]/regions/us-west1/urlMaps/regional-l7-xlb-map'}             {'gcpProject': 'projects/SERVICE_PROJECT_ID', 'location': 'us-west1'}
    

    Copy the service IDs, for example, BACKEND_SERVICE_SP2_ID from the output to use in the next step.

  3. Register services from the previous step to your application. Copy the service IDs from the output field in the previous step.

    gcloud apphub applications services create tutorial-service-backend \
        --discovered-service='projects/HOST_PROJECT_ID/locations/us-west1/discoveredServices/BACKEND_SERVICE_ID' \
        --display-name='Backend service' \
        --criticality-type='HIGH' \
        --environment-type='PRODUCTION' \
        --application=tutorial-application \
        --project=HOST_PROJECT_ID \
        --location=us-west1
    
    gcloud apphub applications services create tutorial-service-forwarding-rule \
        --discovered-service='projects/HOST_PROJECT_ID/locations/us-west1/discoveredServices/FORWARDING_RULE_SERVICE_ID' \
        --display-name='Forwarding rule' \
        --criticality-type='HIGH' \
        --environment-type='PRODUCTION' \
        --application=tutorial-application \
        --project=HOST_PROJECT_ID \
        --location=us-west1
    
    gcloud apphub applications services create tutorial-service-url-map \
        --discovered-service='projects/HOST_PROJECT_ID/locations/us-west1/discoveredServices/URL_MAP_SERVICE_ID' \
        --display-name='URL map' \
        --criticality-type='HIGH' \
        --environment-type='PRODUCTION' \
        --application=tutorial-application \
        --project=HOST_PROJECT_ID \
        --location=us-west1
    

    Replace the following:

    • BACKEND_SERVICE_ID: the service ID of the backend service that you want to register.
    • FORWARDING_RULE_SERVICE_ID: the service ID of the forwarding rule that you want to register.
    • URL_MAP_SERVICE_ID: the service ID of the URL map that you want to register.
  4. List all registered services in the application:

    gcloud apphub applications services list \
        --application=tutorial-application \
        --project=HOST_PROJECT_ID \
        --location=us-west1
    

    You see output similar to the following:

    ID                               DISPLAY_NAME      SERVICE_REFERENCE                                                                                                              CREATE_TIME
    tutorial-service-backend         Backend service   {'uri': '//compute.googleapis.com/projects/[SERVICE_PROJECT_NUMBER]/regions/us-west1/backendServices/l7-xlb-backend-service'}  2024-02-13T00:31:45
    tutorial-service-forwarding-rule Forwarding rule   {'uri': '//compute.googleapis.com/projects/[SERVICE_PROJECT_NUMBER]/regions/us-west1/forwardingRules/l7-xlb-forwarding-rule'}  2024-02-13T00:31:45
    tutorial-service-url-map         URL map           {'uri': '//compute.googleapis.com/projects/[SERVICE_PROJECT_NUMBER]/regions/us-west1/urlMaps/regional-l7-xlb-map'}             2024-02-13T00:31:45
    
    Registered, but detached services are denoted by an empty value in the SERVICE_REFERENCE field. For more information on the registration statuses, see the properties and attributes of App Hub.

  5. List all discovered workloads in the App Hub host project. This command returns workloads that are available to be registered to an application.

    gcloud apphub discovered-workloads list \
        --project=HOST_PROJECT_ID \
        --location=us-west1
    

    You see output similar to the following:

    ID                            WORKLOAD_REFERENCE                                                                                                            WORKLOAD_PROPERTIES
    INSTANCE_GROUP_ID          {'uri': '//compute.googleapis.com/projects/[SERVICE_PROJECT_NUMBER]/zones/us-west1-a/instanceGroups/l7-xlb-backend-example'}  {'gcpProject': 'projects/SERVICE_PROJECT_ID', 'location': 'us-west1', 'zone': 'us-west1-a'}
    
    Copy the workload ID from the output to use in the next step.

  6. Register the workloads from the previous step to your application. Copy the workload ID from the output field in the previous step.

    gcloud apphub applications workloads create tutorial-workload-mig \
        --discovered-workload='projects/HOST_PROJECT_ID/locations/us-west1/discoveredWorkloads/WORKLOAD_ID' \
        --display-name='Workload instance group' \
        --application=tutorial-application \
        --project=HOST_PROJECT_ID \
        --location=us-west1
    
    Replace WORKLOAD_ID with the ID of the workload that you want to register.
  7. List all registered workloads in the application:

    gcloud apphub applications workloads list \
        --application=tutorial-application \
        --project=HOST_PROJECT_ID \
        --location=us-west1
    

    You see output similar to the following:

    ID                        DISPLAY_NAME              WORKLOAD_REFERENCE                                                                                                            CREATE_TIME
    tutorial-workload-mig     Workload instance group   {'uri': '//compute.googleapis.com/projects/[SERVICE_PROJECT_NUMBER]/zones/us-west1-a/instanceGroups/l7-xlb-backend-example'}  2024-02-13T00:31:45
    
    Registered, but detached workloads are denoted by an empty value in the WORKLOAD_REFERENCE field. For more information on the registration statuses, see the properties and attributes of App Hub.

View all services and workloads

You can view details of the services and workloads from the service projects that are attached to the App Hub host project.

  1. In the Google Cloud console, go to the App Hub Services and Workloads page.

    Go to Services and Workloads

    All the services and workloads from the attached App Hub service projects are displayed.

  2. In the Region list, select us-west1. The Workload instance group workload is displayed with details such as App Hub Type, Criticality, and Registered to.

  3. To filter the services or workloads based on its state:

    1. In the Filter field, select filters such as Registration status.
    2. Click Registered. A list of services and workloads registered to the application appears.

View application metrics

You can view the system metrics for the applications created in your App Hub host project. These metrics, correspond to the golden signals - traffic, errors, latency, and saturation that help monitor the performance and health of the application.

  1. In the Google Cloud console, go to the App Hub Applications page.

    Go to Applications

  2. Click the name of the application, Tutorial.

    The Services and workloads tab is displayed with the metadata of services and workloads registered to your application.

  3. To view the system metrics of registered services and workloads, click Metrics.

Clean up

To avoid incurring charges to your Google Cloud account for the resources used in this tutorial, either delete the project that contains the resources, or keep the project and delete the individual resources.

Delete the App Hub resources

Console

  1. In the Google Cloud console, go to the App Hub Applications page.

    Go to Applications

  2. Click the name of an application, Tutorial.

  3. On the Services and workloads tab, from the Registered services and workloads section, click the name of a service.

  4. On the Services and Workloads page, click Unregister.

    An alert notifies that the service is unregistered.

  5. On the Services and workloads tab, from the Registered services and workloads section, click the name of a workload.

  6. On the Details tab, click Unregister.

    An alert notifies that the workload is unregistered.

  7. Go to the App Hub Applications page.

    Go to Applications

  8. Click the name of an application.

  9. On the tutorial-application page, click Delete.

  10. In the Google Cloud console, go to the App Hub Settings page.

    Go to Settings

  11. On the Settings page, select the checkbox for the service project that you want to remove from the App Hub host project.

  12. Click Detach projects.

gcloud

  1. List the registered services in the application:

    gcloud apphub applications services list \
      --application=tutorial-application --project=HOST_PROJECT_ID \
      --location=us-west1
    
  2. Unregister the services from the application:

    gcloud apphub applications services delete SERVICE_NAME \
      --application=tutorial-application --project=HOST_PROJECT_ID \
      --location=us-west1
    

    Replace SERVICE_NAME with the name of your service. The services are now discovered services that can be registered to the application.

  3. List the registered workloads in the application:

    gcloud apphub applications workloads list \
      --application=tutorial-application --project=HOST_PROJECT_ID \
      --location=us-west1
    
  4. Unregister the workload from the application:

    gcloud apphub applications workloads delete WORKLOAD_NAME \
      --application=tutorial-application --project=HOST_PROJECT_ID \
      --location=us-west1
    

    Replace WORKLOAD_NAME with the name of your workload. The workload is now a discovered workload that can be registered to the application.

  5. Delete the application:

    gcloud apphub applications delete tutorial-application \
      --project=HOST_PROJECT_ID \
      --location=us-west1
    
  6. Remove the service project from the App Hub host project:

    gcloud apphub service-projects remove SERVICE_PROJECT_ID \
      --project=HOST_PROJECT_ID
    

Delete the deployment

When you no longer need the solution, to avoid continued billing for the resources that you created in this solution, delete all the resources.

Use this procedure if you deployed the solution by using the Terraform CLI.

  1. In Cloud Shell, make sure that the current working directory is terraform-docs-samples/lb/regional_external_http_load_balancer. If it isn't, go to that directory.

  2. Remove the resources that were provisioned by Terraform:

    terraform destroy
    

    Terraform displays a list of the resources that will be destroyed.

  3. When you're prompted to perform the actions, enter yes.

    Terraform displays messages showing the progress. After all the resources are deleted, Terraform displays the following message:

    Destroy complete!
    

When you no longer need the Google Cloud project that you used for the solution, you can delete the project.

Delete the project

Console

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

    Go to Manage resources

  2. In the project list, select the project that you want to delete, and then click Delete.
  3. In the dialog, type the project ID, and then click Shut down to delete the project.

gcloud

Delete a Google Cloud project:

gcloud projects delete PROJECT_ID

Replace PROJECT_ID with the host or service project IDs.

What's next