Merge pull request #1968 from chrisst/logging-sink-defaults-991

Setting a default update_mask for all log sinks
This commit is contained in:
Chris Stephens 2018-09-06 09:53:44 -07:00 committed by GitHub
commit 73e2972237
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 15 additions and 6 deletions

View File

@ -2,6 +2,7 @@ package google
import (
"fmt"
"github.com/hashicorp/terraform/helper/schema"
)
@ -58,7 +59,8 @@ func resourceLoggingBillingAccountSinkUpdate(d *schema.ResourceData, meta interf
sink := expandResourceLoggingSinkForUpdate(d)
// The API will reject any requests that don't explicitly set 'uniqueWriterIdentity' to true.
_, err := config.clientLogging.BillingAccounts.Sinks.Patch(d.Id(), sink).UniqueWriterIdentity(true).Do()
_, err := config.clientLogging.BillingAccounts.Sinks.Patch(d.Id(), sink).
UpdateMask(defaultLogSinkUpdateMask).UniqueWriterIdentity(true).Do()
if err != nil {
return err
}

View File

@ -77,7 +77,8 @@ func resourceLoggingFolderSinkUpdate(d *schema.ResourceData, meta interface{}) e
sink.ForceSendFields = append(sink.ForceSendFields, "IncludeChildren")
// The API will reject any requests that don't explicitly set 'uniqueWriterIdentity' to true.
_, err := config.clientLogging.Folders.Sinks.Patch(d.Id(), sink).UniqueWriterIdentity(true).Do()
_, err := config.clientLogging.Folders.Sinks.Patch(d.Id(), sink).
UpdateMask(defaultLogSinkUpdateMask).UniqueWriterIdentity(true).Do()
if err != nil {
return err
}

View File

@ -77,7 +77,8 @@ func resourceLoggingOrganizationSinkUpdate(d *schema.ResourceData, meta interfac
sink.ForceSendFields = append(sink.ForceSendFields, "IncludeChildren")
// The API will reject any requests that don't explicitly set 'uniqueWriterIdentity' to true.
_, err := config.clientLogging.Organizations.Sinks.Patch(d.Id(), sink).UniqueWriterIdentity(true).Do()
_, err := config.clientLogging.Organizations.Sinks.Patch(d.Id(), sink).
UpdateMask(defaultLogSinkUpdateMask).UniqueWriterIdentity(true).Do()
if err != nil {
return err
}

View File

@ -84,7 +84,8 @@ func resourceLoggingProjectSinkUpdate(d *schema.ResourceData, meta interface{})
sink := expandResourceLoggingSinkForUpdate(d)
uniqueWriterIdentity := d.Get("unique_writer_identity").(bool)
_, err := config.clientLogging.Projects.Sinks.Patch(d.Id(), sink).UniqueWriterIdentity(uniqueWriterIdentity).Do()
_, err := config.clientLogging.Projects.Sinks.Patch(d.Id(), sink).
UpdateMask(defaultLogSinkUpdateMask).UniqueWriterIdentity(uniqueWriterIdentity).Do()
if err != nil {
return err
}

View File

@ -5,6 +5,9 @@ import (
"google.golang.org/api/logging/v2"
)
// Empty update masks will eventually cause updates to fail, currently empty masks default to this string
const defaultLogSinkUpdateMask = "destination,filter,includeChildren"
func resourceLoggingSinkSchema() map[string]*schema.Schema {
return map[string]*schema.Schema{
"name": {

View File

@ -14,8 +14,9 @@ Manages a project-level logging sink. For more information see
and
[API](https://cloud.google.com/logging/docs/reference/v2/rest/).
Note that you must have the "Logs Configuration Writer" IAM role (`roles/logging.configWriter`)
granted to the credentials used with terraform.
~> **Note:** You must have [granted the "Logs Configuration Writer"](https://cloud.google.com/logging/docs/access-control) IAM role (`roles/logging.configWriter`) to the credentials used with terraform.
~> **Note** You must [enable the Cloud Resource Manager API](https://console.cloud.google.com/apis/library/cloudresourcemanager.googleapis.com)
## Example Usage