Skip to main content
Incidents come in two shapes. Sometimes your infrastructure is on fire and you need the smallest, fastest change that resolves it. Other times a formae command itself is the problem: one you triggered by mistake, or one that is stuck. This guide covers both.

Fix a live incident with a patch

Patch mode is built for firefighting. It only creates or updates the resources you name and never destroys anything, so the blast radius is exactly the resource or two you are touching. See Apply modes for the full contrast with reconcile.
1

Write a focused forma

Include only the resources you are adding or fixing. The stack and target must already exist:
The file does not need to live in your repo. Create it anywhere, for example /tmp/hotfix.pkl, apply it now, and fold it into your code later.
2

Apply the fix

formae shows the plan and asks you to confirm, then streams the run in a live view:
  formae apply · patch                                                                                  hotfix.pkl
────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
  + 1 create

  ▌ Resources
  Operation ▲   Label                                                       Type
  + create      incident-logs                                               AWS::S3::Bucket

────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
  ↑↓: select  space: expand  →←: column  s: sort  y: confirm  q: abort This operation will create 1 resource(s).  Do
you want to continue? (y/N)  ?: help
Add --yes to skip the confirmation prompt when you are certain and need speed.

Settle up after the fix

A patch leaves your codebase describing something slightly different from reality: it created drift. Once the fire is out, you settle up in one of two ways, depending on whether the change was worth keeping. Until you do, the next soft reconcile on that stack detects the drift and fails, which is the reminder that code and reality disagree.

Absorb the change, if you want to keep it

The bucket you patched in is worth keeping, so make your code describe it. Extract the live resource into a forma file, fold it into your formae project, and reconcile. Now the stack matches your code again, and the resource is a first-class part of it.
1

Extract the patched resource

Pull the resource formae created during the incident into a forma file:
Extracted 1 resource to ./incident-logs.pkl

  incident-logs (AWS::S3::Bucket) on stack production
2

Fold it into your formae project and reconcile

Add the extracted resource to your formae project, then reconcile so code and infrastructure agree:
╭─ formae apply ──────────────────────────────────────────────────────────────╮
 No changes needed                                                          
                                                                            
 The specified forma resources are up to date.                              
╰────────────────────────────────────────────────────────────────────────────╯
The reconcile is now a no-op for the bucket, because your code already describes it. The drift is gone.

Discard the change, if it was a throwaway

If the patch was a temporary workaround you do not want to keep, do the opposite: reconcile your unchanged code back over it. Reconcile removes anything not in the forma, so the patched resource goes away and the stack returns to exactly what your code describes.
  formae apply · reconcile                                                                                main.pkl
────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
  - 1 delete

  ▌ Resources
  Operation ▲   Label                                                       Type
  - delete      incident-logs                                               AWS::S3::Bucket

────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
  ↑↓: select  space: expand  →←: column  s: sort  y: confirm  q: abort This operation will delete 1 resource(s).  Do
you want to continue? (y/N)  ?: help
--force overwrites every out-of-band change on the stack, not just your patch. Reach for it only when you know what you are discarding. Extract and compare the current state first if you are unsure.

See also