Running TeamCity Stack in AWS

Last modified: 20 April 2023

The Run on AWS option for TeamCity available on the JetBrains site lets you run the TeamCity stack in AWS using the official CloudFormation template.

See also related blog post

Stack Overview



The current setup uses 2 subnets, a public and a private one.

  • The private subnet includes all the essential items

    • ECS cluster of a CoreOS EC2 instance with the official TeamCity server of the specified version from Docker Hub and one TeamCity Build Agent. The official Docker images with the TeamCity server and build agent are used.

    • an RDS MySQL database

  • The public subnet includes

    • Application Load Balancer

    • NAT gateway ensuring the publicly available IPs

Both subnets are placed into a Virtual Private Cloud (VPC) which is completely secure. The database allows only internal connections within the VPC and its possible to connect to the Server via HTTP(s) or SSH only.

Prerequisites



To create a TeamCity stack and connect to it, you will need

Using Template



1. On the Select Template, use the default TeamCity Template and click Next.

2. Specify the stack name and parameters provided by the template:

Build Agents

2. Click Next. (Optional) In the dialog that appears, provide additional options if required.

3. Click Next, review your settings, accept the creation of AWS roles.

4. and click Сreate. No other actions are required. It takes about 15 minutes for the template to deploy the whole stack. Once the deployment is ready, you will see the TeamCity server endpoint in the Output section which points you to your TeamCity installation.

4. Access the TeamCity instance from your browser, create the administrators account and start using your TeamCity.

Connecting to server and viewing logs



To connect to the servers console, you need to use your instance private key:

To see the teamcity-agent.log or teamcity-server.log , just run thedocker logs command for the desired container, e.g. for the server logs, run

Next Steps



Once you have TeamCity up and running, consider the following steps:

Upgrading TeamCity in AWS



To update TeamCity started from the CloudFormation template:

  1. In the AWS CloudFormation console, from the list of stacks, select the running TeamCity stack and u se the http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-updating-stacks-direct.html.

  2. You will be redirected to the Select Template page: use the Current Template option and click Next.

  3. On the template settings page, enter the TeamCity version you want to update to. Note that if you previously used the TeamCity version tagged latest, you will now need to provide the actual version number as the "latest" tag can be applied to the server only once.

  4. Click Next, provide additional options if required, review the new settings and click Update. Once the Update is complete, access the TeamCity Web UI from the browser.

  5. If required, provide the Super User token: to obtain it, you need to connect to your server instance, get the TeamCity server log as described above, and retrieve the maintenance token.

  6. Wait for the server to upgrade, log in to the TeamCity server and wait for the agent to upgrade and connect to the server.