Skip to content

Instantly share code, notes, and snippets.

@felipegmarques
Created June 7, 2020 11:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save felipegmarques/f8a7a2555293c4b403e53be94116c569 to your computer and use it in GitHub Desktop.
Save felipegmarques/f8a7a2555293c4b403e53be94116c569 to your computer and use it in GitHub Desktop.
Kubectl provides a nice feature for editing some of its objects. You can type `kubectl edit deployment my-cool-deployment` and it will download the deployment description, allow you do edit it on VI and once you save it, it will update the deployment. I would like to have a similar experience with s3 files instead of having to copy, edit and cop…
(ns s3-edit
(:require [clojure.string :as str]
[clojure.java.shell :as sh]
[clojure.java.io :as io])
(:import (java.util UUID)))
(defn s3-edit [s3-path]
(let [temp-secrets-file-name (str "./temp-secrets-" (UUID/randomUUID) ".json")]
(sh/sh "aws" "s3" "cp" s3-path temp-secrets-file-name)
(->
(ProcessBuilder. ["vim" temp-secrets-file-name])
(.inheritIO)
(.start)
(.waitFor))
(sh/sh "aws" "s3" "cp" temp-secrets-file-name s3-path)
(sh/sh "rm" temp-secrets-file-name)))
(s3-edit (first *command-line-args*))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment