Closed jckuester closed 4 years ago
I am closing this issue as the approach to add new resources changed a lot: All code to list resources is planned to be generated via the awsls project, so the generator would be the place if you want to contribute. Deletion happens via the Terraform AWS Provider, so individual functions to delete resources are not needed.
The following explanation hopefully makes it easy contributing the resources you need to this project. As an example, we go through adding the resource
aws_vpc
(which is already supported).1) Add Terraform type ID of the new resource type
Fine the terraform name of the AWS resource type to support (here is a list of all existing resource types) and add it to resource/supported.go.
2) Add function to list resources
Add here a function that lists all resources of the new resource type. For this you need to find the method of the AWS go API to list all VPCs (you find it by looking in the go doc of the AWS API)
Supported resources need to be added to resource/supported.go.
3) Add delete ID
The field name of the ID used by Terraform to delete the resource. For this we actually have to look in the delete method of the AWS provider for the VPC
4) Add custom filter method
In most cases can be left as
filterGeneric
. Some resources require custom filter methods.5) Integration tests
Solid testing is necessary, since we don't want this tool to delete resources unexpectedly :-) Integration tests for each resource have its own file; the ones for
aws_vpc
are in test/vpc_test.go.The test for each resource is structured as follows:
aws_vpc
(one with ID/tag foo, another with ID/tag bar)