teardown
Removing or releasing everything that was set up for a piece of work, from a test's open connections to a whole temporary environment, once it is no longer needed.
In more detail
Teardown must also happen when something fails, which is why it belongs in cleanup code such as finally blocks or error handlers. Good teardown leaves nothing running that would keep a process alive, leak resources or keep costing money. For infrastructure, being able to tear an environment down and rebuild it from its description is what makes short-lived test environments safe and cheap.
Examples
In AWS: Deleting every resource an experiment or environment created, in the right order, so nothing keeps charging.In Terraform: Reliable teardown is what makes short-lived environments safe and cheap. In Terraform it is terraform destroy, and it is the strongest proof that a configuration really describes the whole environment.Related terms
- idle resource — A resource that keeps running and charging while doing little or no useful work, such as a test server left on.
- NAT gateway — A managed AWS service in a public subnet that lets resources in private subnets start outbound internet connections.
- Elastic IP address — A fixed public IPv4 address you allocate to your account and attach to a resource such as a NAT gateway.
- try...catch — A statement that runs code in a try block and, if that code throws an exception, runs a catch block instead of crashing.
- graceful shutdown — Stopping a service in an orderly way: finish current work, close connections, then exit.
- resource leak — A file, socket, timer or other system resource that a program opened and never closed.
- terraform destroy — The command that deletes every resource the current state records, in reverse dependency order.
- environment — One place where a copy of the application runs with its own config, such as development, staging or production.
Taught in
- The Danger of Long-Lived Keys — Cloud Infrastructure & Hyperscaler Architecture
- Network Address Translation — Cloud Infrastructure & Hyperscaler Architecture
- Elastic File System (EFS) — Cloud Infrastructure & Hyperscaler Architecture
- Cost, Budgets, and Tagging — Cloud Infrastructure & Hyperscaler Architecture
- How Bills Actually Get Large — Cloud Infrastructure & Hyperscaler Architecture
- Infrastructure as Code (Handover to Terraform) — Cloud Infrastructure & Hyperscaler Architecture
- Close Phase & Signal Dispatch: Sockets & Teardown — Node.js Internals & Backend Services
- Stream Pipelines: pipeline, AbortSignal & Teardown — Node.js Internals & Backend Services
- Asynchronous File I/O: node:fs/promises & Handles — Node.js Internals & Backend Services
- Tearing It Down With Destroy — Infrastructure as Code with Terraform