GoogleCloudPlatform / cloud-foundation-toolkit

The Cloud Foundation toolkit provides GCP best practices as code.
Apache License 2.0
947 stars 450 forks source link

Add infrastructure for cleaning up old test projects #400

Closed morgante closed 4 years ago

morgante commented 4 years ago

We need to add infrastructure for cleaning up old test projects so they don't continue to cost us money. The work involved should be:

  1. Updating this module with additional inputs:
    • A provided folder ID to delete all projects under (see #306 for reference) unless
    • A provided exclude_label value is provided (ex. exclude_labels: {cft-testing: persistent})
  2. Adding a config in infra/terraform/test-org/test-cleanup/ which sources the project cleanup module and instantiates it on our org. Work began on this here, please pick up from that PR.
paulpalamarchuk commented 4 years ago

@morgante Additional input exclude_labels should be string or list of strings? If it's list, then it have to be JSON format or YAML, or any other format? Should exclude_labels input value ignore folder ID? (Affects all projects, not only under the folder) Should, also folder ID affect old inputs?

morgante commented 4 years ago

exclude_labels should be a map of key/value pairs (in Terraform). It should be combined with folder ID.

So the workflow is that all projects under folder_id without an excluded label will be deleted.

aaron-lane commented 4 years ago

@paulpalamarchuk can you clarify what you mean by

folder ID affect old inputs

paulpalamarchuk commented 4 years ago

@aaron-lane If folder_id is not set, does the func have to delete all the projects(which have defined labels) within the org? I think it's unsafe.

morgante commented 4 years ago

@aaron-lane If folder_id is not set, does the func have to delete all the projects(which have defined labels) within the org? I think it's unsafe.

I think we can make folder_id required.