Opsworks stack does not go down with 'terraform destroy'

Though i am new with Terraform, i am facing this issue. What i did and the sequence i followed:

  • Created a stack of opsworks
  • Created an EC2 instance and ran "aws opsworks register … " to register it with the above opsworks
  • All working fine.

Now when i want to destroy the infratructure (with “terraform destroy”), terraform is not able to remove the opswork stack, and complains for regitered instances. How can we get these EC2 instances unregisteres (stop and delete) and then the opswork stack is brought down.

I think i am missing some sequence in created the EC2 instance and the opsworks stack.

To successfully destroy an OpsWorks stack with Terraform, you need to ensure that all registered instances are deregistered first.