My current deployment process:
Can i deploy code to EB instance using only AWS SDK (nodeJS)?
Found myself. You need to upload ZIP file to S3. Then you need to create application version for EB Application (With unique label and S3Key where ZIP file is). Then you need to update EB environment with new Versionlabel (and don't forget to specify Node start script if needed).
Maybe this code will be helpful for someone:
var aws = require('aws-sdk');
var s3 = new aws.S3();
var eb = new aws.ElasticBeanstalk();
var zipFileName = 'myCodeZipArchive.zip';
var appName = 'app-name';
var envName = 'env-name';
var s3bucket = 'my-app-source-bucket';
var label = `${appName}_${envName}_${new Date().toISOString()}`;
s3.upload({
Bucket: s3bucket,
Key: label,
Body: fs.createReadStream(zipFileName)
}).promise().then(() => eb.createApplicationVersion({
ApplicationName: appName,
VersionLabel: label,
SourceBundle: {
S3Bucket: s3bucket,
S3Key: label
}
}).promise()).then(() => eb.updateEnvironment({
ApplicationName: appName,
EnvironmentName: envName,
OptionSettings: [{
Namespace: 'aws:elasticbeanstalk:container:nodejs',
OptionName: 'NodeCommand',
Value: 'npm start'
}],
VersionLabel: label
}).promise());
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With