Skip to main content

Connect Google Cloud

As an organization owner, you connect Google Cloud to Multicloud. You download one file, multicloud.tf, and you run terraform apply. Terraform creates a new Google Cloud project for Multicloud. Then the Console shows the project as verified, and your pools can run in it. It takes about five minutes.

Multicloud signs in to the project through workload identity federation. There is no service account key and no password. You keep the project, the bill and the quota.

A new project for Multicloud

The Terraform module creates a new project. It does not use an existing project. Multicloud chooses the project ID (mc- and 10 characters). Your billing account pays for the machines in the project, as for any other project. Your other projects stay as they are.

What Multicloud can do in the project

Everything below applies to the new project only.

  • It can create, change and delete machines, disks and networks (Compute Engine) in the project.
  • It can set the firewall rules and the tags of its own machines in the project.
  • It has no access to your other projects, your storage buckets, your databases or your users.
  • There is no service account key. Only Multicloud can use the access.

The exact permissions are in the public module source.

What you need

  • You are an owner of the organization. Members can see the accounts, but they cannot connect one.
  • Terraform or OpenTofu 1.6 or later, and curl. On Windows, use WSL.
  • The Google Cloud CLI (gcloud), signed in with a Google account that has these roles:
    • Billing Account User (roles/billing.user) on the billing account.
    • Project Creator (roles/resourcemanager.projectCreator) on the folder or the organization of the new project.
  • The ID of the billing account. Run gcloud billing accounts list --filter=open=true, or open the billing page of the Google Cloud console.
  • The folder or the organization of the new project, as folders/NUMBER or organizations/NUMBER. Run gcloud organizations list, then gcloud resource-manager folders list --organization=ORGANIZATION_ID. A folder only for Multicloud is best. A personal Google account without an organization needs no folder.

Run this command once, so that Terraform can use your Google login:

gcloud auth application-default login

Connect a project

  1. In the Console, open Organization → Cloud accounts.

  2. Click Connect a cloud, then Connect a new Google Cloud project, then Continue.

  3. Enter the billing account ID.

  4. Choose where the new project lives: in a folder or an organization (enter folders/NUMBER or organizations/NUMBER), or I have no organization.

    The page writes both values into the file. They are not secret, and Multicloud does not receive them.

  5. Click Download multicloud.tf. Put the file in an empty folder.

  6. Copy the connect token. In that folder, run this command, paste the token and press Enter:

    read -rs TF_VAR_multicloud_connect_token && export TF_VAR_multicloud_connect_token
    

    Nothing shows while you paste. That is normal.

  7. In the same terminal window, run:

    terraform init && terraform apply
    

    Type yes when Terraform asks. A new project takes two to five minutes. With OpenTofu, use tofu in place of terraform.

The page shows the connect token once. It works for one connect, until the time the page shows. Do not save it in a file. multicloud.tf holds no secret.

Wait for the check

After the apply, Multicloud checks the access.

  • Waiting for terraform apply: Multicloud has not heard from Terraform yet. Run the apply, or wait for it to finish.
  • Waiting for Google Cloud: Terraform created the project and the access, but Google has not made the access work yet. This can take a few minutes. This is normal, not an error. For about 15 minutes the page checks again every 30 seconds. You can also click Verify now.
  • Verified: Multicloud can start machines in the project. Create a pool to use it.
  • An owner must approve this account: the first check found that the project is older than the connection or already runs machines. The project connects after an owner of the organization approves the shared use. A new, empty project is strongly recommended.

If something goes wrong

  • The check failed. The page shows the reason. Fix what the reason names, run terraform apply again in the same folder, then click Verify now.
  • Terraform reports that a value is not valid. Check the billing account ID (012345-6789AB-CDEF01) and the parent (folders/NUMBER or organizations/NUMBER) in multicloud.tf.
  • Terraform reports an organization policy error. A policy of your organization blocks the setup. Ask your Google Cloud administrator to allow workload identity pools with an AWS provider (constraints/iam.workloadIdentityPoolProviders and constraints/iam.workloadIdentityPoolAwsAccounts).
  • The token expired, or you closed the page before the apply. Click New connect token on the project in the list. Enter the billing account and the parent again, download the file again, and run the apply with the new token.
  • Terraform asks for var.multicloud_connect_token. The token command ran in another terminal window, or did not run. Paste the token at the prompt, or run the token command in this window and run the apply again.

Command line

The mctl cloud-account commands do the same steps from a terminal. mctl cloud-account create --cloud GCE writes multicloud.tf; fill in billing_account and parent yourself. Then mctl cloud-account apply <id> gets the connect token and runs the apply.

Remove access

  1. Delete your pools in the Console first.
  2. Run terraform destroy in the folder with multicloud.tf. This deletes the project and the access. Multicloud cannot use it again.