Created
June 7, 2020 11:30
-
-
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…
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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