Created
May 5, 2020 21:13
-
-
Save ajsharp/cf37fd27bbc0b1729c281898c6d99b5f to your computer and use it in GitHub Desktop.
Migrate the environment variables from one elastic beanstalk environment to another
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
#!/usr/bin/env ruby | |
# Usage: migrate-eb-env FROM_ENV TO_ENV | |
from, to = ARGV | |
if !from || !to | |
$stderr.puts "FROM_ENV and TO_ENV are required" | |
exit(1) | |
end | |
raw_env = `eb printenv #{from}`.strip.gsub(' ', '').split("\n") | |
raw_env.shift # remove the "Environment Variables:" line | |
env = raw_env | |
# filter out secret values | |
env = env.select do |e| | |
found = e.match(/[*]{3}/) | |
if found | |
puts "Secret value found=#{e}" | |
end | |
!found | |
end | |
# puts env | |
setenv = env.join(' ') | |
# puts "setenv=#{setenv}" | |
`eb setenv #{setenv} -e #{to}` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment