Skip to content

Instantly share code, notes, and snippets.

@dvdbng
Created June 16, 2021 14:41
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 dvdbng/435af12f66371fe8d752e57a5ba3409b to your computer and use it in GitHub Desktop.
Save dvdbng/435af12f66371fe8d752e57a5ba3409b to your computer and use it in GitHub Desktop.
Copy/paste all ENV variables from one AWS beanstalk env to another
// 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