Skip to content

Commit

Permalink
Change the default value of unique_writer_identity in resource loggin…
Browse files Browse the repository at this point in the history
…g_project_sink to true. (#8875) (#6210)

Signed-off-by: Modular Magician <[email protected]>
  • Loading branch information
modular-magician authored Sep 6, 2023
1 parent 9bdaaa0 commit a4ddeb0
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 32 deletions.
3 changes: 3 additions & 0 deletions .changelog/8875.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:breaking-change
logging: changed the default value of `unique_writer_identity` from `false` to `true` in `google_logging_project_sink`.
```
6 changes: 4 additions & 2 deletions google-beta/services/logging/resource_logging_project_sink.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0
package logging

import (
Expand Down Expand Up @@ -38,9 +40,9 @@ func ResourceLoggingProjectSink() *schema.Resource {
schm.Schema["unique_writer_identity"] = &schema.Schema{
Type: schema.TypeBool,
Optional: true,
Default: false,
Default: true,
ForceNew: true,
Description: `Whether or not to create a unique identity associated with this sink. If false (the default), then the writer_identity used is serviceAccount:[email protected]. If true, then a unique service account is created and used for this sink. If you wish to publish logs across projects, you must set unique_writer_identity to true.`,
Description: `Whether or not to create a unique identity associated with this sink. If false (the legacy behavior), then the writer_identity used is serviceAccount:[email protected]. If true, then a unique service account is created and used for this sink. If you wish to publish logs across projects, you must set unique_writer_identity to true.`,
}
return schm
}
Expand Down
50 changes: 20 additions & 30 deletions google-beta/services/logging/resource_logging_project_sink_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -294,13 +294,11 @@ func testAccLoggingProjectSink_basic(name, project, bucketName string) string {
resource "google_logging_project_sink" "basic" {
name = "%s"
project = "%s"
destination = "storage.googleapis.com/${google_storage_bucket.log-bucket.name}"
destination = "storage.googleapis.com/${google_storage_bucket.gcs-bucket.name}"
filter = "logName=\"projects/%s/logs/compute.googleapis.com%%2Factivity_log\" AND severity>=ERROR"
unique_writer_identity = false
}
resource "google_storage_bucket" "log-bucket" {
resource "google_storage_bucket" "gcs-bucket" {
name = "%s"
location = "US"
}
Expand All @@ -312,14 +310,12 @@ func testAccLoggingProjectSink_described(name, project, bucketName string) strin
resource "google_logging_project_sink" "described" {
name = "%s"
project = "%s"
destination = "storage.googleapis.com/${google_storage_bucket.log-bucket.name}"
destination = "storage.googleapis.com/${google_storage_bucket.gcs-bucket.name}"
filter = "logName=\"projects/%s/logs/compute.googleapis.com%%2Factivity_log\" AND severity>=ERROR"
description = "this is a description for a project level logging sink"
unique_writer_identity = false
}
resource "google_storage_bucket" "log-bucket" {
resource "google_storage_bucket" "gcs-bucket" {
name = "%s"
location = "US"
}
Expand All @@ -331,14 +327,12 @@ func testAccLoggingProjectSink_described_update(name, project, bucketName string
resource "google_logging_project_sink" "described" {
name = "%s"
project = "%s"
destination = "storage.googleapis.com/${google_storage_bucket.log-bucket.name}"
destination = "storage.googleapis.com/${google_storage_bucket.gcs-bucket.name}"
filter = "logName=\"projects/%s/logs/compute.googleapis.com%%2Factivity_log\" AND severity>=ERROR"
description = "description updated"
unique_writer_identity = false
}
resource "google_storage_bucket" "log-bucket" {
resource "google_storage_bucket" "gcs-bucket" {
name = "%s"
location = "US"
}
Expand All @@ -350,14 +344,14 @@ func testAccLoggingProjectSink_disabled(name, project, bucketName string) string
resource "google_logging_project_sink" "disabled" {
name = "%s"
project = "%s"
destination = "storage.googleapis.com/${google_storage_bucket.log-bucket.name}"
destination = "storage.googleapis.com/${google_storage_bucket.gcs-bucket.name}"
filter = "logName=\"projects/%s/logs/compute.googleapis.com%%2Factivity_log\" AND severity>=ERROR"
disabled = true
unique_writer_identity = false
}
resource "google_storage_bucket" "log-bucket" {
resource "google_storage_bucket" "gcs-bucket" {
name = "%s"
location = "US"
}
Expand All @@ -369,14 +363,14 @@ func testAccLoggingProjectSink_disabled_update(name, project, bucketName, disabl
resource "google_logging_project_sink" "disabled" {
name = "%s"
project = "%s"
destination = "storage.googleapis.com/${google_storage_bucket.log-bucket.name}"
destination = "storage.googleapis.com/${google_storage_bucket.gcs-bucket.name}"
filter = "logName=\"projects/%s/logs/compute.googleapis.com%%2Factivity_log\" AND severity>=ERROR"
disabled = "%s"
unique_writer_identity = true
}
resource "google_storage_bucket" "log-bucket" {
resource "google_storage_bucket" "gcs-bucket" {
name = "%s"
location = "US"
}
Expand All @@ -387,13 +381,13 @@ func testAccLoggingProjectSink_uniqueWriter(name, bucketName string) string {
return fmt.Sprintf(`
resource "google_logging_project_sink" "unique_writer" {
name = "%s"
destination = "storage.googleapis.com/${google_storage_bucket.log-bucket.name}"
destination = "storage.googleapis.com/${google_storage_bucket.gcs-bucket.name}"
filter = "logName=\"projects/%s/logs/compute.googleapis.com%%2Factivity_log\" AND severity>=ERROR"
unique_writer_identity = true
}
resource "google_storage_bucket" "log-bucket" {
resource "google_storage_bucket" "gcs-bucket" {
name = "%s"
location = "US"
}
Expand All @@ -404,13 +398,13 @@ func testAccLoggingProjectSink_uniqueWriterUpdated(name, bucketName string) stri
return fmt.Sprintf(`
resource "google_logging_project_sink" "unique_writer" {
name = "%s"
destination = "storage.googleapis.com/${google_storage_bucket.log-bucket.name}"
destination = "storage.googleapis.com/${google_storage_bucket.gcs-bucket.name}"
filter = "logName=\"projects/%s/logs/compute.googleapis.com%%2Factivity_log\" AND severity>=WARNING"
unique_writer_identity = true
}
resource "google_storage_bucket" "log-bucket" {
resource "google_storage_bucket" "gcs-bucket" {
name = "%s"
location = "US"
}
Expand All @@ -422,7 +416,7 @@ func testAccLoggingProjectSink_heredoc(name, project, bucketName string) string
resource "google_logging_project_sink" "heredoc" {
name = "%s"
project = "%s"
destination = "storage.googleapis.com/${google_storage_bucket.log-bucket.name}"
destination = "storage.googleapis.com/${google_storage_bucket.gcs-bucket.name}"
filter = <<EOS
Expand All @@ -435,7 +429,7 @@ EOS
unique_writer_identity = false
}
resource "google_storage_bucket" "log-bucket" {
resource "google_storage_bucket" "gcs-bucket" {
name = "%s"
location = "US"
}
Expand All @@ -446,7 +440,7 @@ func testAccLoggingProjectSink_bigquery_before(sinkName, bqDatasetID string) str
return fmt.Sprintf(`
resource "google_logging_project_sink" "bigquery" {
name = "%s"
destination = "bigquery.googleapis.com/projects/%s/datasets/${google_bigquery_dataset.logging_sink.dataset_id}"
destination = "bigquery.googleapis.com/projects/%s/datasets/${google_bigquery_dataset.bq_dataset.dataset_id}"
filter = "logName=\"projects/%s/logs/compute.googleapis.com%%2Factivity_log\" AND severity>=ERROR"
unique_writer_identity = true
Expand All @@ -456,7 +450,7 @@ resource "google_logging_project_sink" "bigquery" {
}
}
resource "google_bigquery_dataset" "logging_sink" {
resource "google_bigquery_dataset" "bq_dataset" {
dataset_id = "%s"
description = "Log sink (generated during acc test of terraform-provider-google(-beta))."
}
Expand All @@ -467,13 +461,11 @@ func testAccLoggingProjectSink_bigquery_after(sinkName, bqDatasetID string) stri
return fmt.Sprintf(`
resource "google_logging_project_sink" "bigquery" {
name = "%s"
destination = "bigquery.googleapis.com/projects/%s/datasets/${google_bigquery_dataset.logging_sink.dataset_id}"
destination = "bigquery.googleapis.com/projects/%s/datasets/${google_bigquery_dataset.bq_dataset.dataset_id}"
filter = "logName=\"projects/%s/logs/compute.googleapis.com%%2Factivity_log\" AND severity>=WARNING"
unique_writer_identity = false
}
resource "google_bigquery_dataset" "logging_sink" {
resource "google_bigquery_dataset" "bq_dataset" {
dataset_id = "%s"
description = "Log sink (generated during acc test of terraform-provider-google(-beta))."
}
Expand All @@ -497,8 +489,6 @@ resource "google_logging_project_sink" "loggingbucket" {
description = "test-2"
filter = "resource.type = k8s_container"
}
unique_writer_identity = true
}
`, name, project, project)
Expand Down

0 comments on commit a4ddeb0

Please sign in to comment.