Terraform: Error: Duplicate resource "aws_s3_bucket" configuration — A aws_s3_bucket resource named "logs" was already declared at main.tf:1
The same resource, variable, output or provider is declared twice in the module.
Error: Duplicate resource "aws_s3_bucket" configurationA aws_s3_bucket resource named "logs" was already declared at main.tf:1Error: Duplicate variable declarationA variable named "region" was already declared at variables.tf:1,1-18Error: Duplicate provider configuration Meaning
Terraform loads every .tf file in the directory as one module. A copied file (main copy.tf, .tf.bak named .tf), duplicated blocks, or moving code between files without removing the original causes this. Rename/remove duplicates; keep backups outside the folder or with non-.tf extension.
Common causes
- Backup/copy files ending in
.tf - Same block in two files
- Variable declared in
variables.tfandmain.tf - Duplicate provider without alias
- Merge conflicts leaving both sides
⚡ Quick fix
grep -R 'resource "aws_s3_bucket" "logs"' *.tfand remove the duplicate- Move backups out of the directory
- Give providers aliases when using several configs
Detailed fix by platform
Linux
ls *.tf && grep -n 'variable "region"' *.tf
How to diagnose
- Files — Which declare it?
- Backups — .tf copies?
- Alias — Needed?
🔧 Still not fixed?
Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:
Similar errors
- Invalid AWS Region Terraform: Error: Invalid AWS Region: us-east-3 / Error: configuring Terraform AWS Provider: validating provider credentials: operation error STS: GetCallerIdentity
- Invalid character / Argument or block definition required Terraform: Error: Invalid character — This character is not used within the language / Error: Argument or block definition required
- Missing required argument Terraform: Error: Missing required argument — The argument "ami" is required, but no definition was found
Most viewed in Terraform
- Error acquiring the state lock Terraform: Error: Error acquiring the state lock — ConditionalCheckFailedException / state blob is already locked
- Inconsistent dependency lock file Terraform: Error: Inconsistent dependency lock file — provider x: required by this configuration but no version is selected
- Resource is tainted and must be replaced Terraform: # aws_instance.web is tainted, so must be replaced — -/+ destroy and then create replacement
Other ways to find it
Where this error sits
Origin: Platform & cloud. Errors that are often confused with or caused by this one (click to open):
🧠 Still stuck? Analyze your error
Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.
💬 What worked for others
No tips yet — did something else fix this for you?
Share what worked for you
Tips are checked by an editor before they appear. Links are removed.
Report a correction or suggest an improvement
Last updated 5 Nov 2026