From 4fd3b56b3544556194ba7e390bd52220bd1d7d33 Mon Sep 17 00:00:00 2001 From: Joe Selman Date: Tue, 26 Sep 2017 15:26:54 -0700 Subject: [PATCH] Add resource_logging_billing_account_sink resource (#457) * Add resource_logging_billing_account_sink resource * Fix bad style --- ...logging_billing_account_sink.html.markdown | 69 +++++++++++++++++++ docs/r/logging_project_sink.html.markdown | 2 +- google.erb | 4 ++ 3 files changed, 74 insertions(+), 1 deletion(-) create mode 100644 docs/r/logging_billing_account_sink.html.markdown diff --git a/docs/r/logging_billing_account_sink.html.markdown b/docs/r/logging_billing_account_sink.html.markdown new file mode 100644 index 00000000000..5063de7f20f --- /dev/null +++ b/docs/r/logging_billing_account_sink.html.markdown @@ -0,0 +1,69 @@ +--- +layout: "google" +page_title: "Google: google_logging_billing-account_sink" +sidebar_current: "docs-google-logging-billing-account-sink" +description: |- + Manages a billing account logging sink. +--- + +# google\_logging\_billing\_account\_sink + +Manages a billing account logging sink. For more information see +[the official documentation](https://cloud.google.com/logging/docs/) and +[Exporting Logs in the API](https://cloud.google.com/logging/docs/api/tasks/exporting-logs). + +Note that you must have the "Logs Configuration Writer" IAM role (`roles/logging.configWriter`) +granted to the credentials used with terraform. + +## Example Usage + +```hcl +resource "google_logging_billing_account_sink" "my-sink" { + name = "my-sink" + billing_account = "ABCDEF-012345-GHIJKL" + + # Can export to pubsub, cloud storage, or bigtable + 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)[https://cloud.google.com/logging/docs/view/advanced_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`. diff --git a/docs/r/logging_project_sink.html.markdown b/docs/r/logging_project_sink.html.markdown index 653834a4a10..7f2f80bf1dd 100644 --- a/docs/r/logging_project_sink.html.markdown +++ b/docs/r/logging_project_sink.html.markdown @@ -59,7 +59,7 @@ resource "google_compute_instance" "my-logged-instance" { } } -# A bucket to storage logs in. +# A bucket to store logs in resource "google_storage_bucket" "log-bucket" { name = "my-unique-logging-bucket" } diff --git a/google.erb b/google.erb index e09fc5a87db..7350c554763 100644 --- a/google.erb +++ b/google.erb @@ -342,6 +342,10 @@ > Google Stackdriver Logging Resources