A root module is the composition layer for a product or platform. It chooses versions, names resources, configures providers, and connects outputs. Child modules remain focused, portable, and easy to replace.
platform/main.tf
module "identity" {
source = "pomo-studio/cognito-auth/aws"
}
module "data" {
source = "pomo-studio/dynamodb-global-table/aws"
name = "my-app-users"
hash_key = "id"
attributes = [{ name = "id", type = "S" }]
}
module "api" {
source = "pomo-studio/appsync/aws"
name = "my-app-api"
schema = file("${path.module}/schema.graphql")
cognito_user_pool_arn = module.identity.user_pool_arn
dynamodb_data_sources = {
users = {
table_name = module.data.table_name_primary
table_arn = module.data.table_arn_primary
}
}
}
platform/providers.tf
provider "aws" {
alias = "primary"
region = "us-east-1"
}
provider "aws" {
alias = "dr"
region = "us-west-2"
}
module "events" {
source = "pomo-studio/event-bus/aws"
providers = {
aws.primary = aws.primary
aws.dr = aws.dr
}
enable_dr = true
}