mirror of
https://github.com/letic/terraform-provider-google.git
synced 2024-10-01 16:21:06 +00:00
Setting a default update_mask for all log sinks
[According to log sink documentation](https://cloud.google.com/logging/docs/reference/v2/rest/v2/sinks/update) the api will eventually throw an error if update mask isn't provided. The default specified here is what the api is currently using when an empty mask is passed.
This commit is contained in:
parent
3f906b3c8d
commit
30773a784d
@ -2,6 +2,7 @@ package google
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/hashicorp/terraform/helper/schema"
|
"github.com/hashicorp/terraform/helper/schema"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -58,7 +59,8 @@ func resourceLoggingBillingAccountSinkUpdate(d *schema.ResourceData, meta interf
|
|||||||
sink := expandResourceLoggingSinkForUpdate(d)
|
sink := expandResourceLoggingSinkForUpdate(d)
|
||||||
|
|
||||||
// The API will reject any requests that don't explicitly set 'uniqueWriterIdentity' to true.
|
// 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 {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -77,7 +77,8 @@ func resourceLoggingFolderSinkUpdate(d *schema.ResourceData, meta interface{}) e
|
|||||||
sink.ForceSendFields = append(sink.ForceSendFields, "IncludeChildren")
|
sink.ForceSendFields = append(sink.ForceSendFields, "IncludeChildren")
|
||||||
|
|
||||||
// The API will reject any requests that don't explicitly set 'uniqueWriterIdentity' to true.
|
// 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 {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -77,7 +77,8 @@ func resourceLoggingOrganizationSinkUpdate(d *schema.ResourceData, meta interfac
|
|||||||
sink.ForceSendFields = append(sink.ForceSendFields, "IncludeChildren")
|
sink.ForceSendFields = append(sink.ForceSendFields, "IncludeChildren")
|
||||||
|
|
||||||
// The API will reject any requests that don't explicitly set 'uniqueWriterIdentity' to true.
|
// 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 {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -84,7 +84,8 @@ func resourceLoggingProjectSinkUpdate(d *schema.ResourceData, meta interface{})
|
|||||||
sink := expandResourceLoggingSinkForUpdate(d)
|
sink := expandResourceLoggingSinkForUpdate(d)
|
||||||
uniqueWriterIdentity := d.Get("unique_writer_identity").(bool)
|
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 {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,9 @@ import (
|
|||||||
"google.golang.org/api/logging/v2"
|
"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 {
|
func resourceLoggingSinkSchema() map[string]*schema.Schema {
|
||||||
return map[string]*schema.Schema{
|
return map[string]*schema.Schema{
|
||||||
"name": {
|
"name": {
|
||||||
|
@ -14,8 +14,9 @@ Manages a project-level logging sink. For more information see
|
|||||||
and
|
and
|
||||||
[API](https://cloud.google.com/logging/docs/reference/v2/rest/).
|
[API](https://cloud.google.com/logging/docs/reference/v2/rest/).
|
||||||
|
|
||||||
Note that you must have the "Logs Configuration Writer" IAM role (`roles/logging.configWriter`)
|
~> **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.
|
||||||
granted 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
|
## Example Usage
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user