This Terraform module deploys infrastructure for Masthead Data to monitor Google Cloud services (BigQuery, Dataform, Dataplex, Analytics Hub) using Pub/Sub topics, Cloud Logging sinks, and IAM bindings.
The module supports two deployment modes:
For single-project setups. All resources (logs, Pub/Sub, IAM) are created in a monitored project.
Use when: You have a single project or a few projects to monitor.
For multi-project or folder-level monitoring. Creates centralized Pub/Sub infrastructure in a dedicated deployment project with folder-level and/or project-level log sinks.
Supports:
- One or more GCP folders (monitors all child projects)
- Additional individual projects (outside of folders)
- Any combination of folders and projects
Use when: You want to monitor multiple projects, use GCP folders, or need centralized log collection.
module "masthead_agent" {
source = "masthead-data/masthead-agent/google"
version = ">=0.3.0"
# Project mode: single project
project_id = "project-1"
}module "masthead_agent" {
source = "masthead-data/masthead-agent/google"
version = ">=0.3.0"
# Organization mode: folders + additional projects
monitored_folder_ids = [
"folders/111111111",
"folders/222222222"
]
monitored_project_ids = [
"project-1",
"project-2"
]
deployment_project_id = "project-3"
organization_id = "123456789" # Required for custom IAM roles on folders
labels = {
environment = "production"
}
}Complete configuration with all options:
module "masthead_agent" {
source = "masthead-data/masthead-agent/google"
version = ">=0.3.0"
# Choose ONE mode:
# PROJECT MODE: Set project_id only
project_id = var.project_id
# ORGANIZATION MODE: Set deployment_project_id + folders and/or projects
# deployment_project_id = var.deployment_project_id
# monitored_folder_ids = ["folders/123456789"] # Optional: monitor folders
# monitored_project_ids = ["project-1", "project-2"] # Optional: monitor specific projects
# organization_id = "123456789" # Required when using folders
# Module configuration
enable_modules = {
bigquery = true
dataform = true
dataplex = true
analytics_hub = true
}
# Optional features
enable_apis = true
enable_privatelogviewer_role = true # For retrospective log export
enable_datascan_editing = false # Dataplex DataScan editing permissions
# Labels for governance and cost management
labels = {
environment = "production"
team = "data"
cost_center = "engineering"
monitoring = "masthead"
}
}βββββββββββββββββββββββββββββββββββββββ
β Single GCP Project β
β β
β ββββββββββββββββ βββββββββββββββ β
β β Log Sinks ββ β Pub/Sub β β
β β (Project) β β Topics β β
β ββββββββββββββββ βββββββββββββββ β
β β β β
β ββββββββββββββββββββββββββββββββ β
β β IAM Bindings β β
β ββββββββββββββββββββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββ
ββββββββββββββββββββββββββββββββββββββββββ
β GCP Folder(s) (optional) β
β ββββββββββββββββββββββββββββββββββββ β
β β All Child Projects β β
β ββββββββββββββββββββββββββββββββββββ β
β β β
β ββββββββββββββββββββββββββββββββββββ β
β β Folder-Level Log Sinks β β
β β + IAM Bindings (inherited) β β
β ββββββββββββββββββββββββββββββββββββ β
ββββββββββββββββββββββββββββββββββββββββββ
β
ββββββββββββββββββββββββββββββββββββββββββ
β Additional Projects (optional) β
β ββββββββββββββββββββββββββββββββββββ β
β β Project-Level Log Sinks β β
β β + IAM Bindings β β
β ββββββββββββββββββββββββββββββββββββ β
ββββββββββββββββββββββββββββββββββββββββββ
β
ββββββββββββββββββββββββββββββββββββββββββ
β Deployment Project β
β ββββββββββββββββββββββββββββββββββββ β
β β Centralized Pub/Sub Topics β β
β β + Subscriptions β β
β ββββββββββββββββββββββββββββββββββββ β
ββββββββββββββββββββββββββββββββββββββββββ
- IAM bindings applied at the project level
- Log sinks created at the project level
- All resources in one project
- For folders: IAM bindings applied at folder level (inherited by all child projects)
- For folders: Log sinks created at folder level
- For additional projects: IAM bindings and log sinks applied at project level
- Centralized Pub/Sub in deployment project
You need these permissions in the target project:
logging.sinks.createpubsub.topics.createpubsub.subscriptions.createiam.serviceAccounts.setIamPolicyresourcemanager.projects.setIamPolicy
When using folders, you need these permissions at the folder level:
logging.sinks.create(on folder)resourcemanager.folders.setIamPolicy(on folder)
When using folders, you need these permissions at the organization level:
iam.roles.create(on organization) - Required for creating custom IAM roles
Always required for the deployment project:
pubsub.topics.createpubsub.subscriptions.createiam.serviceAccounts.setIamPolicyresourcemanager.projects.setIamPolicy