Skip to content

Expose API in addition to the command-line option#1

Open
colinmathews wants to merge 2 commits into
careerbuilder:masterfrom
colinmathews:expose-api
Open

Expose API in addition to the command-line option#1
colinmathews wants to merge 2 commits into
careerbuilder:masterfrom
colinmathews:expose-api

Conversation

@colinmathews

Copy link
Copy Markdown

Nice little utility here.

This PR wraps deploy.js in a module and exposes it so that it can be called programmatically. deploy.js can still be run as a command-line utility.

The API uses a standard callback with arguments (error, result), but for now the error property is always null. Further work could switch and/or catch thrown exceptions and feed them into the error argument (instead of just throwing them).

The result to the callback is an object instead of a status so it can easily be extended in the future:

{
  status: '...'
}

Here's a quick sample of how the call works:

var deployer = require('opsworks-deploy');
deployer.run({
  accessKeyId: '...',
  secretAccessKey: '...',
  region: '...',
  stackId: '...',
  layerId: '...',
  appId: '...',
  rolling: true|false
}, (err, result) => {
  if (err) {
    ...
  }
  else {
    ...
  }
});

Cheers!

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant