What a template is#
A template is a text file written in CloudFormation, the language AWS uses to describe a group of cloud resources so they can be created, changed and deleted together. We chose plain CloudFormation on purpose. Your own engineers can read every change Harebell makes in your account, in a format they already know, and a builder never has to write any of it.
The file carries one extra block, Metadata.Harebell, which tells Harebell four things: a title, the inputs a builder may set, the outputs that become the app's environment variables, and the permissions the app's own role receives so it can use what the template made. An output is how the app finds its resource without anyone copying addresses by hand.
A builder asks for a resource in the app's harebell.yaml file by naming the template and setting its inputs, in lower case, next to the name. For example, Sally Chen's expense app at Initech asks for a medium database like this:
resources:
- name: db
template: postgres
size: mediumAt release, Harebell creates one CloudFormation stack for this request, named harebell-res-<app>-<resource>, and the app receives the stack's outputs as environment variables prefixed with the resource's name, such as DB_HOST and DB_DATABASE. Whether the request is allowed, and who must approve it, is decided by your policies.
The three starters#
You do not start with an empty list. When your cloud account connects, Harebell adds three starter templates, so apps can ask for a database, files or a queue on the first day.
| Name | What the app gets | While it is in development | Once released |
|---|---|---|---|
postgres |
A Postgres database that the app signs in to with its AWS identity, so there is no password to keep. The Size input is small, medium or large. |
A database of its own on a small cluster shared by all private copies. | An Aurora PostgreSQL Serverless v2 cluster of its own, scaling up to 2, 4 or 8 capacity units by size, with 7 days of backups. |
file-storage |
A private S3 bucket that only the app can read and write. | Files expire after 7 days. | Versioned, and encrypted with AWS KMS. |
queue |
An SQS queue the app can send to and receive from. | A plain queue. | A queue with a dead-letter queue for messages that fail five times, and a CloudWatch alarm when the oldest message is over an hour old. |
The alarm only changes its own state. Templates cannot attach actions to an alarm, so it notifies nobody until you connect it to something yourself.
If your list is empty, for example because the account connected before the starters existed, the Templates page offers Add the starters. A starter you have already changed is never overwritten.
Why every template has two versions#
Each template holds a development version and a released version in the same file, and CloudFormation chooses between them with a parameter named Environment. A builder trying an app in their private copy gets the development version, which is small, quick to create and thrown away after 7 days unused. A released app gets the released version.
Harebell requires both versions to declare the same outputs. This is the rule that matters most to builders. It means the app reads the same environment variables in both places, so nothing in the app's code changes between trying it and releasing it.
Add or change a template#
Templates are for admins. The Templates page appears in the sidebar for people with the admin role, and only they can edit, test and publish. Builders can use what is published and nothing else.
Press New template to write one, or open an existing template and press Edit draft. A name is lower-case letters, digits and hyphens, starts with a letter, and is at most 40 characters, because apps write it in their harebell.yaml. Press Save draft and Harebell checks the text at once. If something is wrong, the page lists what to fix before the template can be published. If another admin saved the same draft after you opened it, Harebell refuses your save instead of overwriting their work.
Then press Test it in your cloud account. Harebell asks CloudFormation in your account to preview what each version would create, and shows the result as "It would make" followed by a list. The preview is a change set that is never carried out, made in a temporary stack named harebell-test-<template>-... that Harebell deletes straight away. Nothing is created. A passed test is required for each version, and any edit to the draft makes the test stale, so you press Test again. A starter whose text is exactly as Harebell shipped it is exempt, because we tested it.
When both versions have passed, Publish it appears. Publishing writes the next version number and records it in the audit trail, with the admin who did it and the text's SHA-256 hash. A text identical to the latest version is refused.
What a template may contain#
The checks that run when you save are stricter than CloudFormation itself, and the reason is a safety net in your account. Templates run as a role called harebell-templates, held to a boundary named harebell-templates-boundary. A boundary is a ceiling that caps a role no matter what its policies say, and this one keeps template stacks to resources named for their own stack. A template therefore cannot touch Harebell's own tables, queues, functions or keys, or anything else in the account. Harebell checks the same rules when you publish, so you learn about a refusal at your desk instead of on a builder's release.
Within that ceiling, a template may contain these kinds of resource:
- DynamoDB tables, S3 buckets and bucket policies, and SQS queues and queue policies.
- RDS database clusters, instances and their parameter, option and subnet groups.
- Secrets Manager secrets, which need a name that starts with the stack's name.
- Lambda functions with their aliases, versions, URLs and permissions, as long as the function has no network configuration and no layers.
- CloudWatch alarms without actions, log groups, log streams, and metric and subscription filters.
- IAM roles, but only under the path
/harebell/t/and with the templates boundary attached. - Custom resources.
Networks, load balancers, DNS, containers, builds, event rules and schedules are not on the list, because the boundary cannot tell a template's own from Harebell's by name. A few settings are refused inside the allowed types for the same reason: databases cannot start as a copy of another database or replicate to another region, secrets cannot have resource policies, rotation or replicas, and every resource stays in the region Harebell runs in.
What happens to apps that already use a template#
A published version never changes. A resource keeps the version it was made from until its app's next release, so a new version reaches an app only through a release, and the release plan shows what would change before the builder presses Release. Your policies are asked about each changed resource at that moment.
You can stop new requests without touching existing apps. Press Unpublish and apps can no longer ask for the template, while everything already made from it keeps running on its version. Let apps ask for it again reverses it.
When a release removes a resource, Harebell deletes its stack. Data does not vanish with it. A database's final snapshot and a retained bucket stay in your account for 30 days, and then Harebell deletes them. Everything Harebell creates in your account lists the names to look for.