This recipe will walk you through the process to deploy a Prefect Agent using a GCP Managed Instance Group
- Privileges to create service accounts & instances in GCP
- Terraform CLI Locally
- A Public Subnet with allowed ingress and egress Firewall rules to deploy the instances to or a Private Subnet connected to the internet via a NAT Gateway
- Set your default GCP Project to the Project in which the instance will be deployed to via
gcloud auth application-default login
- Create a VPC and Subnet that have external internet access
- Create a Work Queue in Prefect Cloud that the agent will be associated with
- Run
terraform apply
from your local machine- Pass in requested variables
- Wait for the Work Queue to become
Healthy
in the Prefect Cloud UI (Typically within 5 minutes) - You should now be able to run Deployments against your new Prefect Agent
- Note that the VM has only Docker and Prefect installed by default. Other possible python modules may need to be added by updating the
prefect-agent.sh.tpl
file to include the installation of other python modules.
- Note that the VM has only Docker and Prefect installed by default. Other possible python modules may need to be added by updating the
Name | Version |
---|---|
terraform | ~> 1 |
4.44.1 |
Name | Version |
---|---|
4.44.1 |
Name | Source | Version |
---|---|---|
instance_group | terraform-google-modules/vm/google//modules/mig | 7.9.0 |
instance_template | terraform-google-modules/vm/google//modules/instance_template | 7.9.0 |
Name | Type |
---|---|
google_project_iam_binding.prefect_agent_instance_group | resource |
google_service_account.prefect_agent | resource |
Name | Description | Type | Default | Required |
---|---|---|---|---|
prefect_account_id | prefect cloud account ID | string |
n/a | yes |
prefect_api_key | prefect cloud api key | string |
n/a | yes |
prefect_workspace_id | prefect cloud workspace ID | string |
n/a | yes |
project_id | google cloud project ID | string |
n/a | yes |
region | region to deploy the resources to | string |
n/a | yes |
subnet | subnet to deploy the managed instance group | string |
n/a | yes |
work_queue | prefect cloud work queue name | string |
n/a | yes |
disk_size | Size of the Prefect Agent VM disk | string |
"20" |
no |
disk_type | Disk type to be used by the Prefect Agent VM | string |
"pd-standard" |
no |
machine_type | GCP Machine type to be used for the Prefect Agent VM | string |
"n2d-highcpu-2" |
no |
name_prefix | Prefix for the instance name | string |
"prefect-agent" |
no |
num_vm | Number of deployed VMs in the managed instance group | number |
1 |
no |
preemptible | prefect cloud account ID | bool |
false |
no |
No outputs.