What Formal Discovers
Cloud SQL Autodiscovery
Cloud SQL Autodiscovery
Discover Cloud SQL for PostgreSQL and MySQL instances and add them as Formal
resources.
GKE Autodiscovery
GKE Autodiscovery
Discover GKE clusters for Kubernetes access control. Clusters need a public
endpoint to be discovered.
Compute Engine Autodiscovery
Compute Engine Autodiscovery
Discover Compute Engine instances for SSH access.
Cloud Storage Log Delivery
Cloud Storage Log Delivery
Write logs to GCS buckets through a
Log Forwarding.
Pub/Sub Log Delivery
Pub/Sub Log Delivery
Publish logs to Pub/Sub topics through a
Log Forwarding.
Architecture
Theterraform-formal-gcp module enables the required APIs (IAM, STS, IAM Credentials, Cloud Resource Manager) and creates:
- Workload Identity Pool: a pool with an AWS-type provider that trusts Formal’s AWS account
- Attribute Condition: pins Formal’s per-integration role ARN, so only that exact role can exchange a token
- Service Account: the identity Formal impersonates in your project
- Custom Role: a single role holding only the permissions the capabilities you enable actually use, such as
compute.instances.list,container.clusters.list, andcloudsql.instances.listfor discovery, andstorage.objects.createorpubsub.topics.publishfor log delivery, granted to the service account
Setup
- Control Plane
- Terraform
1
Navigate to Cloud Accounts
Go to Cloud Accounts
2
Create Integration
Click Create Integration and choose GCP
3
Enter Details
Enter a name and the Google Cloud project ID to connect
4
Choose Discovery
Toggle autodiscovery for Compute Engine, GKE, and Cloud SQL. All are on by default.
5
Configure GCS Access
To deliver logs to Cloud Storage, enable GCS log writes. Leave the bucket list empty to allow every bucket in the project, or name specific buckets to scope access.
6
Configure Pub/Sub Access
To publish logs to Pub/Sub, enable Allow Pub/Sub log publishing. Leave the topic list empty to allow every topic in the project, or name specific topics to scope access.
7
Run the Setup Command
Formal shows a command with your integration ID and security key filled in. Paste it into an authenticated Cloud Shell for that project:It fetches the setup parameters from Formal, runs
terraform apply, then reports the service account and workload identity pool provider back to Formal, which activates the integration.Cloud Storage Log Delivery
To forward logs to GCS, the integration needs Cloud Storage access. Enable it when creating the integration with two settings:
Formal grants matching IAM: a project-wide
storage.objects.create permission in the custom role when the bucket list is empty, or per-bucket IAM bindings when you restrict it.
Once access is granted, configure Log Forwarding for a bucket to start forwarding logs.
Pub/Sub Log Delivery
To publish logs to Pub/Sub, the integration needs Pub/Sub access. Enable it when creating the integration with two settings:
Formal grants matching IAM: a project-wide
pubsub.topics.publish permission in the custom role when the topic list is empty, or roles/pubsub.publisher on each topic when you restrict it.
Once access is granted, configure Log Forwarding for a topic to start forwarding logs.
Security
- Federated, keyless: no service account keys are created or stored.
- Pinned role: the pool’s attribute condition trusts only Formal’s exact per-integration role ARN.
- Least privilege: through one custom role, the service account gets only the permissions the capabilities you enable actually use, plus read access to the project’s own metadata for connection verification.
- Bucket scoping: restrict
gcs_bucketsso Formal can write only to the buckets you name. - Topic scoping: restrict
pubsub_topicsso Formal can publish only to the topics you name.
Troubleshooting
Setup command fails
Setup command fails
Possible causes:
- The Cloud Shell is not authenticated to the target project
- The account lacks permission to enable APIs or create IAM resources
- The integration ID or security key is wrong
- Run
gcloud config set project <PROJECT_ID>in the Cloud Shell - Ensure the account has
roles/owneror an equivalent set of IAM and Service Usage roles - Copy the exact command Formal shows when you create the integration
Resources not discovered
Resources not discovered
Possible causes:
- Autodiscovery disabled for that resource type
- GKE cluster has no public endpoint
- Cloud SQL instance is neither PostgreSQL nor MySQL
- Service account missing the viewer role
- Verify the discovery toggle is enabled on the Cloud Account
- Confirm the cluster exposes a public endpoint
- Re-run the setup command so the module grants the viewer roles
- Wait a few minutes for the initial scan
GCS log forwarding not working
GCS log forwarding not working
Possible causes:
- Cloud Storage access not enabled on the integration
- The target bucket is not in the
gcs_bucketsallowlist - Log integration not configured
- Confirm
allow_gcs_accessis enabled on the Cloud Account - Add the bucket to
gcs_buckets, or leave the list empty to allow all buckets - Configure Log Forwarding for this cloud integration
Pub/Sub log forwarding not working
Pub/Sub log forwarding not working
Possible causes:
- Pub/Sub access not enabled on the integration
- The target topic is not in the
pubsub_topicsallowlist - Log integration not configured
- Confirm
allow_pubsub_accessis enabled on the Cloud Account - Add the topic to
pubsub_topics, or leave the list empty to allow all topics - Configure Log Forwarding for this cloud integration
Next Steps
Log Forwarding
Forward logs to Cloud Storage or Pub/Sub
Add Resources
Manually configure discovered resources
Terraform
Manage integrations as code
View Resources
See all autodiscovered resources