# Alchemy vs Terraform + Decoupling Infrastructure with Layers

> For agents: start with the [agent guide](https://ratstack.sh/llms.txt). Every page is Markdown by default; add `Accept: text/html` for HTML.

[Effect | TypeScript for the AI Era](https://www.youtube.com/@effect-ts) · Published 2026-06-05 · 12:04 · A tier · Alchemy and infrastructure as code

[Watch on YouTube](https://www.youtube.com/watch?v=83BsUCw3wew) · [All RatTube videos](/tube)

## Summary

Sam Goodwin discusses [Alchemy](/lore/infrastructure-as-effects)'s TypeScript approach and the tradeoffs of stateful infrastructure tools. The conversation covers deployment graphs, circular references, and the value of knowing a resource plan before applying it.

The discussion then turns to separating application code from infrastructure choices through [Layers](/lore/layers-make-dependencies-explicit). Swapping implementations can change how the application reaches a resource. A Better Auth example illustrates a [service](/lore/layer-constructor-pattern) with a database-specific implementation.

## Section notes

- [0:14](https://www.youtube.com/watch?v=83BsUCw3wew\&t=14s): Goodwin explains his preference for TypeScript infrastructure over a Terraform-based tool.
- [2:00](https://www.youtube.com/watch?v=83BsUCw3wew\&t=120s): The speakers compare stateful tools with checking deployed infrastructure.
- [4:10](https://www.youtube.com/watch?v=83BsUCw3wew\&t=250s): Deployment graphs complicate circular dependencies.
- [6:20](https://www.youtube.com/watch?v=83BsUCw3wew\&t=380s): A known resource plan offers checks before deployment.
- [8:21](https://www.youtube.com/watch?v=83BsUCw3wew\&t=501s): Layers allow resource access implementations to be replaced.
- [10:33](https://www.youtube.com/watch?v=83BsUCw3wew\&t=633s): A Better Auth service illustrates an infrastructure-carrying implementation.

## Key concepts

- [Alchemy](/lore/infrastructure-as-effects)
- [Layers](/lore/layers-make-dependencies-explicit)
- [service](/lore/layer-constructor-pattern)

## Our take

Sam Goodwin on replacing Terraform with resources written in TypeScript and Effect, and why he keeps a plan you can audit and check before deploying rather than a pure reconciler. Then layers swap D1 for DynamoDB behind one Effect service.

## Related videos

- [What is Alchemy? Zero-to-Production Infrastructure in TypeScript & Effect | Office Hours 27](/tube/what-is-alchemy-zero-to-production)
- [Alchemy, Infrastructure as Effects | Office Hours 27 🔥](/tube/alchemy-infrastructure-as-effects-office-hours)
- [Fork Every Business: Sam Goodwin on Alchemy, Effect and AI](/tube/sam-goodwin-alchemy-effect-ai)
- [Cluster, Workflows & Cloudflare Durable Objects](/tube/cluster-workflows-cloudflare-durable-objects)

Summary based on the transcript. Written 2026-11-15.
