Google Cloud (Stackdriver) Logging Organization Bucket Config

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

google_logging_organization_bucket_config (Terraform)

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

Example Usage from GitHub

logging_organization_bucket_config_test.tf#L6
resource "google_logging_organization_bucket_config" "basic" {
  organization   = "1" # fake
  location       = "global"
  retention_days = 30
  bucket_id      = "_Default"
}
logging_organization_bucket_config_test.tf#L6
resource "google_logging_organization_bucket_config" "basic" {
  organization   = "1" # fake
  location       = "global"
  retention_days = 30
  bucket_id      = "_Default"
}
main.tf#L7
resource "google_logging_organization_bucket_config" "this" {
  bucket_id      = var.bucket_id
  description    = var.description
  location       = var.location
  organization   = var.organization
  retention_days = var.retention_days
main.tf#L35
resource "google_logging_organization_bucket_config" "bucket" {
  count          = var.parent_type == "organization" ? 1 : 0
  organization   = 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.

  • 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

  • organization required - string
    • The parent resource that contains the logging 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 organization-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 Organization Bucket Config?

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

For Terraform, the gilyas/infracost, infracost/infracost and niveklabs/google 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.