I have finally gotten around to writing a gist to help those of you who want to set up an integration between CircliCI and Elastic Beanstalk! I’ve used WordPress as an example, as that’s the application I originally set up this integration for, but this method should be easy enough to adopt for other applications/frameworks.
Essentially, there are three main files to consider:
circle.yml– this configures the CircleCI behaviour. In my gist, I’ve only included the details on how to set up the Elastic Beanstalk CLI tools and deploy to after a successful test run. You’ll obviously want to add your own set of tests, database setup, etc. The important sections are:
dependencies– here’s where the EB CLI tools are installed (and you will configure any other dependencies your project may need to build/deploy via CircleCI).
deployment– this section is responsible for generating the
bundle.zipthat will be pushed to Elastic Beanstalk
.elasticbeanstalk/config.yml– this file tells the EB CLI tools to use a deployable artefact, which is generated by the
deploymentsection of our
circle.yml, instead of creating a release from the current state of the local repository (the default EB CLI tool behaviour).
In addition to the above, it’s also necessary to grant the relevant privileges to CircleCI in order for the service to be able to make the necessary API calls to Elastic Beanstalk. The easiest way to achieve this is as follows:
- Create a new IAM user in your AWS account, named something like
circleci, and note/download the API keys (AWS Access Key ID and AWS Secret Access Key) associated with it.
- Associate the AWS Managed Policy,
AWSElasticBeanstalkFullAccesswith the account.
- In your Circle CI project settings, navigate to the AWS Permissions page and input the API keys gathered in the first step.
Now you should be able to either manually kick off a build, or have CircleCI automatically build and release your software to Elastic Beanstalk with each