3
votes

I tried terraform versions v0.12.26 and v0.13.3. Both failed.

terraform plan

Acquiring state lock. This may take a few moments...

Error: Error locking state: Error acquiring the state lock: 2 errors occurred: * ResourceNotFoundException: Requested resource not found * ResourceNotFoundException: Requested resource not found

Terraform acquires a state lock to protect the state from being written by multiple users at the same time. Please resolve the issue above and try again. For most commands, you can disable locking with the "-lock=false" flag, but this is not recommended.

Related source code:

terraform {
  backend "s3" {
    encrypt        = false
    bucket         = "dev-terraform-state"
    key            = "dev/Oregon/eks/terraform.tfstate"
    region         = "us-west-2"
    dynamodb_table = "dev-lock-table"
  }
  required_version = ">= 0.12.0"
}
1
Hi. I've noticed that you have bunch of questions with answers, but not a single one was accepted. It is a good practice to accept questions which were helpful as it help others in future with similar issue. If good answers are not accepted, it prompts people to make duplicate questions with the false assumption that the answers given weren't userful. - Marcin
I would like to accept those answers. But, how to accept? - Melissa Jenner
Under upvote/downvote buttons there is a "tick" symbol. - Marcin
I found out dev-lock-table is not created in AWS dynamodb table by running terraform init and plan. But, why is it not created? - Melissa Jenner
I removed the line, dynamodb_table = "dev-lock-table". Then, "terraform plan" works. Why? - Melissa Jenner

1 Answers

5
votes

The error is ResourceNotFoundException, which suggests that your dev-lock-table does not exist.

Terraform does not create it. Instead it must exist before you will use it. From docs:

dynamodb_table field to an existing DynamoDB table name.