If you find this project helpful, please consider giving ZenML a star on GitHub. Your support helps promote the project and lets others know it's worth checking out.
Thank you for your support! 🌟
This Terraform module sets up the necessary GCP infrastructure for a ZenML stack. It provisions various GCP services and resources, and registers a ZenML stack using these resources with your ZenML server, allowing you to create an internal MLOps platform for your entire machine learning team.
- Terraform installed (version >= 1.9")
- GCP account set up
- To authenticate with GCP, you need to have the
gcloud
CLI installed on your machine and you need to have rungcloud init
orgcloud auth login
to set up your credentials. - ZenML (version >= 0.62.0) installed and configured. You'll need a Zenml server deployed in a remote setting where it can be accessed from GCP. You have the option to either self-host a ZenML server or register for a free ZenML Pro account.
The Terraform module in this repository creates the following resources in your GCP project:
- a GCS bucket
- a Google Artifact Registry
- a Cloud Composer environment (only if the
orchestrator
variable is set toairflow
) - a Service Account with the minimum necessary permissions to access the GCS bucket, the Google Artifact Registry and the GCP project to build and push container images with Google Cloud Build, store artifacts and run pipelines with Vertex AI, SkyPilot or GCP Cloud Composer.
- depending on the target ZenML Server capabilities, different authentication methods are used:
- for a self-hosted ZenML server, a Service Account Key is generated and shared with the ZenML server
- for a ZenML Pro account, GCP Workload Identity Federation is used to authenticate with the ZenML server, so that no sensitive credentials are shared with the ZenML server. For this, a GCP Workload Identity Pool and a GCP Workload Identity Provider are created and linked to the GCP Service Account. There's only one exception: when the SkyPilot orchestrator is used, this authentication method is not supported, so the Service Account Key is used instead.
The Terraform module automatically registers a fully functional GCP ZenML stack directly with your ZenML server. The ZenML stack is based on the provisioned GCP resources and is ready to be used to run machine learning pipelines.
The ZenML stack configuration is the following:
- an GCP Artifact Store linked to the GCS bucket
- an GCP Container Registry linked to the Google Artifact Registry
- depending on the
orchestrator
input variable:
- a local Orchestrator, if
orchestrator
is set tolocal
. This can be used in combination with the Vertex AI Step Operator to selectively run some steps locally and some on Vertex AI. - a Vertex AI Orchestrator linked to the GCP project, if
orchestrator
is set tovertex
(default) - a SkyPilot Orchestrator linked to the GCP project, if
orchestrator
is set toskypilot
- an Airflow Orchestrator linked to the Cloud Composer environment, if
orchestrator
is set toairflow
- a Google Cloud Build Image Builder linked to the GCP project
- a Vertex AI Step Operator linked to the GCP project
- a GCP Service Connector configured with the GCP service account credentials or the GCP Workload Identity Provider configuration and used to authenticate all ZenML components with the GCP resources
To use the ZenML stack, you will need to install the required integrations:
- for Vertex AI:
zenml integration install gcp
- for SkyPilot:
zenml integration install gcp skypilot_gcp
- for Airflow:
zenml integration install gcp airflow
To use this module, aside from the prerequisites mentioned above, you also need to create a ZenML Service Account API key for your ZenML Server. You can do this by running the following command in a terminal where you have the ZenML CLI installed:
zenml service-account create <service-account-name>
module "zenml_stack" {
source = "zenml-io/zenml-stack/gcp"
project_id = "your-gcp-project-id"
region = "europe-west1"
orchestrator = "vertex" # or "skypilot" or "airflow"
zenml_server_url = "https://your-zenml-server-url.com"
zenml_api_key = "ZENKEY_1234567890..."
}
output "zenml_stack_id" {
value = module.zenml_stack.zenml_stack_id
}
output "zenml_stack_name" {
value = module.zenml_stack.zenml_stack_name
}
ZenML Documentation ZenML Starter Guide ZenML Examples ZenML Blog
If you need assistance, join our Slack community or open an issue on our GitHub repo.
Features · Roadmap · Report Bug · Sign up for ZenML Pro · Read Blog · Contribute to Open Source · Projects Showcase