-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for setting bucket's logging config #946
Conversation
Added an issue for this pull request, for tracking purposes on our end: #972 |
@rosbo friendly bump? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @skinp, looks good! Just one quick nit.
Also, for log_object_prefix, setting the value as Computed
would be a start (it would stop having diffs between empty and the default), but it does mean that if you set it to a custom value it won't show a diff if you try to set it back to the default. I'm generally in favor of having something that works most of the time now instead of something that works all the time later, but if you'd like to get something that works all the time check out some of the customdiff helpers (example from within our codebase here)
google/resource_storage_bucket.go
Outdated
if v, ok := d.GetOk("logging"); ok { | ||
sb.Logging = expandBucketLogging(v.([]interface{})) | ||
} | ||
if sb.Logging == nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this can just be else
, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, will fix
Right, I toyed with Computed for awhile but couldn't get it to revert back to the default if I removed the explicit config like you're describing. I'll go with the "something that works most of the time" for now. |
Test run fwiw.
|
Thanks @skinp! Merging now. |
* Add support for setting bucket's logging config * Add log_object_prefix and fix nil Logging condition
Signed-off-by: Modular Magician <magic-modules@google.com>
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. If you feel I made an error 🤖 🙉 , please reach out to my human friends 👉 hashibot-feedback@hashicorp.com. Thanks! |
Mostly self explanatory, this enables setting up which bucket to log access/storage logs to.
In theory, GCP also allows us to set a log_object_prefix. Unfortunately I couldn't easily get this working, so this is a first step. It's also why logging ends up being a TypeList instead of TypeString... to allow for future support of log_object_prefix.
Setting log_object_prefix wasn't obvious for the following reasons... In theory, this should an optional field but GCP sets it to the bucket name by default. It wasn't straightforward to go back and forth from an explicitly set value to the default because the expected TF state is "" but GCP reports it as the bucket name. It seems like the easiest approach would be to set a Default(Func) value for log_object_prefix dynamically to be the bucket's name, but I couldn't figure out how to make this work. Open for suggestions here...