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:

  1. Keep the manage_state setting as true (default)

  2. Remove your existing backend configuration

  3. 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):

  1. Recreate the stack with manage_state set to false

  2. Keep 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.