terraform-provider-google/website/docs/r/logging_billing_account_sink.html.markdown
Marcin Niemira a9ad2b4669 Update logging_billing_account_sink.html.markdown (#3384)
* Update logging_billing_account_sink.html.markdown

fix issue in docs

* Fix same docs issue in logging_folder_sink logging_organization_sink and logging_project_sink
2019-05-07 15:47:40 -07:00

2.8 KiB

layout page_title sidebar_current description
google Google: google_logging_billing_account_sink docs-google-logging-billing-account-sink Manages a billing account logging sink.

google_logging_billing_account_sink

Manages a billing account logging sink. For more information see the official documentation and Exporting Logs in the API.

~> Note You must have the "Logs Configuration Writer" IAM role (roles/logging.configWriter) granted on the billing account to the credentials used with Terraform. IAM roles granted on a billing account are separate from the typical IAM roles granted on a project.

Example Usage

resource "google_logging_billing_account_sink" "my-sink" {
    name = "my-sink"
    billing_account = "ABCDEF-012345-GHIJKL"

    # Can export to pubsub, cloud storage, or bigquery
    destination = "storage.googleapis.com/${google_storage_bucket.log-bucket.name}"
}

resource "google_storage_bucket" "log-bucket" {
    name     = "billing-logging-bucket"
}

resource "google_project_iam_binding" "log-writer" {
    role = "roles/storage.objectCreator"

    members = [
        "${google_logging_billing_account_sink.my-sink.writer_identity}",
    ]
}

Argument Reference

The following arguments are supported:

  • name - (Required) The name of the logging sink.

  • billing_account - (Required) The billing account exported to the sink.

  • destination - (Required) 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:

"storage.googleapis.com/[GCS_BUCKET]"
"bigquery.googleapis.com/projects/[PROJECT_ID]/datasets/[DATASET]"
"pubsub.googleapis.com/projects/[PROJECT_ID]/topics/[TOPIC_ID]"
The writer associated with the sink must have access to write to the above resource.
  • filter - (Optional) The filter to apply when exporting logs. Only log entries that match the filter are exported. See Advanced Log Filters for information on how to write a filter.

Attributes Reference

In addition to the arguments listed above, the following computed attributes are exported:

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

Import

Billing account logging sinks can be imported using this format:

$ terraform import google_logging_billing_account_sink.my_sink billingAccounts/{{billing_account_id}}/sinks/{{sink_id}}