You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
| billing\_account | Billing Account used to provision resources. |`string`|`""`| no |
30
+
| clean\_up\_billing\_sinks | Clean up Billing Account Sinks. |`bool`|`false`| no |
27
31
| clean\_up\_org\_level\_cai\_feeds | Clean up organization level Cloud Asset Inventory Feeds. |`bool`|`false`| no |
28
32
| clean\_up\_org\_level\_scc\_notifications | Clean up organization level Security Command Center notifications. |`bool`|`false`| no |
29
33
| clean\_up\_org\_level\_tag\_keys | Clean up organization level Tag Keys. |`bool`|`false`| no |
30
34
| function\_timeout\_s | The amount of time in seconds allotted for the execution of the function. |`number`|`500`| no |
31
35
| job\_schedule | Cleaner function run frequency, in cron syntax |`string`|`"*/5 * * * *"`| no |
36
+
| list\_billing\_sinks\_page\_size | The maximum number of Billing Account Log Sinks to return in the call to `BillingAccountsSinksService.List` service. |`number`|`200`| no |
32
37
| list\_scc\_notifications\_page\_size | The maximum number of notification configs to return in the call to `ListNotificationConfigs` service. The minimun value is 1 and the maximum value is 1000. |`number`|`500`| no |
33
38
| 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 |
34
39
| organization\_id | The organization ID whose projects to clean up |`string`| n/a | yes |
35
40
| project\_id | The project ID to host the scheduled function in |`string`| n/a | yes |
36
41
| region | The region the project is in (App Engine specific) |`string`| n/a | yes |
42
+
| target\_billing\_sinks | List of Billing Account Log Sinks names regex that will be deleted. Regex example: `.*/sinks/sk-c-logging-.*-billing-.*`|`list(string)`|`[]`| no |
37
43
| target\_excluded\_labels | Map of project lablels that won't be deleted. |`map(string)`|`{}`| no |
38
44
| target\_excluded\_tagkeys | List of organization Tag Key short names that won't be deleted. |`list(string)`|`[]`| no |
39
45
| target\_folder\_id | Folder ID to delete all projects under. |`string`|`""`| no |
40
46
| target\_included\_feeds | List of organization level Cloud Asset Inventory feeds that should be deleted. Regex example: `.*/feeds/fd-cai-monitoring-.*`|`list(string)`|`[]`| no |
41
47
| target\_included\_labels | Map of project lablels that will be deleted. |`map(string)`|`{}`| no |
42
-
| target\_included\_scc\_notifications | List of organization Security Command Center notifications names regex that will be deleted. Regex example: `.*/notificationConfigs/scc-notify-.*`|`list(string)`|`[]`| no |
48
+
| target\_included\_scc\_notifications | List of organization Security Command Center notifications names regex that will be deleted. Regex example: `.*/notificationConfigs/scc-notify-.*`|`list(string)`|`[]`| no |
43
49
| 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 |
44
50
| 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 |
45
51
| topic\_name | Name of pubsub topic connecting the scheduled projects cleanup function |`string`|`"pubsub_scheduled_project_cleaner"`| no |
Copy file name to clipboardExpand all lines: modules/project_cleanup/function_source/README.md
+14-1
Original file line number
Diff line number
Diff line change
@@ -15,11 +15,24 @@ The following environment variables may be specified to configure the cleanup ut
15
15
16
16
| Name | Description | Type | Default | Required |
17
17
|------|-------------|:----:|:-----:|:-----:|
18
+
|`BILLING_ACCOUNT`| Billing Account used to provision resources. |`string`| n/a | no |
19
+
|`BILLING_SINKS_PAGE_SIZE `| The maximum number of Billing Account Log Sinks to return in the call to `BillingAccountsSinksService.List` service. |`number`| n/a | yes |
|`CLEAN_UP_SCC_NOTIFICATIONS`| Clean up organization level Security Command Center notifications. |`bool`| n/a | yes |
23
+
|`CLEAN_UP_TAG_KEYS`| Clean up organization level Tag Keys. |`bool`| n/a | yes |
24
+
|`MAX_PROJECT_AGE_HOURS`| The project age, in hours, at which point deletion should be considered | integer | n/a | yes |
25
+
|`SCC_NOTIFICATIONS_PAGE_SIZE`| The maximum number of notification configs to return in the call to `ListNotificationConfigs` service. The minimun value is 1 and the maximum value is 1000. |`number`| n/a | yes |
26
+
|`TARGET_BILLING_SINKS`| List of Billing Account Log Sinks names regex that will be deleted. Regex example: `.*/sinks/sk-c-logging-.*-billing-.*`|`list(string)`| n/a | no |
18
27
|`TARGET_EXCLUDED_LABELS`| Labels to match on for identifying projects to avoid deletion | string | n/a | no |
28
+
|`TARGET_EXCLUDED_TAGKEYS`| List of organization Tag Key short names that won't be deleted. |`list(string)`| n/a | no |
19
29
|`TARGET_FOLDER_ID`| Folder ID to delete projects under | string | n/a | yes |
30
+
|`TARGET_INCLUDED_FEEDS`| List of organization level Cloud Asset Inventory feeds that should be deleted. Regex example: `.*/feeds/fd-cai-monitoring-.*`|`list(string)`| n/a | no |
20
31
|`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 | yes |
32
+
|`TARGET_INCLUDED_SCC_NOTIFICATIONS`| List of organization Security Command Center notifications names regex that will be deleted. Regex example: `.*/notificationConfigs/scc-notify-.*`|`list(string)`| n/a | no |
33
+
|`TARGET_ORGANIZATION_ID`| The organization ID whose projects to clean up |`string`| n/a | yes |
22
34
23
35
## Required Permissions
24
36
25
37
This Cloud Function must be run as a Service Account with the `Organization Administrator` (`roles/resourcemanager.organizationAdmin`) role.
38
+
If `CLEAN_UP_BILLING_SINKS` is enabled the Service Account running the Cloud Function needs role Logs Configuration Writer(`roles/logging.configWriter`) in the billing account `BILLING_ACCOUNT`.
logger.Fatalf("Could not convert [%s] to integer. Specify correct value for environment variable [%s] and try again.", maxAgeInHoursStr, MaxProjectAgeHours)
logger.Fatalf("Clean up Tag Keys environment variable [%s] not set, set the environment variable and try again.", CleanUpTagKeys)
276
-
}
277
-
result, err:=strconv.ParseBool(cleanUpTagKeys)
278
-
iferr!=nil {
279
-
logger.Fatalf("Invalid Clean up Tag Keys value [%s], specify correct value for environment variable [%s] and try again.", cleanUpTagKeys, CleanUpTagKeys)
logger.Fatalf("Invalid Clean up SCC notifications value [%s], specify correct value for environment variable [%s] and try again.", cleanUpSCCNotfiVal, CleanUpSCCNotfi)
280
+
logger.Fatalf("Invalid bool value [%s], specify correct value for environment variable [%s] and try again.", envVariableNameVal, envVariableName)
logger.Printf("Failed to get CAI Feeds list from [%s] env variable, error [%s]", envVariableName, err.Error())
318
-
returnnil
319
-
} else {
320
-
logger.Printf("Got CAI Feeds list [%s] from [%s] env variable", caiFeeds, envVariableName)
321
-
}
322
-
323
-
//build Regexes
324
-
for_, r:=rangecaiFeeds {
325
-
result, err:=regexp.Compile(r)
326
-
iferr!=nil {
327
-
logger.Printf("Invalid regular expression [%s] for CAI Feed", r)
328
-
} else {
329
-
compiledRegEx=append(compiledRegEx, result)
330
-
}
289
+
logger.Fatalf("Could not convert [%s] to integer. Specify correct value for environment variable [%s] and try again.", envVariableStr, envVariableName)
logger.Fatalf("Clean up CAI Feeds environment variable [%s] not set, set the environment variable and try again.", CleanUpCaiFeeds)
339
-
}
340
-
result, err:=strconv.ParseBool(cleanUpCaiFeeds)
341
-
iferr!=nil {
342
-
logger.Fatalf("Invalid Clean up CAI Feeds value [%s], specify correct value for environment variable [%s] and try again.", cleanUpCaiFeeds, CleanUpCaiFeeds)
0 commit comments