npm install aws-sdk
node index.js appName envName
Last active
March 25, 2016 14:09
-
-
Save gbleu/2d4a6c3887b9d71fe371 to your computer and use it in GitHub Desktop.
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
title |
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
var AWS = require('aws-sdk'); | |
AWS.config.region = 'eu-west-1'; | |
var elasticbeanstalk = new AWS.ElasticBeanstalk({apiVersion: '2010-12-01'}); | |
var args = process.argv.slice(2); | |
if(args.length < 2){ | |
console.log('Error not enough args'); | |
return 1; | |
} | |
var appName = args[0]; | |
var envName = args[1]; | |
var optIncludes = [ | |
"LoadBalancerHTTPPort", | |
"LoadBalancerPortProtocol", | |
"LoadBalancerHTTPSPort", | |
"LoadBalancerSSLPortProtocol", | |
"EC2KeyName", | |
"SSLCertificateId", | |
"AssociatePublicIpAddress", | |
"IamInstanceProfile", | |
"InstanceType", | |
"JVMOptions", | |
"VPCId", | |
"Subnets", | |
"Xms", | |
"Xmx", | |
"XX:MaxPermSize" | |
]; | |
var params = { | |
ApplicationName: appName, | |
EnvironmentName: envName | |
// Options: [{ Namespace: 'aws:elasticbeanstalk:application:environment' }] | |
}; | |
elasticbeanstalk.describeConfigurationOptions(params, function(err, data) { | |
if (err) { console.log(err); return 1; } | |
else { | |
var optNames = data.Options | |
.filter(function(opt) { return opt.UserDefined || optIncludes.indexOf(opt.Name) !== -1 }) | |
.map(function(opt) { return opt.Name; }); | |
var params2 = { | |
ApplicationName: appName, | |
EnvironmentName: envName | |
}; | |
elasticbeanstalk.describeConfigurationSettings(params2, function(err2, data2) { | |
if (err2) { console.log(err2); return 1; } | |
else { | |
var optSettings = []; | |
if(data2.ConfigurationSettings.length === 1) { | |
data2.ConfigurationSettings[0].OptionSettings.forEach(function(optSetting){ | |
if(optNames.indexOf(optSetting.OptionName) !== -1 && optSetting.Value != undefined){ | |
delete optSetting.ResourceName; | |
optSettings.push(optSetting); | |
} | |
}); | |
} | |
console.log(JSON.stringify(optSettings, null, 2)); | |
} | |
}); | |
} | |
}); | |
return 0; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment