Skip to content

Expose function_timeout_s on project_cleanup #23

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 20, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning][semver-site].

## [Unreleased]

### Added

- The `function_timeout_s` variable is exposed on the `project_cleanup` submodule.

## [1.1.1] - 2019-11-13

### Fixed
Expand Down
6 changes: 3 additions & 3 deletions modules/project_cleanup/function_source/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,9 +219,9 @@ func invoke(ctx context.Context) {
requestFilter := fmt.Sprintf("parent.type:folder parent.id:%s", localFolderId)
req := cloudResourceManagerService.Projects.List().Filter(requestFilter)
if err := req.Pages(ctx, processProjectsResponsePage(removeProjectWithLiens)); err != nil {
logger.Printf("Fail to get projects for the forlder with id [%s], error [%s]", localFolderId, err.Error())
logger.Printf("Fail to get projects for the folder with id [%s], error [%s]", localFolderId, err.Error())
} else {
logger.Printf("Got and processed all projects for the forlder with id [%s]", localFolderId)
logger.Printf("Got and processed all projects for the folder with id [%s]", localFolderId)
}
}

Expand All @@ -234,7 +234,7 @@ func invoke(ctx context.Context) {
removeProjectsInFolder(folderId)
return nil
}); err != nil {
logger.Fatalf("Fail to get subfolders for the forlder with id [%s], error [%s]", folderId, err.Error())
logger.Fatalf("Fail to get subfolders for the folder with id [%s], error [%s]", folderId, err.Error())
}
}

Expand Down
1 change: 1 addition & 0 deletions modules/project_cleanup/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ module "scheduled_project_cleaner" {
function_description = "Clean up GCP projects older than ${var.max_project_age_in_hours} hours matching particular tags"
function_runtime = "go111"
function_service_account_email = google_service_account.project_cleaner_function.email
function_timeout_s = var.function_timeout_s

function_environment_variables = {
TARGET_EXCLUDED_LABELS = jsonencode(var.target_excluded_labels)
Expand Down
6 changes: 6 additions & 0 deletions modules/project_cleanup/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@
* limitations under the License.
*/

variable "function_timeout_s" {
type = number
default = 60
description = "The amount of time in seconds allotted for the execution of the function."
}

variable "organization_id" {
type = string
description = "The organization ID whose projects to clean up"
Expand Down