Skip to content

Commit

Permalink
Reworked Go fund to del old projects
Browse files Browse the repository at this point in the history
 * Fix #
  • Loading branch information
paulpalamarchuk committed Nov 1, 2019
1 parent a9db806 commit 54694ae
Show file tree
Hide file tree
Showing 6 changed files with 211 additions and 190 deletions.
9 changes: 7 additions & 2 deletions modules/project_cleanup/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,17 @@ The following services must be enabled on the project housing the cleanup functi

| Name | Description | Type | Default | Required |
|------|-------------|:----:|:-----:|:-----:|
| job\_schedule | Cleaner function run frequency, in cron syntax | string | `"*/5 * * * *"` | no |
| max\_project\_age\_in\_hours | The maximum number of hours that a GCP project, selected by `target_tag_name` and `target_tag_value`, can exist | number | `"6"` | no |
| organization\_id | The organization ID whose projects to clean up | string | n/a | yes |
| project\_id | The project ID to host the scheduled function in | string | n/a | yes |
| region | The region the project is in (App Engine specific) | string | n/a | yes |
| target\_tag\_name | The name of a tag to filter GCP projects on for consideration by the cleanup utility | string | `"cft-ephemeral"` | no |
| target\_tag\_value | The value of a tag to filter GCP projects on for consideration by the cleanup utility | string | `"true"` | no |
| target\_excluded\_labels | Map of project lablels that won't be deleted. | map(string) | `<map>` | no |
| target\_folder\_id | Folder ID to delete all projects under. | string | `""` | no |
| target\_included\_labels | Map of project lablels that will be deleted. | map(string) | `<map>` | no |
| target\_tag\_name | The name of a tag to filter GCP projects on for consideration by the cleanup utility (legacy, use `target_included_labels` map instead). | string | `""` | no |
| target\_tag\_value | The value of a tag to filter GCP projects on for consideration by the cleanup utility (legacy, use `target_included_labels` map instead). | string | `""` | no |
| topic\_name | Name of pubsub topic connecting the scheduled projects cleanup function | string | `"pubsub_scheduled_project_cleaner"` | no |

## Outputs

Expand Down
11 changes: 7 additions & 4 deletions modules/project_cleanup/function_source/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
This is a simple utility that scans a GCP organization for projects matching certain criteria, and enqueues such projects for deletion. Currently supported criteria are the combination of:

- **Age:** Only projects older than the configured age, in hours, will be marked for deletion.
- **Key-Value Pair:** Only projects whose labels contain the provided key-value pair will be marked for deletion.
- **Key-Value Pair Include:** Only projects whose labels contain the provided key-value pair will be marked for deletion.
- **Key-Value Pair Exclude:** Projects whose labels contain the provided key-value pair won't be marked for deletion.
- **Folder ID:** Only projects under this Folder ID will be marked for deletion.

Both of these criteria must be met for a project to be deleted.

Expand All @@ -13,9 +15,10 @@ The following environment variables may be specified to configure the cleanup ut

| Name | Description | Type | Default | Required |
|------|-------------|:----:|:-----:|:-----:|
| `TARGET_TAG_NAME` | The tag name to match on for identifying projects to delete | string | n/a | yes |
| `TARGET_TAG_VALUE` | The tag value to match on for identifying projects to delete | string | n/a | yes |
| `MAX_PROJECT_AGE_HOURS` | The project age, in hours, at which point deletion should be considered | integer | n/a | yes |
| `TARGET_EXCLUDED_LABELS` | Labels to match on for identifying projects to avoid deletion | string | n/a | no |
| `TARGET_FOLDER_ID` | Folder ID to delete prjojects under | string | n/a | yes |
| `TARGET_INCLUDED_LABELS` | Labels to match on for identifying projects to delete | string | n/a | no |
| `MAX_PROJECT_AGE_HOURS` | The project age, in hours, at which point deletion should be considered | integer | n/a | no |

## Required Permissions

Expand Down
115 changes: 0 additions & 115 deletions modules/project_cleanup/function_source/go.sum

This file was deleted.

Loading

0 comments on commit 54694ae

Please sign in to comment.