Error: EBS Volume in unexpected state after deletion: available

Hello,

Terraform v0.12.20

  • provider.aws v2.61.1

I received an error while deleting EBS volume:

Error: EBS Volume in unexpected state after deletion: available. I know it’s AWS glitch but terraform is not able to recover from this error.

In the state file after this error, it’s not showing that resource is tainted - it shows as a regular status:

“module”: “module.firefly_EC2”,
“mode”: “managed”,
“type”: “aws_ebs_volume”,
“name”: “default”,
“each”: “map”,
“provider”: “provider.aws”,
“instances”: [
{
“index_key”: “opstest-Firefly-Firefly-B1./dev/sdg”,
“schema_version”: 0,
“attributes”: {

When I am trying to refresh the state it gives another error:
Error: Invalid function argument

 ../../../modules/Cluster/EC2/main.tf line 60, in resource "aws_volume_attachment" "default":
  60:     volume_id   = lookup(aws_ebs_volume.default, each.key).id
    |----------------
    | aws_ebs_volume.default is object with 3 attributes

Invalid value for "inputMap" parameter: the given object has no attribute
"opstest-Firefly-Firefly-B1./dev/sdg".

State file is empty except with this 1 corrupted EBS.

Is there a workaround for this?