Connecting Bundles
Welcome to part 2 of the Massdriver getting started guide! In part 1, you learned how to publish, configure, and deploy a bundle. Now you'll learn how to connect bundles together to share information between them using resources - one of Massdriver's most powerful features.
What You'll Learn
By the end of this guide, you'll understand:
✅ What resources are - How bundles share data with each other
✅ Resource types - The versioned schema contracts that ensure type safety
✅ Publishing resource types - Making reusable data contracts available
✅ Producing resources - Updating bundles to output structured resource data
✅ Consuming resources - Declaring dependencies on resources from other bundles
✅ Bundle connections - Connecting bundles visually in the UI
Understanding Resources and Resource Types
What Are Resources?
Resources are structured JSON outputs that bundles produce to share data with other bundles. Think of them as the "public API" of your infrastructure - they expose specific data that other bundles can consume. This is managed via two fields in the massdriver.yaml file:
- Bundles produce the resources that are declared in the
resourcesblock - Bundles consume the resources that are declared in the
dependenciesblock
What Are Resource Types?
Resource types are JSON Schema specifications that define the structure and type of data that resources must contain. They create an enforceable "contract" between bundles:
- Bundles which produce resources are guaranteed to output JSON that matches the resource type schema
- Bundles which consume resources are guaranteed to receive JSON that matches the expected resource type schema
Resource types are versioned. A bundle that produces a resource pins the exact version it emits, and a bundle that consumes one names the range of versions it accepts. That is how the contract can evolve without breaking the bundles already wired to it.
Resource types are not paired 1-to-1 with bundles. This is intentional. Consider:
- You might have one
aws-s3-bucketresource type which contains information relevant to an S3 bucket - But multiple bundles that create different S3 buckets (logging bucket, data lake bucket, CloudFront bucket)
- All these bundles produce the same S3 resource type
This separation allows for reusable contracts across your infrastructure ecosystem. Massdriver also maintains a set of resource types which are used by our own internal bundles and public bundle templates. These resource types are available to re-use in your own bundles, or modify and republish as your own.
Step 1: Create and Publish a Resource Type
First, you'll publish a resource type that describes the data produced by the getting-started bundle from the previous guide.
Navigate to the Resource Types Directory
- In the
getting-startedrepository, you should see aresource-typesdirectory - Inside, you'll find a
getting-starteddirectory containing amassdriver.yamlthat defines the schema for your bundle's outputs
Examine the Resource Type
Open resource-types/getting-started/massdriver.yaml and examine its structure:
name: getting-started
version: 1.0.0
label: Getting Started
schema:
title: Getting Started
description: A basic example of a resource type, paired with the getting-started bundle from part 1.
type: object
additionalProperties: false
required:
- data
properties:
data:
title: Resource Data
type: object
required:
- pet-name
- password
- shuffle
properties:
pet-name:
title: Pet Name
description: The generated pet name
type: string
password:
title: Password
description: The generated password
type: string
$md.sensitive: true
shuffle:
title: Shuffle
description: The shuffled words
type: array
items:
type: string
Some key points:
nameis the identifier other bundles use to reference the resource type. Within your own organization you refer to it simply asgetting-started.versionis the semantic version of this contract. Publishing is immutable: once1.0.0exists it can never be overwritten, so you bump the version to change the contract.labelis the human-friendly name shown in the Massdriver UI.schemais a JSON Schema describing the resource payload. Here everything lives under a singledataobject with apet-namestring, apasswordstring, and a list of strings calledshuffle. All three arerequired.$md.sensitivemarks the password so it is masked in the UI and API responses.
The massdriver.yaml format also supports onboarding instructions, downloadable export templates, and UI placement. See the Resource Type Spec for the complete reference.
Publish the Resource Type
From your getting-started repository root, run:
mass resource-type publish resource-types/getting-startedConfirm it published by fetching it back:
mass resource-type get getting-started
Because the resource type lives in your organization, your bundles can reference it by name alone. No organization prefix is needed.
Step 2: Update getting-started Bundle to Produce a Resource
Now you'll modify your getting-started bundle from the previous guide to produce a resource of the type you just published.
Update the Bundle Configuration
Navigate to your
01-deployingdirectoryOpen
massdriver.yamlFind the commented
resources:section and uncomment it:resources:
your_first_resource:
resource_type: getting-started@1.0.0
required: true
The bundle pins the exact resource type version it produces, 1.0.0. required: true means the bundle always creates this resource.
Update the Resource Output
Open
src/resources.tfUncomment the
massdriver_resourceresource:resource "massdriver_resource" "example" {
field = "your_first_resource"
name = "A human friendly name. This is the resource for ${var.md_metadata.name_prefix}"
resource = jsonencode({
data = {
pet-name = random_pet.name.id
password = random_password.password.result
shuffle = random_shuffle.shuffle.result
}
})
}
You'll notice the structure of the resource field matches the schema: a top-level data object with pet-name, password and shuffle nested under it. The field value matches the key you declared under resources in massdriver.yaml.
Republish and Redeploy
Publish the updated bundle:
mass bundle publishIn the Massdriver UI, navigate to the project from the previous guide that has
getting-starteddeployed.Notice: Your bundle now has a connection port on the right side!
Click on the
getting-startedbundle, and deploy it from the config tab so it will run the OpenTofu and create the new resource.Explore: Click on the "Resources" tab to view and download the produced resource
Step 3: Deploy the Connecting Bundle
Now you'll deploy a second bundle that consumes a getting-started resource.
Declare the Dependency
Navigate to your
02-connectingdirectoryOpen
massdriver.yamlScroll near the bottom of the file where the
dependenciesblock is located. This is where you declare the resources the bundle needs from other bundles:dependencies:
your_first_dependency:
resource_type: getting-started@~1
required: true
Where the producing bundle pinned an exact version, the consuming bundle accepts a range. ~1 means any 1.x.x release of the getting-started resource type, so the producer can ship compatible updates without this bundle changing. See Version Resolution for the range forms you can use.
Generate Variables from Dependencies
Run the bundle build command to generate variables from your dependencies:
mass bundle buildNotice: This updates
src/_massdriver_variables.tfto create a typed variable that matches the resource type schemaExamine: Look at how the resource type became a typed OpenTofu variable:
variable "your_first_dependency" {
type = object({
data = object({
password = string
pet-name = string
shuffle = list(string)
})
})
}
Publish the Connecting Bundle
Publish the connecting bundle:
mass bundle publish
Connect the Bundles in the UI
- In the Massdriver UI, drag your
connecting-bundlesbundle onto the canvas and name it - Notice: The left side has a connection port that matches your resource type
- Connect: Draw a line from the output port of your
getting-startedbundle to the input port of yourconnecting-bundlesbundle - Deploy: Click on
connecting-bundlesand click Deploy from the Config tab
Step 4: Explore the Results
Once deployed, explore what the connecting bundle created:
View the Outputs
- Click on your deployed connecting bundle
- Check the outputs in the deployment logs to see how the connected data was used:
- extended_pet_name: A new pet name using the original as a prefix
- password_based_port: A port number derived from the password length
- reshuffled_words: A new ordering of the original shuffled words
Key Takeaways
🧩 Resources enable bundle composition - Complex systems are built by connecting simple bundles
📜 Resource types ensure contracts - Type-safe data exchange between bundles
🔢 Versions let contracts evolve - Producers pin a version, consumers accept a range
🔄 Resource types are reusable - One resource type can be used by many bundles
👀 Visual connections - The UI makes infrastructure dependencies clear and manageable
🔗 Dependency enforcement - Required dependencies prevent incomplete deployments
What's Next?
Now that you understand bundle connections, you can:
- Create more complex architectures - Chain multiple bundles together
- Design reusable resource types - Create contracts for your infrastructure patterns
- Build custom bundles - Create your own infrastructure bundles with meaningful resources
- Explore advanced features - Learn about alarms, monitoring, and advanced bundle patterns
Congratulations! You've mastered the fundamental concepts of Massdriver's bundle system. You're ready to build real infrastructure architectures using these powerful composability patterns.