AWS CodeDeploy Runner plugin
Good news for those of you who use both TeamCity and Amazon Web Services, and those who for now stick with only one of the above, but are looking for a good integration.
With the help of the new TeamCity AWS CodeDeploy Runner plugin, your application can now be automatically deployed directly to your fleet of EC2 instances, on-premises instances or both in the scope of the CodeDeploy application.
AWS CodeDeploy is a fully managed, high-scale deployment service that can work with any kind of deployable content like code, web and configuration files, executables, etc. and with almost any kind of target platforms.
Generally, any deployment consists of four main steps:
- preparing deployable content
- uploading it to a repository
- triggering a deployment
- viewing the deployment status
TeamCity AWS CodeDeploy Runner plugin helps to automate and simplify all the mentioned tasks by adding a build step which packages the build output as a revision, uploads it to an S3 bucket and registers it in CodeDeploy. For the registered revision, it can run a deployment and optionally monitor and show its status using the TeamCity progress and error reporting.
To set up a deployment, one basically needs to make the following five steps (assuming the initial account set-up is complete):
- set up target instances
- plan a revision
- set up a CodeDeploy application
- add an AWS CodeDeploy step to a TeamCity build
By default each deployment can target up to 50 instances which must be running an AWS CodeDeploy agent and either be tagged or belong to an Auto Scaling group. Amazon EC2 instances must be running with an IAM instance profile attached – for the AWS CodeDeploy agent to verify the identity of the instance – and must belong to the same region as the CodeDeploy application.
AWS CloudFormation provides a template which creates and configures new, single Amazon EC2 instances based on Amazon Linux or Windows Server with the AWS CodeDeploy agent already installed. For more information on setting up both EC2 and on-premises instances, see Configure Instances.
An application revision is an archive containing deployable files accompanied by the application specification file appspec.yml which is a YAML-formatted file used by CodeDeploy to determine where to place the application files on the target instance, and which lifecycle event hooks to run in response to deployment lifecycle events – that’s where most of the magic happens. The archive is uploaded to an existing S3 bucket and registered in a CodeDeploy application.
The TeamCity AWS CodeDeploy Runner accepts either a ready-made application revision (must contain appspec.yml) archive or a list of paths to package. For the latter Ant-style wildcards like dir/**/*.html are supported.
A CodeDeploy application is a place where all the deployment resources are put together: the revision location, deployment group, deployment configuration and other settings.
An AWS CodeDeploy deployment group identifies a collection of instances based on their tags, Auto Scaling group names, or both. Multiple application revisions can be deployed to the same instance, and one and the same application revision can be deployed to multiple instances.
The deployment configuration specifies a set of deployment order rules and the success and failure conditions. It specifies the number (or percentage) of instances that must remain available at any time during a deployment. One may either use one of the default configurations, or create a custom one.
AWS CodeDeploy TeamCity build step
After one has a working CodeDeploy application, he or she only needs to type in the settings such as region, credentials, S3 bucket parameters, CodeDeploy application and deployment group name, and run a TeamCity build.