Terraform plan command on simple main.tf ERROR?

I’m working from an Orielly Terraform book, and the first exercise:

provider “aws” {
region = “us-east-1”
}

I’m working from an Orielly Terraform book [newbie], and the first exercise:

provider “aws” {
region = “us-east-1”
}

“terraform plan” command generated the following error:

A default (non-aliased) provider configuration for “aws” was already given at main-code.tf:1,1-15…

Searching got me nowhere as the problem may be either too simple or too weird. I have provided AWS_KEYs… as exports in zsh, and my general aws cli queries work fine on this machine. Ideas?

Hi @64-plus,

The error message is saying that there are two blocks in your configuration like provider "aws". You need to remove one of them for the configuration to be valid.

The error message should be giving you the source location for both of them. One of them is in the error message text you shared (code.tf line 1), and the other one should’ve been mentioned on a line above the one you shared. You’ll need to review both blocks and decide which one is correct for your situation. Unfortunately I’m not familiar with the book you are reading so I can’t say which of these is the one you need to keep.