Google Cloud (Stackdriver) Logging Billing Account Sink

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


Fix issues in your cloud & app configurations

Test for misconfigurations of this resource in your cloud.


Terraform Example (google_logging_billing_account_sink)


  • billing_account required - string
    • The billing account exported to the sink.

  • description optional - string
    • A description of this sink. The maximum length of the description is 8000 characters.

  • destination required - string
    • The destination of the sink (or, in other words, where logs are written to). Can be a Cloud Storage bucket, a PubSub topic, or a BigQuery dataset. Examples: "[GCS_BUCKET]" "[PROJECT_ID]/datasets/[DATASET]" "[PROJECT_ID]/topics/[TOPIC_ID]" The writer associated with the sink must have access to write to the above resource.

  • disabled optional - bool
    • If set to True, then this sink is disabled and it does not export any log entries.

  • filter optional - string
    • The filter to apply when exporting logs. Only log entries that match the filter are exported.

  • id optionalcomputed - string
  • name required - string
    • The name of the logging sink.

  • writer_identity requiredcomputed - string
    • The identity associated with this sink. This identity must be granted write access to the configured destination.

Example Usage (from GitHub)

resource "google_logging_billing_account_sink" "basic" {
  name            = "my-sink"
  description     = "what it is"
  billing_account = "00AA00-000AAA-00AA0A" # fake

  destination = ""
resource "google_logging_billing_account_sink" "basic" {
  name            = "my-sink"
  description     = "what it is"
  billing_account = "00AA00-000AAA-00AA0A" # fake

  destination = ""
resource "google_logging_billing_account_sink" "sink" {
  count           = length(var.sink)
  billing_account = element(var.billing_account, lookup(var.sink[count.index], "billing_account_id"))
  destination     = element(var.destination, lookup(var.sink[count.index], "destination_id"))
  name            = lookup(var.sink[count.index], "name")
  filter          = lookup(var.sink[count.index], "filter")
resource "google_logging_billing_account_sink" "this" {
  billing_account = var.billing_account
  destination     = var.destination
  filter          = var.filter
  name            =

Frequently asked questions

What is Google Cloud (Stackdriver) Logging Billing Account Sink?

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

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