# Terraform: Error: Duplicate resource "aws_s3_bucket" configuration — A aws_s3_bucket resource named "logs" was already declared at main.tf:1

**Code:** `Duplicate resource configuration / variable declaration` · **Category:** Terraform · **Seen on:** Terraform

The same resource, variable, output or provider is declared twice in the module.

## 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.tf` and `main.tf`
- Duplicate provider without alias
- Merge conflicts leaving both sides

## Quick fix

1. `grep -R 'resource "aws_s3_bucket" "logs"' *.tf` and remove the duplicate
2. Move backups out of the directory
3. Give providers aliases when using several configs

## Detailed fix by platform

### Linux

1. `ls *.tf && grep -n 'variable "region"' *.tf`

## How to diagnose

1. **Files** — Which declare it?
2. **Backups** — .tf copies?
3. **Alias** — Needed?

---
Source: [WhatIsMyError](https://whatismyerror.com/errors/terraform/duplicate-resource-or-variable-definition)
