After changing the Terraform files by hand, I realized that I have Terraform resources created on AWS.

But I can't do a terraform destroy -auto-approve, because the existing Terraform files are still there, and there's conflicts in the definition that I can't resolve.

So, I moved the Terraform files away, and started with no files, then used the following commands:

  • terraform init
  • echo "ap-southeast-1" | terraform import -allow-missing-config aws_ami ami-xxxxxxx && echo "ap-southeast-1" | terraform destroy -auto-approve
This allowed me to import the missing resources by their ID and resource, which was AWS AMIs, and delete them automatically.

Another lesson learnt ;o)