Friday, September 02, 2011

JenkinsCI Cloud Formation Plugin

Lately I have been very busy working mainly in automation stuff. JenkinsCI is an awesome CI server that we are using for pretty much every automation activity we do. What makes JenkinsCI such a good tool is, among other things, how easy it is to extend. This is the primary reason why there are so many plugins that let you use the tool in the most unexpected ways.
Amazon Cloud Formation is a service that allows you to express your application stack in the form of a json document (assuming you application is being deployed to AWS). This is indeed a very nice service as it allows you to treat you AWS stack definitions as code.
The combination of these 2 tools/services can be extremely powerful. One use case that comes to mind right away is to be able to create a brand new stack, run tests against it, collect test results for publishing/reporting and then take the whole stack down to save money. Another use case could be to implement BLUE/GREEN deployments.
Use cases like these are possible using the Amazon CLI tools by running ad hoc commands from a JenkinsCI Shell builder. However, getting such a set up to work reliably can be extremely challenging, specially due to the fact that calls to the AWS API are not guaranteed to work all the time and need clever ways to check for its completion and success. Achieving this in a shell script is doable, but tricky to say the least.
Enter the JenkinsCI Cloud Formation Plugin. This plugin allows for the creation of AWS Stacks in a declarative way. All is needed is a stack document (json) and the parameters that you wish to pass into the stack. The plugin allows for the use of build environment variables as values to stack parameters so that the stack creation is not isolated from the rest of the build. Another nice feature is the ability to "chain" stacks by passing outputs from one stack as parameters to another stack further down.
The plugin is in its early stages but it is fully functional. Please give it a try and let me know how it goes. If you find problems please log an issue here.