Skip to content
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

Allow deleting google_logging_*_bucket_config #11538

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .changelog/5949.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
logging: made `google_logging_*_bucket_config` deletable
```
22 changes: 19 additions & 3 deletions google/resource_logging_bucket_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -262,9 +262,25 @@ func resourceLoggingBucketConfigUpdate(d *schema.ResourceData, meta interface{})
}

func resourceLoggingBucketConfigDelete(d *schema.ResourceData, meta interface{}) error {
name := d.Get("bucket_id")
for _, restrictedName := range []string{"_Required", "_Default"} {
if name == restrictedName {
log.Printf("[WARN] Default logging bucket configs cannot be deleted. Removing logging bucket config from state: %#v", d.Id())
return nil
}
}

log.Printf("[WARN] Logging bucket configs cannot be deleted. Removing logging bucket config from state: %#v", d.Id())
d.SetId("")

config := meta.(*Config)
userAgent, err := generateUserAgentString(d, config.userAgent)
if err != nil {
return err
}
url, err := replaceVars(d, config, fmt.Sprintf("{{LoggingBasePath}}%s", d.Id()))
if err != nil {
return err
}
if _, err := sendRequestWithTimeout(config, "DELETE", "", url, userAgent, nil, d.Timeout(schema.TimeoutUpdate)); err != nil {
return fmt.Errorf("Error deleting Logging Bucket Config %q: %s", d.Id(), err)
}
return nil
}