Using Bundle Deployment Metadata
Massdriver adds md_metadata to the params of every deployment. It carries the instance's name prefix, the tags to apply, the alarm webhook, and deployment context, so bundles do not need params for them.
md_metadata holds no secrets.
Two keys keep their v1 names:
targetholds environment data, andpackageholds instance data.
Access​
- OpenTofu and Terraform:
var.md_metadata.mass bundle builddeclares the variable in_massdriver_variables.tf. - jq expressions in a step's
configblock:.params.md_metadata. See The jq context.
Structure​
{
"name_prefix": "ecomm-prod-api-a1b2",
"default_tags": {
"managed-by": "massdriver",
"md-project": "ecomm",
"md-environment": "prod",
"md-component": "api",
"md-instance": "ecomm-prod-api"
},
"observability": {
"alarm_webhook_url": "https://..."
},
"deployment": {
"id": "6f1c2b8e-..."
},
"target": {
"contact_email": "jane@example.com"
},
"package": {
"created_at": "2026-01-15T18:21:07Z",
"updated_at": "2026-03-02T09:44:51Z",
"deployment_enqueued_at": "2026-03-02T09:45:03Z",
"previous_status": "PROVISIONED"
}
}
name_prefix​
Type: string
The instance's name prefix: a unique prefix for every cloud resource the instance creates. It is set from the organization's naming convention when the instance is created and does not change. With the default convention it is <project>-<environment>-<component>-<suffix>.
resource "aws_s3_bucket" "logs" {
bucket = "${var.md_metadata.name_prefix}-logs"
}
default_tags​
Type: map(string)
Tags to apply to every resource the bundle creates. The organization's default tags setting chooses the attributes in this map. managed-by (massdriver) and md-instance (the instance ID) are always present.
resource "aws_instance" "app" {
tags = merge(
var.md_metadata.default_tags,
{
Name = "${var.md_metadata.name_prefix}-app"
}
)
}
observability.alarm_webhook_url​
Type: string
The environment's alarm webhook. Point cloud alarms at it to report them to Massdriver. See Monitoring & Alarms.
resource "aws_cloudwatch_metric_alarm" "high_cpu" {
alarm_name = "${var.md_metadata.name_prefix}-high-cpu"
comparison_operator = "GreaterThanThreshold"
evaluation_periods = 2
metric_name = "CPUUtilization"
namespace = "AWS/EC2"
period = 120
statistic = "Average"
threshold = 80
alarm_actions = [var.md_metadata.observability.alarm_webhook_url]
}
deployment.id​
Type: string
The ID of the running deployment.
target.contact_email​
Type: string
The email of whoever created the deployment. For a service account it is a generated address, not a mailbox.
package​
Type: object
Instance context at the time the deployment was created.
| Field | Type | Holds |
|---|---|---|
created_at | ISO 8601 string | When the instance was created |
updated_at | ISO 8601 string | When the instance was last updated |
deployment_enqueued_at | ISO 8601 string | When this deployment was created |
previous_status | string | The instance's status before this deployment: INITIALIZED, PROVISIONED, DECOMMISSIONED, or FAILED |
An instance that has never been deployed is INITIALIZED:
locals {
is_first_deployment = var.md_metadata.package.previous_status == "INITIALIZED"
}
resource "kubernetes_job" "migrations" {
count = local.is_first_deployment ? 1 : 0
# ...
}
Environment-specific behavior​
When the organization's default tags include md-environment, its value is the environment's ID without the project, such as prod:
locals {
is_production = var.md_metadata.default_tags["md-environment"] == "prod"
}
resource "aws_db_instance" "database" {
backup_retention_period = local.is_production ? 30 : 7
# ...
}
The same check in a step's config:
steps:
- path: src
provisioner: opentofu:1.10
config:
checkov:
enable: true
halt_on_failure: '.params.md_metadata.default_tags["md-environment"] == "prod"'
Best practices​
- Name resources from
name_prefix. Do not ask users for project or environment names. - Apply
default_tagsto every resource. - Send alarms to
alarm_webhook_url.
Related Documentation​
- Creating Your Own Bundle - Previous guide in this series
- Organization Settings - Naming convention and default tags
- Identifier Constraints - Reference for the
md_metadatastructure