Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The Problem
I just accidentally deleted a lot of documents from a remote cluster because I forgot this tunnel was opened 🤦.
The Solution
Add a
-block-deletes
flag which will block delete requests from being proxied through to the cluster. I am very rarely wanting to connect to a remote cluster to do delete operations, so from now on I will use this library like so:The default is still to allow requests unless you opt-out using the new flag.
Risks
I am not a heavy ES user so I don't think I've covered all of the possible ways to delete things. From what I saw in the documentation disallowing
DELETE
requests is a good starting point. I burned myself with the_delete_by_query
functionality so I also added that one. It won't do anything to block deletes that are in a_bulk
query.I know this isn't strictly related to proxying but I think this would be a nice option to have.
Other
go run aws-es-proxy.go -block-deletes -endpoint <my_endpoint>
and sent through someDELETE
requests and some_delete_by_query
requests, all of which were blocked with a log indicating what happened: