Google Cloud (Stackdriver) Logging Project Bucket Config

This page shows how to write Terraform for Cloud (Stackdriver) Logging Project Bucket Config and write them securely.

google_logging_project_bucket_config (Terraform)

The Project Bucket Config in Cloud (Stackdriver) Logging can be configured in Terraform with the resource name google_logging_project_bucket_config. The following sections describe 5 examples of how to use the resource and its parameters.

Example Usage from GitHub

logging_project_bucket_config_test.tf#L6
resource "google_logging_project_bucket_config" "basic" {
  project        = "fake"
  location       = "global"
  retention_days = 30
  bucket_id      = "_Default"
}
06_logging.tf#L2
resource "google_logging_project_bucket_config" "default" {
  project = var.PROJECT.name
  location = "global"
  retention_days = 1825
  bucket_id = "_Default"
}
logging.tf#L1
resource "google_logging_project_bucket_config" "basic" {
    project    = "amarello-interno-terraform"
    location  = "global"
    retention_days = 30
    bucket_id = "_Default"
logging_project_bucket_config_test.tf#L6
resource "google_logging_project_bucket_config" "basic" {
  project        = "fake"
  location       = "global"
  retention_days = 30
  bucket_id      = "_Default"
}
main.tf#L7
resource "google_logging_project_bucket_config" "this" {
  bucket_id      = var.bucket_id
  description    = var.description
  location       = var.location
  project        = var.project
  retention_days = var.retention_days

Review your Terraform file for Google best practices

Shisho Cloud, our free checker to make sure your Terraform configuration follows best practices, is available (beta).

Parameters

The name of the logging bucket. Logging automatically creates two log buckets: _Required and _Default.

An optional description for this bucket.

The bucket's lifecycle such as active or deleted.

The location of the bucket.

  • name optional computed - string

The resource name of the bucket

The parent project that contains the logging bucket.

Logs will be retained by default for this amount of time, after which they will automatically be deleted. The minimum retention period is 1 day. If this value is set to zero at bucket creation time, the default time of 30 days will be used.

Explanation in Terraform Registry

Manages a project-level logging bucket config. For more information see the official logging documentation and Storing Logs.

Note: Logging buckets are automatically created for a given folder, project, organization, billingAccount and cannot be deleted. Creating a resource of this type will acquire and update the resource that already exists at the desired location. These buckets cannot be removed so deleting this resource will remove the bucket config from your terraform state but will leave the logging bucket unchanged. The buckets that are currently automatically created are "_Default" and "_Required".

Frequently asked questions

What is Google Cloud (Stackdriver) Logging Project Bucket Config?

Google Cloud (Stackdriver) Logging Project Bucket Config is a resource for Cloud (Stackdriver) Logging of Google Cloud Platform. Settings can be wrote in Terraform.

Where can I find the example code for the Google Cloud (Stackdriver) Logging Project Bucket Config?

For Terraform, the gilyas/infracost, synaptic-cl/SYNAPTIC-bot_monitor and jlagohuertaq/tf-logging-project source code examples are useful. See the Terraform Example section for further details.

security-icon

Automate config file reviews on your commits

Fix issues in your infrastructure as code with auto-generated patches.