Skip to main content

Resources & Resource Types

A resource is structured data that a bundle produces to describe what it provisioned. A resource type is the JSON Schema contract a resource must match. One bundle's resource fills another bundle's dependency through that contract.

Resource types were previously called artifact definitions, and resources artifacts. The old names still appear in some API fields, CLI aliases, and the massdriver_artifact Terraform resource.

How resources work​

A PostgreSQL bundle produces a resource with the database's connection details. An application bundle that depends on that resource type receives the hostname, port, and credentials at deploy time, validated against the resource type's schema.

Example PostgreSQL Resource:

json
{
"authentication": {
"hostname": "db.example.com",
"port": 5432,
"username": "app_user",
"password": "secret_value"
},
"infrastructure": {
"arn": "arn:aws:rds:us-west-2:123456789012:db:mydb",
"region": "us-west-2"
}
}

Resource Types​

A resource type:

  1. Defines the schema of a resource's data
  2. Allows links only between components that produce and consume the same type
  3. Passes state between tools, for example from an OpenTofu bundle to a Helm bundle
  4. Masks fields marked $md.sensitive

Example Resource Type:

json
{
"type": "object",
"title": "PostgreSQL Database",
"properties": {
"authentication": {
"type": "object",
"properties": {
"hostname": { "type": "string" },
"port": { "type": "integer" },
"password": {
"type": "string",
"$md.sensitive": true
}
}
}
}
}

Resource origins​

Provisioned resources​

A deployed bundle produces them:

  • Belong to the instance that produced them
  • ID is <instance ID>.<field>, for example ecomm-prod-db.authentication
  • Updated on each deployment of the instance
  • Removed with the instance

Imported resources​

You create them for things Massdriver does not provision, such as cloud credentials (AWS IAM roles, GCP service accounts) and existing infrastructure. Use Import Resource on the Resources page, or mass resource create. See Import a Resource.

  • ID is a UUID
  • Lifecycle is independent of any instance

How a resource reaches a bundle​

  1. Link: drawing a link between two components checks that both ends use the same resource type.
  2. Validation: a produced resource is validated against the resource type's schema.
  3. Injection: at deploy time, the resource's data is passed to the consuming bundle as the dependency's value.

A dependency can also be filled by an environment default or a remote reference. See Dependencies & Links.

Resource types are versioned​

A resource type is authored as a massdriver.yaml, published to its own OCI repository in your organization's catalog, and versioned like a bundle:

  • Each version is a semantic version. Dependencies can reference a release channel such as ~1 or latest.
  • Published versions are immutable, except 0.0.0, which can be republished.
  • Resource type repositories are not grant-gated. Anyone with repo:view and repo:pull can use them.
shell
mass resource-type create aws-vpc
mass resource-type publish ./aws-vpc
mass resource-type pull aws-vpc@2.1.0
mass resource-type get aws-vpc

The version is the version of the contract between bundles. Adding a required field to a payload that three bundles consume breaks all three, so it needs a major version bump.

Usage in massdriver.yaml​

A bundle names the resource types it consumes under dependencies and the ones it produces under resources, each with the versions it accepts:

yaml
# What the bundle consumes
dependencies:
vpc:
resource_type: aws-vpc@~1
required: true

# What the bundle produces
resources:
database:
resource_type: postgresql-authentication@1.0.0
required: true

A dependency accepts a range, which Massdriver resolves at deploy time. A name without @ means latest. A resource names the version it produces. See Version Resolution.

connections and artifacts are the previous names for these blocks. They still work, and mass bundle publish warns about them. A slot declared that way carries no version range and takes part in no version checks.

Best Practices​

  • Mark sensitive fields with $md.sensitive for automatic masking
  • Group related properties logically (authentication, infrastructure, iam)
  • Use descriptive field names that indicate what the resource represents
  • Design resource types for reuse across multiple bundles