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
resource "google_logging_project_bucket_config" "basic" {
project = "fake"
location = "global"
retention_days = 30
bucket_id = "_Default"
}
resource "google_logging_project_bucket_config" "default" {
project = var.PROJECT.name
location = "global"
retention_days = 1825
bucket_id = "_Default"
}
resource "google_logging_project_bucket_config" "basic" {
project = "amarello-interno-terraform"
location = "global"
retention_days = 30
bucket_id = "_Default"
resource "google_logging_project_bucket_config" "basic" {
project = "fake"
location = "global"
retention_days = 30
bucket_id = "_Default"
}
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
Parameters
-
bucket_id
required - string
The name of the logging bucket. Logging automatically creates two log buckets: _Required and _Default.
-
description
optional computed - string
An optional description for this bucket.
-
id
optional computed - string -
lifecycle_state
optional computed - string
The bucket's lifecycle such as active or deleted.
-
location
required - string
The location of the bucket.
-
name
optional computed - string
The resource name of the bucket
-
project
required - string
The parent project 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 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.