Resolving "Duplicate backend configuration" error in Terraform stacks
Last updated: March 13, 2025
When using Spacelift with existing Terraform state files, you may encounter a "Duplicate backend configuration" error. This occurs because Spacelift attempts to create its own state backend while your configuration already defines one.
Resolution Options
You have two options to resolve this:
Option 1: Let Spacelift Manage State
If you want Spacelift to manage your state:
Keep the
manage_statesetting as true (default)Remove your existing backend configuration
Spacelift will create a state file for you the first time you apply changes.
Option 2: Use Your Own Backend
If you want to keep managing state in your own backend (e.g., S3):
Recreate the stack with
manage_stateset to falseKeep your existing backend configuration in your Terraform code
Note: You cannot have both Spacelift's managed state and your own backend configuration at the same time, as this would create a conflict in state management.