Domain-Oriented Ownership
resource "aws_glue_catalog_database" "domain_data" {
name = "customer-domain"
catalog_id = aws_glue_catalog_table.customer_data.catalog_id
tags = {
Domain = "Customer"
Owner = "customer-team"
DataProduct = "true"
}
}
resource "aws_lake_formation_permissions" "domain_access" {
principal = aws_iam_role.domain_team.arn
permissions = ["CREATE_TABLE", "ALTER", "DROP"]
database {
name = aws_glue_catalog_database.domain_data.name
}
}
resource "azurerm_synapse_workspace" "data_product" {
name = "customer-insights"
resource_group_name = azurerm_resource_group.data_mesh.name
location = azurerm_resource_group.data_mesh.location
storage_data_lake_gen2_filesystem_id = azurerm_storage_data_lake_gen2_filesystem.data_mesh.id
identity {
type = "SystemAssigned"
}
tags = {
DataProduct = "CustomerInsights"
Domain = "Customer"
Owner = "customer-analytics"
}
}
resource "google_bigquery_dataset" "federated_view" {
dataset_id = "customer_federation"
location = "US"
access {
role = "READER"
user_by_email = "domain-team@example.com"
}
labels = {
environment = "production"
federation = "true"
}
}
resource "google_bigquery_routine" "data_contract" {
dataset_id = google_bigquery_dataset.federated_view.dataset_id
routine_id = "customer_contract"
language = "SQL"
definition_body = <<-SQL
CREATE OR REPLACE VIEW customer_federation.customer_360 AS
SELECT
c.customer_id,
c.profile,
o.order_history,
p.preferences
FROM customer_domain.profiles c
JOIN orders_domain.history o USING (customer_id)
JOIN preferences_domain.settings p USING (customer_id)
SQL
}