Tons of new funtionality in Massdriver! We're demoing a new feature everday until Christmas.
Check out the advent calendar hereMassdriver Automations
Twenty-three ready-made services that act on Massdriver events: deploy dependents, roll back failures, freeze changes, find drift, move new bundle versions through stages, run a public status page, show cloud costs, metrics, and who is on call, record deployment results, and score instances.
Ready-made services that receive Massdriver events and act on them.
Event destinations send Massdriver events to your own systems. massdriver-automations is a set of twenty-three services that receive those events and do the work that platform teams usually write themselves: deploy the instances that depend on a change, roll back a failed deployment, stop deployments during a change freeze, find drift, move a new bundle version from dev to staging to prod, serve a public status page, show the cloud costs of your instances, put your metrics and who is on call on the canvas, record the results of each deployment, keep deployed params in git, and score instances against your own checks.
Each automation receives events from an HTTP event destination, verifies the Standard Webhooks signature, and calls the Massdriver API or another service. You turn on the automations that you need, and give each one a short YAML config.
๐ Deploy them with a bundle
Each automation has two bundles:
massdriver-<automation>runs the automation on Kubernetes, behind an ingress controller.massdriver-<automation>-ecsruns it on Amazon ECS with Fargate, behind an Application Load Balancer.
Each bundle runs one automation and creates the event destination that sends it only the event types, attributes, and condition that it uses. Put the automations that you need on a canvas, and each one is its own instance with its own config, deployments, and logs. Here eight automations run in an automations project, and each one depends on the ECS cluster:
The top of each bundle form sets the image, the host, and the log retention. The host is <automation>.<domain of the cluster's hosted zone> by default, and the ECS bundles can create its DNS record. Every bundle uses the 0.3 image by default.
Below it, Settings has the keys of the automation's config file. A setting left empty uses the automation's default. Fields for groups and projects list the ones in your organization.
After a deploy, the destinations are in Organization Settings โ Event destinations, one for each automation, with the URL of its host:
The Overview tab of a destination shows the events that it sends, its condition, and its deliveries in the last 24 hours. The autodeploy-downstream destination gets only deployment.completed events of PROVISION deployments:
The signing secret of each destination goes to its automation. The bundles read it with signing_secret on massdriver_event_destination, so they need Terraform provider 2.7.0 or later.
The ECS bundles have Development and Production presets, and an operator guide that shows as a runbook on the instance page.
Publish the resource types that the bundles use before you publish a bundle. Every bundle depends on massdriver-service-account. The Kubernetes bundles depend on massdriver-kubernetes-cluster. Both types are in massdriver-resource-types. The ECS bundles depend on aws-iam-role and aws-ecs-cluster. The repository has an example aws-ecs-cluster type and an example website type, which you can change to match how your organization runs things.
๐งฐ The automations
| Automation | What it does |
|---|---|
autodeploy-downstream | When an instance deploys, deploys or proposes a deployment of the dependent instances that match its rules. |
rollback-on-failure | When a deployment of an opted-in instance fails, rolls it back to its last completed deployment. |
proposal-chatops | Posts proposed deployments to Slack with Approve and Reject buttons. |
freeze-guard | Adds deny policies for deployment actions to your groups during change freeze windows. |
drift | Plans instances on a schedule, sends drift alerts to Slack, and can apply the deployed configuration again. |
statuspage | Serves a public status page from alarms, instances, and deployments. |
cost-explorer | Serves a dashboard of instance costs that you can group, filter, and chart over time. |
github-deployments | Shows Massdriver deployments as GitHub Deployments. |
release-notes | Posts new bundle versions, and the instances that can upgrade, to Slack and Microsoft Teams. |
bundle-scanner | Scans each new bundle version with Trivy and Checkov. |
audit-archiver | Archives every event, unchanged, in S3, Splunk, Datadog, or a local directory. |
sandbox-on-join | Forks a sandbox environment for each new group member, and removes it when they leave. |
router | Runs HTTP requests, commands, and Massdriver API calls for the events that match the routes in its YAML file. |
upgrade-train | Moves each new bundle version through stages of instances, such as dev, staging, and prod, with a soak time and an alarm check between stages. |
stale-proposals | Posts a Slack digest of proposed deployments that wait too long for approval, and can reject the oldest. |
stash-sync | Copies CloudWatch and Prometheus metrics into stash entries, so widgets show health, usage, and traffic on the canvas. |
pr-sync | Writes the GitHub pull requests of a project's repositories to the project's stash. |
chaos-monkey | Sends random presets, mutated params, and invalid values to the instances that match its attributes. |
log-results | Reads the logs of each finished deployment with your rules, and writes the plan changes, apply outcome, or scan findings to its stash. |
params-to-git | Writes the params of each successful deployment to params.json in a GitHub repository, by push or pull request. |
oncall | Writes who is on call now in PagerDuty or incident.io to each environment's on-call card. |
leaderboard | Ranks the authors of GitHub pull requests and writes the top players to each environment's leaderboard card. |
scorecards | Scores instances against the checks in your scorecards, and writes the scores and the facts that they use to the stash. |
Deploy dependents
autodeploy-downstream reads deployment.completed. When an instance deploys, it finds the instances that depend on it and applies the first rule that matches each one. A rule selects dependents by their attributes, and can also require attributes on the instance that deployed. A value with commas, such as api, web, matches any of its values. The action is Deploy now or Propose a deployment for a person to approve.
The same rules as a config file:
rules:
- name: staging-cascade
upstream:
md-environment: staging
downstream:
autodeploy: 'true'
md-environment: staging
action: deploy
- name: prod-review
upstream:
md-environment: prod
downstream:
autodeploy: 'true'
tier: [frontend, api]
action: propose
Roll back failures
rollback-on-failure reads deployment.failed. When a PROVISION deployment of an instance with your opt-in attribute fails, it proposes a deployment with the bundle version, params, and dependencies of the last completed deployment, and approves it. It does not roll back a failed rollback, and it waits when another deployment of the instance is running. When the environment requires separation of duty, the proposal waits for a person to approve it.
Freeze changes
freeze-guard blocks deployments with access policies. A window is weekly, such as every night, or a fixed range, such as a holiday. When a window starts, freeze-guard adds a DENY policy for the deployment actions to each custom group that is not exempt. When the window ends, it deletes those policies. People can still configure instances, plan, and propose deployments during a freeze. A window can select instances and environments by attribute, such as md-environment: prod.
To lift a window early, send POST /freeze/lift?window=<name> with the admin token. The built-in Administrators group is never frozen.
Find drift
drift plans instances on a schedule. Each check selects instances by attribute and runs planDeployment with the params of the last completed deployment, so unsaved edits do not show as drift. It reads the plan logs and sends an alert to Slack for each instance that drifted. A check can only alert, propose a deployment that removes the drift, or deploy at once.
To start a check from outside the schedule, send POST /drift/run?check=<name> with the run token.
Run a public status page
statuspage serves a public status site from your environments. It reads alarms, instances, and deployments from the API at start, then keeps the site current from events. The site has a status banner, active and past incidents, uptime bars for each day, maintenance, announcements, /api/status.json, an Atom feed, and an SVG badge for each page.
Each page lists environments, and each environment lists rows. A row selects instances by attribute, and takes the worst status of its instances. Its impact sets how a firing alarm on one of its instances shows: degraded performance, partial outage, or major outage.
This is the development page of the status site. Two alarms fire in development, so the page shows degraded performance, the two incidents, and the rows they affect:
With the stash block on, the page also reads the stash. An instance whose md/v1/health is degraded shows degraded performance, and one that is down shows its impact, or a major outage when no impact is set. A row takes the worse of stash health and alarms, so a firing alarm still wins over healthy.
An md/v1/banner on an environment shows as a notice on each page that has the environment. min_level filters banners. The block is off by default, and the service account needs stash:view:
stash:
health: true
banners: true
min_level: warning
The site shows only the titles in the config and the names of instances. It does not show the identifiers of projects, environments, instances, or alarms. Incident updates do not include alarm names and provider messages unless you turn on show_alarm_details.
The statuspage bundle produces a website resource with the URL of the site, so other bundles and your docs can read it:
Show cloud costs
cost-explorer serves a dashboard of the cloud costs of every instance. You group and filter the costs by instance attributes, such as md-project, md-environment, or your own team and cost_center attributes. The dashboard shows the last month, the monthly and daily averages, the projected cost of this month, and a daily chart over 7, 30, or 90 days, or all history. Each group lists its instances, with links to them in Massdriver, and you can download the instances in view as CSV. The filters and the grouping are in the URL, so you can share a view.
It reads costs from the Massdriver API every hour by default, and 30 seconds after a provision or decommission completes. It keeps one cost for each instance each day, so the chart keeps instances that you deleted. The dashboard uses basic auth unless you set public: true. Like statuspage, its bundle produces a website resource with the URL of the dashboard.
Move new versions through stages
upgrade-train reads repo.published. A train names the bundles that it covers and a list of stages. Each stage selects instances by attribute, such as md-environment: dev, and deploys or proposes the new version to the PROVISIONED instances whose version constraint resolves to it. After every deployment of a stage completes, the stage soaks. During the soak, it checks every minute that each instance is still on the new version and has no firing alarms. Then the next stage starts.
trains:
- name: databases
bundles: [aws-aurora-postgres, aws-rds-mysql]
stages:
- name: dev
match:
md-environment: dev
mode: deploy
soak: 4h
- name: staging
match:
md-environment: staging
mode: deploy
soak: 24h
- name: prod
match:
md-environment: [prod, prod-eu]
mode: propose
soak: 1h
A failed, aborted, or rejected deployment, or a firing alarm during the soak, stops the run and posts the reason to Slack. POST /upgrade-train/run resumes the run at the stage where it stopped, and POST /upgrade-train/halt stops runs. The train never changes a version constraint. It names the instances that are pinned to a different version, and leaves them out. Development versions are skipped unless you set include_development. With STATE_DIR set, a restart continues the runs that were in progress.
Put metrics on the canvas
The stash is a key-value store on projects, environments, components, instances, and deployments. The stash API is alpha, so its names start with alpha and can change. The automations that write to the stash need stash:write on the scopes that they write. A value under a well-known md/v1/ key shows as a widget for everyone who can view the project: md/v1/health colors an instance, md/v1/usage draws a usage bar, md/v1/traffic shows the request rate, errors, and latency on the links that leave an instance, md/v1/banner shows a banner on an environment, and md/v1/links adds links to the environment header.
stash-sync fills those keys from your monitoring. It runs in your cloud with your own credentials, and Massdriver does not need access to your monitoring systems. It reads AWS CloudWatch metrics and alarms, and Prometheus queries. Presets fill a widget from a common metric with no query to write:
| Preset | Key | Source |
|---|---|---|
aws-rds-connections | md/v1/usage | RDS DatabaseConnections against the connection limit |
aws-alb-traffic | md/v1/traffic | ALB requests per second, 5xx count, and p95 response time |
aws-alarm-health | md/v1/health | The state of a CloudWatch alarm |
prometheus-traffic | md/v1/traffic | Request rate, 5xx count, and p95 latency of an HTTP histogram |
Rules write any other stash key from a query or a fixed value. stash-sync writes a value only when it changes, checks each md/ value against the widget catalog before it writes, and sets a TTL of three intervals on each entry, so the widgets go away when the automation stops. mode: simulate writes changing values with no cloud access, from the steady, incident, postgres-cutover, or rollout scenario.
pr-sync reads the pull requests of the GitHub repositories that you map to each project, and writes them to one JSON entry, github/prs, in the project's stash. Each pull request has its repository, title, author, link, review state, check state, and a summary state: merging, checks, failed, approved, review, draft, or merged. A note pinned to the project header can list them:
### Merging PRs
{% for pr in project.stash["github/prs"].prs %}
- [{{ pr.repo }}#{{ pr.number }}]({{ pr.url }}) {{ pr.title }} ยท **{{ pr.state }}**
{% endfor %}
Show who is on call, and a leaderboard
oncall reads who is on call now and writes them to md/v1/oncall on each environment in its routes, lowest escalation level first, up to 10 people by default. A route reads PagerDuty schedules and escalation policies, or incident.io schedules and escalation paths. A static route writes a fixed list, so you can try the card with no provider:
interval: 2m
routes:
- environments: [billing-prod, billing-staging]
title: Billing on call
pagerduty:
escalation_policies: [PD4E5F6]
- environments: [sandbox-dev]
title: Demo on call
static:
- name: Jo Park
email: jo@tendwell.example
handles: [slack:@jo]
The list shows as an On call card on the environment canvas, with a face and a name for each person. Hover a person to see the email and the handles. It also shows on the locked card of a resource that the environment produces, so people who cannot open that project still know whom to ask. When a provider query fails, oncall writes nothing for that route, and the last list stays until its TTL ends.
leaderboard reads the pull requests of GitHub repositories and writes the top authors to md/v1/leaderboard, as a ranked card under the on-call card. A route picks the environments, the repositories, an optional base branch, labels, and path prefixes, a window (30 days by default), and a score: merged (the default), opened, or lines. Bots do not score unless include_bots is set. It also takes a static route.
Record deployment results
The widget catalog also has keys for the results of a deployment. md/v1/step/<step>, md/v1/changes/<step>, and md/v1/compliance/<step> go on a deployment, and md/v1/drift and md/v1/release go on an instance. Five automations write them:
driftwritesmd/v1/drifton the instance, and the changes of its plan tomd/v1/changes/drift.upgrade-trainwritesmd/v1/step/upgrade-trainon each deployment that a stage creates, andmd/v1/releaseon the instance when that deployment completes.rollback-on-failure,autodeploy-downstream, andchaos-monkeywritemd/v1/step/rollback,md/v1/step/autodeploy, andmd/v1/step/chaos-monkeyon the deployments that they start.github-deploymentswritesmd/v1/source, with the repository, ref, and commit, whenMASSDRIVER_API_KEYis set.
Each of them takes results.prefix (default md/v1). A prefix outside md/, such as results/v1, writes the same values as labeled Deployment metadata rows. A failed write is logged and does not fail the event.
log-results fills these keys until your provisioners write them. It reads the logs of each deployment.completed and deployment.failed event with the rules in its config file. A rule writes nothing unless its detect pattern is in the logs, so the rules for every tool share one file. The example config has rules for OpenTofu and Terraform plans and applies, Checkov findings, Helm releases, and Bicep what-if changes. To check your rules on a saved log, run:
massdriver-automations test log-results -config config.yaml -action PLAN < deploy.log
Score instances
scorecards scores instances against the scorecards in its config. A scorecard selects instances by attribute and has a list of checks. Each check reads one stash entry or the instance, and passes when its jq expression is true. A check is unknown when its entry is missing, expired, or older than max_age. An unknown check does not count in the score.
The score is the percentage of the passed and failed checks that passed, and the level is the highest level that the score reaches:
scorecards:
- name: production-readiness
match:
md-environment: prod
checks:
- id: no-drift
stash: md/v1/drift
pass: .status == "none"
max_age: 2d
- id: checkov-clean
stash: { key: md/v1/compliance/src, scope: deployment }
pass: .failed == 0
- id: owned
stash: { key: md/v1/ownership, scope: environment }
pass: (.groups | length) > 0
levels:
gold: 100
silver: 80
bronze: 50
It writes the checks, the score, and the level to md/v1/scorecard/<name> on each instance. Each environment and project gets a roll-up of its instances. It also writes facts that checks can read:
md/v1/delivery: the deployments in the window, the failures and rollbacks, and the median duration.md/v1/reliability: the alarms, the time in alarm, and the median recovery time.md/v1/currency: how many versions and days the instance is behind the latest bundle version.md/v1/pending: params or a version that are not deployed.md/v1/parity: how an environment differs from its reference environment.md/v1/ownership: the groups that own an environment or a project.
The Metadata tab of an instance shows a Scorecards card with each check and the facts. The canvas node of a scored instance shows a level pill. The environment summary shows the roll-up and the parity, and the project overview shows a Scorecards card. The service account needs stash:write on the instances, environments, and projects, and organization:manageGroups for ownership.
Keep deployed params in git
params-to-git writes the params of each successful PROVISION to <root>/<project>/<environment>/<component>/params.json in a GitHub repository, and deletes the file on decommission. The first mapping that matches the deployment's attributes picks the repository, branch, root, and strategy. push commits to the branch, and pull_request opens or updates a pull request. Sensitive params are masked or left out. The sync goes one way: a merge or an edit in git deploys nothing. To try it without a repository, the stdout strategy prints each file, and the directory strategy writes the files to a local directory.
More automations
proposal-chatopsposts each proposed deployment to Slack with the instance, the action, the bundle version, and who proposed it. A click approves or rejects it as the service account. A decision made in Massdriver, the CLI, or the API also updates the message.github-deploymentscreates a GitHub deployment for each Massdriver deployment, in the repository named by the instance'sgithub_repoattribute, and adds a status at each step.release-notesposts each new bundle version with its changelog, the instances that can upgrade, and the instances on a release channel that Massdriver moves to it.bundle-scannerpulls each new bundle version from the Massdriver registry, scans its IaC with Trivy and Checkov, posts the findings, and can recordpassedorfailedas an attribute on the bundle's repo.audit-archiverwrites every event, unchanged, to S3 (with optional Object Lock), Splunk, Datadog, or a local directory.sandbox-on-joinforks a template environment when a person joins a group, with the attributesownerandsandbox=true. When they leave, it decommissions the fork and can delete it.stale-proposalsreads every proposed deployment on a schedule and posts one Slack digest of the proposals older thanremind_after(24 hours by default), grouped by project and environment. Mention rules add Slack users or groups to the proposals that match their attributes. Withreject_after, it also rejects the oldest proposals, anddry_runlists them without a rejection.chaos-monkeypicks random instances that match its required attributes and sends them presets, merged presets, mutated params, or invalid values, as proposals, plans, or deployments. It posts to Slack what it sent, what Massdriver rejected, any invalid value that Massdriver accepted, and how each deployment ended. Use it on sandbox instances to test your bundles and their params validation.routerruns steps when an event matches a route. A step can be an HTTP request, a command, or a Massdriver API call. The repository has example routes for PagerDuty incidents, Teams messages, cleanup after a decommission, and a plan after an instance changes.
โ๏ธ Run one yourself
You do not need the bundles. All of the automations ship in one image, and you run one automation in each container:
docker run -p 8080:8080 \
-v "$PWD/config.yaml:/etc/massdriver-automations/config.yaml:ro" \
-e MASSDRIVER_SIGNING_SECRET=whsec_... \
-e MASSDRIVER_ORGANIZATION_ID=acme \
-e MASSDRIVER_API_KEY=md_... \
ghcr.io/massdriver-cloud/massdriver-automations:0.3 run autodeploy-downstream
- Each automation receives events on
POST /hooks/massdriverand answers health checks onGET /healthz. - Environment variables hold credentials. The YAML config holds everything else. A setting that needs a credential names the environment variable that holds it, such as
token_env: GITHUB_TOKEN. - An invalid config stops the automation at start with one log record that names the file, the key, and the problem, but not the value.
- Logs are JSON lines in a container and colored text on a terminal. Each record has the automation, its version, and the event ID and type.
- Set
OTEL_EXPORTER_OTLP_ENDPOINTto send OpenTelemetry traces. Massdriver sends the trace context of the work that caused each event, so the spans of an automation join that trace. - The images are for
linux/amd64andlinux/arm64, run as non-root, and have an SBOM and a signed build provenance attestation. - The automations that post to Slack share one Slack app. A Slack incoming webhook also works, except for
proposal-chatops, which needs the app for its buttons. - The README of each automation has its config, its environment variables, and the
mass event destination createcommand that sends it only the events it uses.
To run an automation on your computer, start it with go run and give Massdriver a public URL with a tunnel. The README has the steps.
๐ ๏ธ Write your own
An automation is one Go method, Handle, that receives a verified event. The packages that verify signatures, drop repeated events, and call the Massdriver API are importable, so you can build automations in your own repository.
The event reference has the fields of each event. Start with deployments and instances, which has the events that most automations read.
