Google Cloud (Stackdriver) Logging Billing Account Bucket Config

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

google_logging_billing_account_bucket_config (Terraform)

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

Example Usage from GitHub
resource "google_logging_billing_account_bucket_config" "basic" {
  billing_account = "00AA00-000AAA-00AA0A" # fake
  location        = "global"
  retention_days  = 30
  bucket_id       = "_Default"
resource "google_logging_billing_account_bucket_config" "basic" {
  billing_account = "00AA00-000AAA-00AA0A" # fake
  location        = "global"
  retention_days  = 30
  bucket_id       = "_Default"
resource "google_logging_billing_account_bucket_config" "bucket_config" {
  count           = length(var.bucket_config)
  billing_account = var.billing_account
  bucket_id       = element(var.bucket_id, lookup(var.bucket_config[count.index], "bucket_id"))
  location        = lookup(var.bucket_config[count.index], "location", "global")
  retention_days  = lookup(var.bucket_config[count.index], "retention_days")
resource "google_logging_billing_account_bucket_config" "this" {
  billing_account = var.billing_account
  bucket_id       = var.bucket_id
  description     = var.description
  location        = var.location
  retention_days  = var.retention_days
resource "google_logging_billing_account_bucket_config" "bucket" {
  count           = var.parent_type == "billing_account" ? 1 : 0
  billing_account = var.parent
  location        = var.location
  retention_days  = var.retention
  bucket_id       =

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).


The parent resource that contains the logging bucket.

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

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 billing account 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 Billing Account Bucket Config?

Google Cloud (Stackdriver) Logging Billing Account 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 Billing Account Bucket Config?

For Terraform, the gilyas/infracost, infracost/infracost and mikamakusa/terraform source code examples are useful. See the Terraform Example section for further details.


Automate config file reviews on your commits

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