Run TeamCity Server and Agents in EC2 using internal IP addresses

amazon ec2teamcity

I'm setting up a TeamCity cluster, with an SVN server, in EC2, and want to user TeamCity's 'cloud' functionality to have it spin up new agents when needed.

My primary concern at this point is making sure that all communications between the three types of machines (TC Server, TC Agent(s), and SVN) user internal EC2 IP addresses to make the data transfers free (see the EC2 Pricing page, Availability Zone Data Transfer).

This is easy for the SVN server, I can put it's private IP address in to TeamCity Server configuration. However, for the TeamCity server URL, I believe I need to enter the external IP address so that users can access the server. The same IP address is sent to the newly spun agents so that they know where to talk to.

Therefore, communication from agents to server will be over the external IP, thus incurring data transfer costs. How do I avoid this?

EDIT

I ran 'dig' on one of my agents, giving it hte elastic IP address of the TC Server, and got this (note I obfuscated the external IP slightly). No internal IP address is in there.

[ec2-user@ip-10-166-9-94 ~]$ dig 54.243.x.y

; <<>> DiG 9.8.2rc1-RedHat-9.8.2-0.10.rc1.25.amzn1 <<>> 54.243.x.y
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NXDOMAIN, id: 60896
;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 1, ADDITIONAL: 0

;; QUESTION SECTION:
;54.243.x.y.            IN  A

;; AUTHORITY SECTION:
.           10800   IN  SOA a.root-servers.net. nstld.verisign-grs.com. 2012111500 1800 900 604800 86400

;; Query time: 38 msec
;; SERVER: 172.16.0.23#53(172.16.0.23)
;; WHEN: Thu Nov 15 18:10:09 2012
;; MSG SIZE  rcvd: 106

Best Answer

You don't need to setup a domain/DNS. If you assign Elastic IPs, you can use the Elastic IP Public DNS name, and it will resolve to the external IP if you query it externally, and resolve to the internal address if you query it from other EC2 instances.

So if I've got an Elastic IP of 54.254.54.54, the public hostname is ec2-54-254-54-54.us-west-2.compute.amazonaws.com. This will resolve to the internal IP if you query it internally.

You can CNAME your own hostname (foo.domain.com) to it, and it will function the same way.