EC2/VPC Teardown with Ansible - How should I do it?

Hi Experts,

This is my first time posting here. I’m just starting to learn ansible and I’ve noticed there are lots of tutorials on how to create ec2 instances/vpcs but not a lot of information on how to tear them down. Some of what I’m doing is problematic because I have to reverse-engineer my dependencies in AWS, but I’d also like to figure out what the best approach is. Right now, I have separate build and teardown playbooks and then I’m using dynamic inventory. This is not idempotent, so I should probably use *_facts, I think, but I’m pretty sure that will also be slow. I’ve thought about using fact caching but that could be slow as well.

I’d like to hear how people here recommend approaching this. I’d like to avoid hardcoding as much as possible. I’m having trouble figuring out how to use tagging to get the information I created in the build stage into the teardown stage. I’m using the latest ansible (2.7.14) and the documentation seems to vary between versions, so I thought I’d check in to see what the latest wisdom is on this

John