jckuester / awsweeper

A tool for cleaning your AWS account
Mozilla Public License 2.0
469 stars 45 forks source link

enhancement: use terraform data lookup to enumerate resources #32

Closed harkamals closed 4 years ago

harkamals commented 5 years ago

Suggestion to not use aws sdk describe-* API to enumerate instances, instead use output of terraform data lookups. This makes more sense we use terraform to delete resources so why not offload discovery too.

` data "aws_instances" "ec2" { instance_tags { Name = "*" } instance_state_names = ["running", "stopped"] }

output "ec2" { value = "${data.aws_instances.ec2.ids}" } `

jckuester commented 5 years ago

I totally agree. This way, probably, more resources can be supported more easily. I guess, it would be best (like I did in the wipe function), to use the Terraform API in some way for the lookups.

jckuester commented 4 years ago

Unfortunately, the approach of using data sources to discover resources does only work for a few resource types. The approach for discovery I am using is via the https://github.com/jckuester/awsls project.