Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error releasing the state lock #157

Open
definewbee opened this issue Mar 5, 2024 · 0 comments
Open

Error releasing the state lock #157

definewbee opened this issue Mar 5, 2024 · 0 comments
Labels
bug 🐛 An issue with the system

Comments

@definewbee
Copy link

Describe the Bug

when upload state to s3, then run 'terraform destroy --auto-approve' command, I've got error message: "Error releasing the state lock"

Expected Behavior

destroy correctly.

Steps to Reproduce

main.tf:

`provider "aws" {
region = "ap-northeast-1"
}

module "terraform_state_backend" {
source = "cloudposse/tfstate-backend/aws"

Cloud Posse recommends pinning every module to a specific version

version = "x.x.x"

namespace = "wasai"
stage = "test"
name = "terraform-example"
attributes = ["state"]

terraform_backend_config_file_path = "."
terraform_backend_config_file_name = "backend.tf"
force_destroy = false
}

resource "aws_instance" "example" {
ami = "ami-00247e9dc9591c233" # 指定 AMI ID
instance_type = "t2.micro" # 指定实例类型

tags = {
Name = "ExampleInstance" # 添加标签
Name = "test"
}
}`

  1. terraform init
  2. terraform plan
  3. terraform apply --auto-approve
  4. terraform init --force-copy
  5. terraform destroy --auto-approve

got error message:

Error: deleting S3 Bucket (wasai-test-terraform-example-state): operation error S3: DeleteBucket, https response error StatusCode: 409, RequestID: HYQKXS2B45JK65Z1, HostID: lB27Gd2tBiyKXf+gK2kUSdjams0k8MBkLCoWfiONz8i4rKCwUwWHp6r7HjJ4OuNOfubh1pFpIsM=, api error BucketNotEmpty: The bucket you tried to delete is not empty. You must delete all versions in the bucket.




│ Error: Error releasing the state lock

│ Error message: failed to retrieve lock info for lock ID "1caa2e0b-3858-49d0-0032-99423fc0914e": Unable to retrieve item from DynamoDB table "wasai-test-terraform-example-state-lock":
│ operation error DynamoDB: GetItem, https response error StatusCode: 400, RequestID: IUH3UIMJ76VK7U4QKG0C2ACQN3VV4KQNSO5AEMVJF66Q9ASUAAJG, ResourceNotFoundException: Requested resource not
│ found

│ Terraform acquires a lock when accessing your state to prevent others
│ running Terraform to potentially modify the state at the same time. An
│ error occurred while releasing this lock. This could mean that the lock
│ did or did not release properly. If the lock didn't release properly,
│ Terraform may not be able to run future commands since it'll appear as if
│ the lock is held.

│ In this scenario, please call the "force-unlock" command to unlock the
│ state manually. This is a very dangerous operation since if it is done
│ erroneously it could result in two people modifying state at the same time.
│ Only call this command if you're certain that the unlock above failed and
│ that no one else is holding a lock.

Screenshots

No response

Environment

OSX

Additional Context

No response

@definewbee definewbee added the bug 🐛 An issue with the system label Mar 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 An issue with the system
Projects
None yet
Development

No branches or pull requests

1 participant