Skip to content

Commit 4c6c87c

Browse files
authored
Merge pull request #20 from paulpalamarchuk/update_cleanup_func_with_new_input
Reworked Go func to del old projects
2 parents a9db806 + 89e6494 commit 4c6c87c

File tree

7 files changed

+251
-186
lines changed

7 files changed

+251
-186
lines changed

modules/project_cleanup/README.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Old Project Cleanup Utility Module
22

3-
This module schedules a job to clean up GCP projects older than a specified length of time, that match a particular key-value pair. This job runs every 5 minutes via Google Cloud Scheduled Functions. Please see the [utility's readme](./function_source/README.md) for more information as to its operation and configuration.
3+
This module schedules a job to clean up GCP projects older than a specified length of time, that match a particular labels. This job runs every 5 minutes via Google Cloud Scheduled Functions. Please see the [utility's readme](./function_source/README.md) for more information as to its operation and configuration.
44

55
## Requirements
66

@@ -21,12 +21,17 @@ The following services must be enabled on the project housing the cleanup functi
2121

2222
| Name | Description | Type | Default | Required |
2323
|------|-------------|:----:|:-----:|:-----:|
24+
| job\_schedule | Cleaner function run frequency, in cron syntax | string | `"*/5 * * * *"` | no |
2425
| 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 |
2526
| organization\_id | The organization ID whose projects to clean up | string | n/a | yes |
2627
| project\_id | The project ID to host the scheduled function in | string | n/a | yes |
2728
| region | The region the project is in (App Engine specific) | string | n/a | yes |
28-
| target\_tag\_name | The name of a tag to filter GCP projects on for consideration by the cleanup utility | string | `"cft-ephemeral"` | no |
29-
| target\_tag\_value | The value of a tag to filter GCP projects on for consideration by the cleanup utility | string | `"true"` | no |
29+
| target\_excluded\_labels | Map of project lablels that won't be deleted. | map(string) | `<map>` | no |
30+
| target\_folder\_id | Folder ID to delete all projects under. | string | `""` | no |
31+
| target\_included\_labels | Map of project lablels that will be deleted. | map(string) | `<map>` | no |
32+
| 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 |
33+
| 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 |
34+
| topic\_name | Name of pubsub topic connecting the scheduled projects cleanup function | string | `"pubsub_scheduled_project_cleaner"` | no |
3035

3136
## Outputs
3237

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
go.mod
2+
go.sum
3+
pkg
4+
README.md

modules/project_cleanup/function_source/README.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
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:
44

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

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

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

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

2023
## Required Permissions
2124

modules/project_cleanup/function_source/go.sum

Lines changed: 0 additions & 115 deletions
This file was deleted.

0 commit comments

Comments
 (0)