Skip to content

feat(meshstack): add composition building block - #247

Draft
JohannesRudolph wants to merge 4 commits into
mainfrom
feat/meshstack-composition
Draft

feat(meshstack): add composition building block#247
JohannesRudolph wants to merge 4 commits into
mainfrom
feat/meshstack-composition

Conversation

@JohannesRudolph

Copy link
Copy Markdown
Member

Adds modules/meshstack/composition — a reference implementation of the composition pattern: a building block that provisions meshObjects through the meshStack API with its run's ephemeral API key, rather than cloud resources.

It creates a meshBuildingBlockDefinition in the consuming workspace and a meshBuildingBlock from that definition. Because both are created with the ephemeral key, meshStack records the composition as their creator and surfaces "created by building block" provenance on each — so this module doubles as an end-to-end check of that provenance with no cloud platform involved.

Reuses link rather than inventing an implementation

The created definition runs the hub's link building block. link provisions nothing but a terraform_data and needs neither a cloud provider nor an operator, which keeps the whole chain automatic — no manual step anywhere.

It declares link's input/output wiring inline instead of sourcing modules/meshstack/link as a submodule: a submodule source needs ?ref=${...} interpolation, which requires a const variable, and const values may not come from a runtime building-block input. hub_git_ref is passed as a static input from the composition's own var.hub.git_ref so the created definition clones link from the same hub revision.

Notes for review

  • wait_for_completion = false on the created building block is deliberate. That run is itself a terraform run, and a stack with a single terraform runner cannot start it before this run returns — waiting would deadlock. Provenance is recorded at creation time, so nothing depends on the result.
  • The created definition declares no permissions, keeping it within meshStack's privilege escalation guard.
  • Scorecard: 90% — Core Structure and Integration both 100%; only the optional e2e/ tier is missing. Happy to add one if you'd like it covered by hub CI.
  • tofu fmt and tofu validate clean; terraform-docs generated.

Status

Draft — exercised against a local dev stack, not yet against a shared environment.

🤖 Generated with Claude Code

Reference implementation of the composition pattern: a building block that
provisions meshObjects through the meshStack API with its run's ephemeral API
key rather than cloud resources. It creates a building block definition and a
building block from it, which meshStack attributes to the creating block, so it
doubles as an end-to-end check of that provenance with no cloud platform
involved.

The created definition runs the hub's `link` building block instead of an
implementation of its own — `link` provisions nothing but a terraform_data and
needs neither a cloud provider nor an operator, which keeps the whole chain
automatic.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Scorecard Check

Scorecard run on commit baf72d6c03842a8720447ae21754b9a6bdc74d5a relative to origin/main

📊 meshstack-hub Module Scorecard

Generated: 2026-08-07 | Modules scanned: 1 | Categories: 5

📋 Per-Module Category Summary

Score per category per building block. n/a = category does not apply to this module.

Module Overall Core Structure Integration Azure Backplane STACKIT Backplane Testing
meshstack/composition 🟢 90% 🟢 100% 🟢 100% n/a n/a 🔴 0%

⚠️ 1 module has failing checks — failing categories are expanded below.

Core Structure — ✅ all passing

Basic module file structure and documentation — applies to 1 modules

Module Score 📦 🔗 📋 📝 🖼️ 📌 🔒
meshstack/composition 🟢 100%

Core Structure — Summary

Emoji Criterion Coverage Status
📦 buildingblock/ directory exists 1/1 🟢 100%
🔗 meshstack_integration.tf present 1/1 🟢 100%
📋 buildingblock/APP_TEAM_README.md present (no-integration fallback) n/a
📝 buildingblock/README.md with YAML front-matter 1/1 🟢 100%
🖼️ buildingblock/logo.png included 1/1 🟢 100%
📌 buildingblock/versions.tf present 1/1 🟢 100%
🔒 Provider versions use minimum constraint (>=) 1/1 🟢 100%
Integration — ✅ all passing

meshstack_integration.tf conventions — applies to 1 modules

Module Score 🏷️ 🏢 📤 🔌 📎 🔀 📋 🏷️ 🧱 📖 📝 📊 🚫 🔄
meshstack/composition 🟢 100%

Integration — Summary

Emoji Criterion Coverage Status
🏷️ variable "hub" in integration 1/1 🟢 100%
🏢 variable "meshstack" in integration 1/1 🟢 100%
📤 building_block_definition output exposed 1/1 🟢 100%
🔌 meshcloud/meshstack in required_providers 1/1 🟢 100%
📎 backplane source uses var.hub.git_ref 1/1 🟢 100%
🔀 ref_name uses var.hub.git_ref 1/1 🟢 100%
📋 version_spec.draft uses var.hub.bbd_draft 1/1 🟢 100%
🏷️ BBD metadata.tags forwards var.meshstack.tags 1/1 🟢 100%
🧱 BBD input argument vars with optional() have explicit defaults 1/1 🟢 100%
📖 BBD readme field present 1/1 🟢 100%
📝 BBD readme starts with plain-text description (no heading) 1/1 🟢 100%
📊 BBD readme has shared responsibility table (✅/❌) 1/1 🟢 100%
🚫 No documentation_md output in backplane 1/1 🟢 100%
🔄 meshstack_platform has lifecycle ignore_changes = [availability] n/a
Azure Backplane — not applicable

Azure UAMI-based automation principal conventions — applies to 0 modules

No applicable modules.

STACKIT Backplane — not applicable

STACKIT WIF-based automation principal conventions — applies to 0 modules

No applicable modules.

Testing — some checks failing

End-to-end test coverage — applies to 1 modules

Module Score ⚙️ 🧪
meshstack/composition 🔴 0%

Testing — Summary

Emoji Criterion Coverage Status
⚙️ backplane/ directory (optional tier) n/a
🧪 e2e/ test directory exists 0/1 🔴 0%
e2e/ contains .tftest.hcl files 0/1 🔴 0%

@aws-amplify-eu-central-1

Copy link
Copy Markdown

This pull request is automatically being deployed by Amplify Hosting (learn more).

Access this pull request here: https://pr-247.d1o16zfeoh2slu.amplifyapp.com

JohannesRudolph and others added 3 commits August 7, 2026 17:56
The created definition's version stays DRAFT: releasing needs admin approval,
which the run's ephemeral key — a plain workspace key — cannot obtain. So
draft = false left the version DRAFT anyway and version_latest_release null,
failing the apply with "Attempt to get attribute from null value".

Declare the draft honestly and reference version_latest instead, which a draft
permits because the definition and the building block's target are the same
workspace (BuildingBlockCreationValidator.requireAccess's selfOwning branch).

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
…tinctly

The composition and the objects it created were both called "Composition Demo",
which made the two building block definitions in the panel hard to tell apart.
Name the composition "Composition Demo" and the objects it creates after their
implementation, "Link", via a link_name input defaulting to that.

Renames the `name` input to `link_name` so it pairs with `link_url` and reads as
belonging to the created objects rather than to the composition itself.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Two teardown failures.

link_name had no default, so a destroy run of a building block whose stored
inputs predate the rename from `name` aborted with "No value for required
variable". A destroy only has to delete the created meshObjects, and their
display names have no bearing on that, so default it.

The created definition used deletion_mode = DELETE, which schedules a
deprovisioning run for the created building block on teardown. That run cannot
start until the composition's own destroy run returns, deadlocking wherever the
runner pool has a single worker. PURGE skips it and leaks nothing, since `link`
provisions no infrastructure.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

spec = {
display_name = var.link_name
description = "Link building block definition created by the Composition Demo building block."

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

d: parameterize this already so that it shows some dummy link, for example "this is an element of a composition"

# which satisfies BuildingBlockCreationValidator.requireAccess's `selfOwning` branch.
draft = true

# PURGE, not DELETE: DELETE would schedule a deprovisioning run for the building block below when

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

d: I think that's not fully correct, and just a matter of correct depends_on because tofu doesn't know the BBD -> BB topology inside meshStack

@@ -0,0 +1,96 @@
---
name: Composition Demo

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

d: actually this is a demo of an "architecture composition" which is an advanced use case of compositions. A plain composition is sth like the AKS StarterKit that only deploys application team resources (projects, tenants, building blocks)

This is a "reference architecture" composition that also deploys platform team artifacts like BBDs, (LZs forthcomming) etc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant