Terraform Remote Backend
We want to store the terraform state files with the GCP project itself. This has several advantages:- The state files are stored in a central location, making it easier for multiple users to collaborate on the same project.
- The state files are stored securely in GCP, reducing the risk of data loss.
- One human can work on multiple deployments at the same time, by having one codebase and updating the project id environment variable.
main.tf
file in the repository:
Configuration and Deployment
We are using terraform to setup the backend. We will also be hosting the terraform state inside the project itself by using a remote backend. The configuration is passed on the command line since we want to use the project-id in the bucket name. Since the project-ids are globally unique, so will the storage bucket name.Cloud Function Backend
First create a file that will contain the LOOKER_AUTH_TOKEN and place it at the root. This will be used by the cloud function locally, as well as the extension framework app. The value of this token will uploaded to the GCP project as secret to be used by the Cloud Function. If in the/explore-assistant-backend
cd back to root (ie. cd ..
) and run the following command:
/explore-assistant-backend
directory run the following.
To deploy the Cloud Function backend:
BigQuery Backend
To deploy the BigQuery backend:Deployment Notes
- Changes to the code in
explore-assistant-cloud-function
will result in a zip file with a new hash. This hash is added to the environment variables for the cloud function, and a new hash will trigger the redeployment of the cloud function.
Resources Created
- Google Cloud Functions or Cloud Run services, based on the selected backend.
- Google BigQuery dataset and table to store the examples
- Google BigQuery connection and gemini pro model, if using the BigQuery backend.
- Necessary IAM roles and permissions for the Looker Explore Assistant to operate.
- Storage buckets for deploying cloud functions or storing data.
- Artifact Registry for storing Docker images, if required.