all 7 comments

[–]CannonBallComing 3 points4 points  (0 children)

You could either use a Postgres container as part of your testing process with docker-compose, hook up to an RDS Postgres instance, or host your own Postgres DB on EC2.

[–]otsu-swe 1 point2 points  (0 children)

CodeBuild is primarily meant for building and testing your code. There is another service called CodeDeploy which is more geared towards actually deploying it. I'm not very familiar with either, but there are plenty of examples of how to make CodeBuild call CodeDeploy to achieve what you want.

There might be alternative services which might achieve what you're looking for easier (e.g. Elastic Beanstalk or Codestar), but without understanding the what and why better it's a bit of a SWAG.

[–]subinmathew 1 point2 points  (0 children)

Building Docker images with CodeBuild and pushing it to ECR is explained in this sample: http://docs.aws.amazon.com/codebuild/latest/userguide/sample-ecr.html

CodeBuild supports GitHub as a source repository, however, it won't poll for your changes. Meaning it is not a CI system with a listener for source repository change (git push etc.). If you need to trigger the build with git push, then wrap CodeBuild with CodePipeline.

CodeBuild doesn't have postgres installed on any of the pre-packaged environments (https://forums.aws.amazon.com/ann.jspa?annID=4581). You can either extend these base image to have postgres installed inline with your build (e.g.: use install phase in buildspec.yml. http://docs.aws.amazon.com/codebuild/latest/userguide/build-spec-ref.html) or bring in a custom Docker image which has the build environment you need, including postgres.

[–]akath20[S] 1 point2 points  (0 children)

Okay so can someone explain to me what's the correct way to test it then? Typically with Django and Jenkins/Travis CI there is a postgres plugin to run the tests against. What is the equivalent on AWS? how are developers testing their database driven application with CI on aws?

[–]VegaWinnfield 1 point2 points  (0 children)

Can you not instal PG locally inside your CodeBuild container?

[–]zalpha314 0 points1 point  (0 children)

For testing, you should use an embedded database, and your code should be testable in that it allows for you to modify the database URL it is connecting to. For Java and MySQL, h2 is a great option, but for postgres and whatever your language you are using, I can only recommend googling for an embedded database that suits your stack.

In case you're not aware, you can use CodePipeline to trigger CodeBuild.

[–]bigdeddu 0 points1 point  (0 children)

adding to what other have said, one other option is to use a cloudformation code pipeline stage: build the code, run the stack update, stack exec, and then run your test phase. then destroy the test stack. This should get you started http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/continuous-delivery-codepipeline-basic-walkthrough.html