Skip to content

Connect Google Cloud (GCP)

A Mayadyn connection to Google Cloud works in one project, as one service account. There are two ways to connect:

  • Keyless (recommended): Workload Identity Federation. Your project trusts Mayadyn’s OpenID issuer (https://id.mayadyn.com) for this one connection, and lets that identity act as your service account. Mayadyn stores no key.
  • Service account key. You download a JSON key and give it to Mayadyn, which stores it encrypted.

Both need the Compute Engine API enabled in the project.

  • The project ID (e.g. acme-prod) and the project number (digits, shown on the project’s dashboard).
  • A service account in the project for Mayadyn to act as, e.g. mayadyn@acme-prod.iam.gserviceaccount.com. Create one under IAM & Admin → Service accounts if you do not have one. Do not create a key for it.
  • Names for a Workload Identity pool and provider, each 4 to 32 lowercase letters, digits or dashes (e.g. mayadyn and mayadyn-oidc). You choose them now; the trust steps create them.
  • gcloud with rights to create Workload Identity pools and to change IAM policies in the project.
  • The admin scope in Mayadyn.

The Workload Identity provider field is the full name of the provider the steps will create:

projects/<project number>/locations/global/workloadIdentityPools/<pool>/providers/<provider>

Console

  1. Open Cloud accounts and choose Connect account.
  2. Pick Google Cloud, enter a Name (e.g. gcp-dammam) and the Default region (e.g. me-central2).
  3. Keep Keyless. Enter Project ID, Workload Identity provider and Service account.
  4. Choose Connect account. The Trust steps dialog opens.

CLI

Terminal window
cat > gcp-keyless.json <<'EOF'
{"type": "mayadyn_federated",
"project_id": "acme-prod",
"workload_provider": "projects/123456789012/locations/global/workloadIdentityPools/mayadyn/providers/mayadyn-oidc",
"service_account": "mayadyn@acme-prod.iam.gserviceaccount.com"}
EOF
mayadyn connections add --provider gcp --name gcp-dammam --region me-central2 --credentials gcp-keyless.json
mayadyn connections setup gcp-dammam

Only these four fields are accepted; anything else is refused.

The connection shows Needs fixing until you finish step 2. That is expected.

Step 2: run the trust steps in your project

Section titled “Step 2: run the trust steps in your project”

The Trust steps dialog (or mayadyn connections setup <name>) shows the Issuer, the Trusted subject, the Audience, and the exact commands for your connection. They have this shape:

Terminal window
gcloud iam workload-identity-pools create <pool> --project=<project id> --location=global --display-name="Mayadyn"
gcloud iam workload-identity-pools providers create-oidc <provider> --project=<project id> --location=global --workload-identity-pool=<pool> --issuer-uri=https://id.mayadyn.com --allowed-audiences=//iam.googleapis.com/projects/<project number>/locations/global/workloadIdentityPools/<pool>/providers/<provider> --attribute-mapping="google.subject=assertion.sub" --attribute-condition="assertion.sub == 'mayadyn:<workspace id>:<connection id>'"
gcloud iam service-accounts add-iam-policy-binding <service account> --project=<project id> --role=roles/iam.workloadIdentityUser --member="principal://iam.googleapis.com/projects/<project number>/locations/global/workloadIdentityPools/<pool>/subject/mayadyn:<workspace id>:<connection id>"
gcloud projects add-iam-policy-binding <project id> --member=serviceAccount:<service account> --role=roles/compute.instanceAdmin.v1

Then choose Check on the connection (or mayadyn connections verify <name>). It should turn Working.

Notes the steps come with:

  • The pool and provider must be in the project whose number is in workload_provider.
  • Your first machine also needs roles/compute.networkAdmin and roles/compute.securityAdmin on the service account, because Mayadyn creates the mayadyn network and its firewall rules. You may remove them afterwards.
  • Only the subject mayadyn:<workspace id>:<connection id> is trusted. No other Mayadyn workspace or connection can use this trust.
Step Effect
Create the pool A container for external identities in your project.
Create the OIDC provider Trusts tokens from https://id.mayadyn.com, only with this connection’s audience, and only when the token’s subject is this connection’s subject.
workloadIdentityUser binding Lets that one subject act as your service account.
compute.instanceAdmin.v1 binding Lets the service account manage Compute Engine instances in the project.

Mayadyn’s tokens for this trust are short-lived and are created only when Mayadyn opens this connection.

Role When
roles/compute.instanceAdmin.v1 Always.
roles/compute.networkAdmin The first time (creates the mayadyn network).
roles/compute.securityAdmin The first time (creates the firewall rules).

Delete the provider, or remove the roles/iam.workloadIdentityUser binding for the subject. Google then refuses Mayadyn’s tokens, and the connection fails its checks with auth_failed: “The project’s Workload Identity trust for this connection is missing, changed or was removed.”

Code Meaning Fix
auth_failed Google did not accept Mayadyn’s token: the pool, provider, audience, condition or binding is missing or different. Run mayadyn connections setup <name> (or Trust steps), apply the steps, then check again.
permission_denied The service account lacks a role, or the Compute Engine API is off. Grant roles/compute.instanceAdmin.v1 (and networkAdmin/securityAdmin for first use), and enable the Compute Engine API.
invalid_input A field has the wrong shape, or the project cannot use the default region. Fix the value. The message lists the regions the project can use.

Service account key: connect with a stored key

Section titled “Service account key: connect with a stored key”
  1. Create a service account in the project (or pick one).
  2. Grant it roles/compute.instanceAdmin.v1, plus roles/compute.networkAdmin and roles/compute.securityAdmin for the first machine.
  3. Create a JSON key: IAM → Service accounts → Keys → Create JSON key.

Console: Cloud accounts → Connect account → Google Cloud, pick Stored key, and paste the whole file into Service account key (JSON).

CLI:

Terminal window
mayadyn connections add --provider gcp --name gcp-dammam --region me-central2 --credentials key.json

Use the key file exactly as Google issued it. A key whose token_uri is not https://oauth2.googleapis.com/token, or whose universe is not googleapis.com, is refused.

Credentials are encrypted and never shown again. Every use is recorded in the audit log (“Used account credentials”).

Code Hint Mayadyn gives
auth_failed “The service account key is invalid or was deleted; create a new key.”
permission_denied “Grant the service account roles/compute.instanceAdmin.v1 (and networkAdmin/securityAdmin for first use), and enable the Compute Engine API.”
invalid_input “Create a key for a service account (IAM → Service accounts → Keys → JSON) and send the whole file.”

Use Replace credentials with keyless values for the same project, run the trust steps, check, then delete the service account key in Google Cloud. See Replace credentials.

The console offers these GCP regions first: me-central2 (Dammam), me-central1 (Doha), europe-west3 (Frankfurt), europe-west2 (London), us-east4 (Ashburn), us-central1 (Iowa). Other regions work if your project can use them.

GCP machines live in zones. When you give a region (me-central2), Mayadyn uses its -a zone (me-central2-a). Give a zone (me-central2-b) to use that zone.