Skip to content

Instantly share code, notes, and snippets.

@tiagotex
Last active February 27, 2023 12:41
Show Gist options
  • Save tiagotex/3a7b0b0ecf33ac2a610f to your computer and use it in GitHub Desktop.
Save tiagotex/3a7b0b0ecf33ac2a610f to your computer and use it in GitHub Desktop.
Mass insert/update environment variables in AWS Elastic Beanstalk configuration
// I could not find a easy way to mass insert environment variables when migrating a project to EBS,
// this variables were in a config file so I decided to transform them into a array and write this script
// to allow easy insertion and update.
// To use this script fill the variables_array with your variables and then go to AWS Console,
// open your EBS environment, go to Configuration tab and then Software Configuration,
// you should see a table of Environment Properties. Open the browser console and use the scripts below.
// NOTICE: The combined size of all environment variables defined for an environment is limited to 4096 bytes.
// NOTICE: This script was done in January 2016, it might not work if AWS console is updated.
// Insert all variables from array
var variables_arrray = [
['KEY', 'VALUE'],
['KEY', 'VALUE']
];
variables_arrray.forEach(function (element, index){
var input_boxes = $("input.ng-valid").slice(-2);
input_boxes[0].value = element[0];
input_boxes[1].value = element[1];
angular.element(input_boxes[0]).trigger('input');
angular.element(input_boxes[1]).trigger('input');
$(".icon-plus:last").triggerHandler('click');
});
// Remove all variables
$.each($('tr.ng-scope'), function (index, element){
angular.element(element).find('.icon-remove').triggerHandler('click');
});
@adamtester
Copy link

This literally saves me hours! Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment