Google Cloud (Stackdriver) Logging Folder Bucket Config

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

google_logging_folder_bucket_config (Terraform)

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

Example Usage from GitHub

logging_folder_bucket_config_test.tf#L6
resource "google_logging_folder_bucket_config" "basic" {
  folder         = "fake"
  location       = "global"
  retention_days = 30
  bucket_id      = "_Default"
}
logging_folder_bucket_config_test.tf#L6
resource "google_logging_folder_bucket_config" "basic" {
  folder         = "fake"
  location       = "global"
  retention_days = 30
  bucket_id      = "_Default"
}
main.tf#L1
resource "google_logging_folder_bucket_config" "bucket_config" {
  count          = length(var.bucket_config)
  bucket_id      = lookup(var.bucket_config[count.index], "bucket_id", "_Default")
  folder         = element(var.folder, lookup(var.bucket_config[count.index], "folder_id"))
  location       = lookup(var.bucket_config[count.index], "location", "global")
  description    = lookup(var.bucket_config[count.index], "description", null)
main.tf#L7
resource "google_logging_folder_bucket_config" "this" {
  bucket_id      = var.bucket_id
  description    = var.description
  folder         = var.folder
  location       = var.location
  retention_days = var.retention_days
main.tf#L26
resource "google_logging_folder_bucket_config" "bucket" {
  count          = var.parent_type == "folder" ? 1 : 0
  folder         = var.parent
  location       = var.location
  retention_days = var.retention
  bucket_id      = var.id

Parameters

  • bucket_id required - string
    • The name of the logging bucket. Logging automatically creates two log buckets: _Required and _Default.

  • description optionalcomputed - string
    • An optional description for this bucket.

  • folder required - string
    • The parent resource that contains the logging bucket.

  • id optionalcomputed - string
  • lifecycle_state requiredcomputed - string
    • The bucket's lifecycle such as active or deleted.

  • location required - string
    • The location of the bucket.

  • name requiredcomputed - string
    • The resource name of the bucket

  • retention_days optional - number
    • 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 folder-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 Folder Bucket Config?

Google Cloud (Stackdriver) Logging Folder 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 Folder 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.

security-icon

Scan your IaC problem in 3 minutes for free

You can keep your IaC security for free. No credit card required.