Saturday, December 10, 2016

Chef Cookbooks in CodeBuild

AWS usually releases a large number of new services at re:Invent, and this year was no exception.

The announcement I was most excited about was AWS CodeBuild, which is exactly what it sounds like: a service designed to take servers out of your build process.

One of the problems we looked tackling first is "building" chef recipes. If you're a chef user, you know that recipes don't need to be build so much as critiqued using foodcritic and packaged or deployed.


The first step is to put together a buildspec.yml file (apparently AWS has drunk the yml coolaid) that tells CodeBuild how to download and run your build tools. If you're build can fit into one of the AWS supported docker images it makes this process a little easier because the tools will be built in.

If you need a different tool set it's a good idea to build your own docker image so that your build environment is consistent, but for getting started quick you can also download and install custom tools in the Install step, as I've done in the example below.



This example will run foodcritic, and if it passes zip your recipes and send them to wherever was specified in your code build project.

From there you can point an Opsworks stack at them to have them run on your servers.

I've been using CodeBuild for about a week, and the build has been taking about a minute and a half on average on the smallest instance size. That brings my cost per build to about a cent. Obviously this will vary based on what you're building, but it makes it worth taking a look at.

No comments:

Post a Comment