Error releasing the state lock
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" } }`
- terraform init
- terraform plan
- terraform apply --auto-approve
- terraform init --force-copy
- 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