Created
June 16, 2021 14:41
-
-
Save dvdbng/435af12f66371fe8d752e57a5ba3409b to your computer and use it in GitHub Desktop.
Copy/paste all ENV variables from one AWS beanstalk env to another
This file contains hidden or 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
// Copy/paste all ENV variables from one AWS beanstalk env to another. Use this functions in the browser console | |
// Copy ENV as json | |
copy( | |
JSON.stringify( | |
Object.fromEntries( | |
Array.from( | |
document.querySelectorAll('.env-props-table tbody tr:not(.ng-hide)') | |
).map(e => [ | |
e.querySelector('[ng-model="option.optionName"]').value, | |
e.querySelector('[ng-model="option.value"]').value | |
]) | |
.filter(r => r[0]) | |
), | |
null, 2 | |
) | |
); | |
// paste env | |
(function(entries) { | |
function type(e, val) { | |
e.value = val; | |
const event = new Event('input', { bubbles: true, cancelable: true }); | |
e.dispatchEvent(event); | |
} | |
function addNext(){ | |
if (!entries.length) return; | |
const [key, val] = entries.pop(); | |
const rows = document.querySelectorAll('.env-props-table tbody tr:not(.ng-hide)'); | |
const row = rows[rows.length - 1]; | |
type(row.querySelector('[ng-model="option.optionName"]'), key); | |
type(row.querySelector('[ng-model="option.value"]'), val); | |
setTimeout(addNext, 50); | |
} | |
addNext(); | |
})(Object.entries(JSON.parse(prompt()))); | |
/* | |
Test JSON: | |
{"FOO":"bar","BAZ":"gg"} | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment