Skip to content
This repository has been archived by the owner on Jul 12, 2023. It is now read-only.

Commit

Permalink
Allow customizing log retention period
Browse files Browse the repository at this point in the history
  • Loading branch information
sethvargo committed Mar 2, 2021
1 parent a69c68b commit e18ffef
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
13 changes: 13 additions & 0 deletions terraform/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ resource "google_project_service" "services" {
"firebase.googleapis.com",
"iam.googleapis.com",
"identitytoolkit.googleapis.com",
"logging.googleapis.com",
"monitoring.googleapis.com",
"redis.googleapis.com",
"run.googleapis.com",
Expand Down Expand Up @@ -110,6 +111,18 @@ resource "google_vpc_access_connector" "connector" {
]
}

resource "google_logging_project_bucket_config" "basic" {
project = var.project
location = "global"
retention_days = var.log_retention_period
bucket_id = "_Default"

depends_on = [
google_project_service.services["logging.googleapis.com"],
google_project_service.services["stackdriver.googleapis.com"],
]
}

resource "null_resource" "build" {
provisioner "local-exec" {
environment = {
Expand Down
6 changes: 6 additions & 0 deletions terraform/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,12 @@ variable "enable_lb_logging" {
EOT
}

variable "log_retention_period" {
type = number
default = 14
description = "Number of days to retain logs"
}

// Note: in Cloud Run/Knative, there are two kinds of annotations.
// - Service level annotations: applies to all revisions in the service. E.g.
// the ingress restriction
Expand Down

0 comments on commit e18ffef

Please sign in to comment.