Skip to content

Instantly share code, notes, and snippets.

@toshihirock
Created September 1, 2015 10:24
Show Gist options
  • Save toshihirock/6be8a2fe8b967b7f23a7 to your computer and use it in GitHub Desktop.
Save toshihirock/6be8a2fe8b967b7f23a7 to your computer and use it in GitHub Desktop.
var AWS = require('aws-sdk');
AWS.config.update({region: 'ap-northeast-1'});
var codedeploy = new AWS.CodeDeploy();
// getDeployment
function getDeployment(deploymentId, callback) {
var status = '';
var params = {
deploymentId: deploymentId
};
codedeploy.getDeployment(params, function(err, data) {
if (err) console.log(err, err.stack); // an error occurred
else {
console.log(data.deploymentInfo.status);
status = data.deploymentInfo.status;
}
callback(status);
});
}
function deploy() {
var params = {
applicationName: 'DemoApplication',
deploymentGroupName: 'DemoFleet',
deploymentConfigName: 'CodeDeployDefault.OneAtATime',
description: 'desc',
ignoreApplicationStopFailures: true ,
revision: {
revisionType: 'S3',
s3Location: {
bucket: 'hoge-fuga',
bundleType: 'zip',
key: 'SampleApp_Linux.zip'
}
}
};
codedeploy.createDeployment(params, function(err, data) {
if (err) console.log(err, err.stack); // an error occurred
else {
var deploymentId = data.deploymentId
console.log(deploymentId);
var timer = setInterval(function() {
getDeployment(deploymentId, function(status) {
console.log('status = ', status);
if (status === 'Succeeded' || status === 'failed' || status === 'Failed') {
console.log('finish');
clearInterval(timer);
}
});
}, 1000);
}
});
}
deploy();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment