← IaC Academy

Reusable projects · 22 / 23

Wire a module into its caller

Use the typed module output to connect Alice to the team without exposing its internals.

YOUR TASK

Make this happen

3 steps
  1. Use module.dispatch.id for the membership teamId.

  2. Keep the existing user lookup and user.alice.id reference.

  3. Inspect the cross-module dependency and simulate.

Read the starter files

main.cococo

module "dispatch" {
  source = "./modules/team"
  inputs = { name = "Fulfillment" }
}

team_membership "alice" {
  teamId = module.dispatch.missing
  userId = user.alice.id
}

modules/team/cococo.module.toml

format = 1

modules/team/main.cococo

input "name" { type = "string" }
team "this" {
  name = input.name
  description = "Ships customer orders"
}
output "id" {
  type = "identity<team>"
  value = team.this.id
}

people.cococo

user "alice" {
  email = "alice@example.com"
}