S3 backend and versioning
The S3 backend stores state at a configured bucket and key. The bucket must already exist before backend initialization. Protect access and enable versioning for recovery. Backend credentials should come from supported secure credential mechanisms rather than hardcoded secrets in configuration or copied plan files. For example, an environment uses key dev/network.tfstate in a restricted versioned bucket separate from its managed application bucket.
An environment uses key dev/network.tfstate in a restricted versioned bucket separate from its managed application bucket.
Two engineers need one authoritative state for a network project. They configure an existing restricted S3 bucket and a specific key, then initialize the backend deliberately. State reads and writes now use that location rather than each laptop's independent inventory. The backend bucket should not be owned by the same disposable application stack if its deletion would erase management data.
A backend is the state storage and coordination mechanism. A key is the S3 object path chosen for that state. Versioning retains earlier object versions for recovery. Before migration, stop concurrent writers, securely back up state, verify destination account and access, and review the migration procedure. Remote storage improves collaboration but adds availability and permission dependencies. Access to state can expose sensitive attributes even without access to the application resource itself. Separate environment keys and preferably stronger account/access boundaries where needed; a path named prod is not a protection unless policies enforce it.
An environment uses key dev/network.tfstate in a restricted versioned bucket separate from its managed application bucket.
Do not overlook this operational distinction: Backend credentials should come from supported secure credential mechanisms rather than hardcoded secrets in configuration or copied plan files.