Export and delete
The state stays yours. You can download it at any time, and deleting a stack offers to download it first.
Export state
The Export state… button on the stack's page downloads the current state, in the clear, without locking anything. Through the API, it is GET /api/v1/orgs/{org}/stacks/{id}/state/export.
| What | File |
|---|---|
| The whole stack | a .tar.gz with one <unit>/terraform.tfstate per unit, the format the import reads |
One unit, with ?unit=<key> |
a .tfstate |
# The whole stack.
curl -H "Authorization: Bearer $ADMIN" -o state.tar.gz "$API/api/v1/orgs/$ORG/stacks/$STACK/state/export"
# One unit.
curl -H "Authorization: Bearer $ADMIN" -o net.tfstate "$API/api/v1/orgs/$ORG/stacks/$STACK/state/export?unit=net"
The file has secrets in plain text. Providers keep passwords, keys and tokens in the state. Each export is recorded, per unit, with who did it and when.
- It is all or nothing: if a unit can't be read, nothing is downloaded, and the API answers 503.
- A stack with no state answers 404.
- While there is only one role, any member of the organization can export.
- Choosing an older version comes with the State tab, which is planned.
Delete a stack
Deleting a stack doesn't destroy infrastructure. The dialog tells you what it will do:
- No state, or a state with no resources left. It removes the stack, its runs and its settings, and that empty state.
- A state that still manages resources. It says how many resources in how many units, offers to export them, which is optional, and asks you to type the stack's name. The stack and the state are then deleted together.
That infrastructure keeps running, with nothing in First Lume managing it. To remove it too, run a destroy first.
The stored state files are erased after 30 days, and no screen brings them back. State kept in another backend, such as your own s3, stays where it is.
A run in progress or a locked unit refuses the deletion with a 409, in every case.
Through the API:
curl -X DELETE -H "Authorization: Bearer $ADMIN" "$API/api/v1/orgs/$ORG/stacks/$STACK" \
-d '{"delete_state": true, "confirm": "<stack name>"}'
Without that body, a stack whose state still manages resources is refused with a 409.
Delete only the state
To keep the stack and remove its state, use DELETE /api/v1/orgs/{org}/stacks/{id}/state with the stack's name in the body, as {"confirm": "<name>"}. The deleted state is kept for 30 days as well.