Requirements: Terraform, GCP credentials with permission to create a project Tested with: Terraform v0.12.23, google cloud provider v3.26
You can use an environment variable to set which service account key to use during provisioning export GOOGLE_APPLICATION_CREDENTIALS=/path/to/key
The service account you use must belong to a GCP project that has the necessary APIs enabled (such as billing and resource manager)--if it does not, you may have to enable these APIs manually along the way in those projects
In this directory, run terraform init
then terraform apply
-- you will need to provide a billing_id and organization_id for your GCP project
Once successful, be sure to add the following to your ~/.prefect/config.toml
[server]
endpoint = "YOUR_MACHINES_PUBLIC_IP:4200/graphql"
Also, you may need to run prefect backend server
to interact with Prefect Server instead of Prefect Cloud
Note: Because of odd behaviour of the project services, you may need to run this twice before it passes (terraform sometimes does not wait for the compute engine api to be fully available) That error looks like this:
Error: Error creating Firewall: googleapi: Error 403: Compute Engine API has not been used in project ##### before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/compute.googleapis.com/overview?project=284203841876 then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry., accessNotConfigured
on gcloud.tf line 57, in resource "google_compute_firewall" "default":
57: resource "google_compute_firewall" "default" {
In order to access the server from outside, the last line of the
startup.sh
script should be: