Subscribe
-
-
Latest blog posts
What we’re up to on Twitter
What we're up to on Twitter
Recent Comments
- www.seoorganics.net/ on SQL Monitor 3.1 released
- list eruption 2.0 on Using CloudWatch to monitor EC2 instances
- automatizari porti on SQL Bits 8
- Tweets that mention Maintenance windows and SSRS reports | The Future of Monitoring -- Topsy.com on Maintenance windows and SSRS reports
- Chris.Spencer on Using CloudWatch to monitor EC2 instances
Links
-

Setting up Windows Networking on EC2
This follows on from my previous blog post that covered the basics of getting started with Amazon’s cloud computing service EC2. On this post I want to go into a lot more detail about the issues I had automating Windows networking on EC2.
I have very little knowledge about networking but I quickly realised that each networked machine would need the IP Address of the domain controller. For this reason I start up my EC2 network in several steps
Step 2 can be done manually by monitoring the machine instance in Elasticfox and then pasting the IP Address into the C# code used to start the rest of the machines. Alternatively it can be automated using the ec2-describe-instances.cmd command line utility and parsing the output to pick out the IP Address. This IP Address then gets passed to every subsequent machine using the runRequest.UserData property as follows:
runRequest.UserData = Convert.ToBase64String(Encoding.ASCII.GetBytes(dcIpAddress));
The only thing that needs doing now is to make sure that each machine launched reads in this IP Address and joins the domain. To do this I wrote a C# executable, copied it to several of my personal AMIs and configured the Windows Server to run it at start-up. Maybe there’s an easier, more intuitive means to do this but I chose the executable and didn’t hit too many problems.
The only major problem was getting all my stuff to play nicely with the ec2config service which runs on all EC2 machines and seems to do important stuff like giving the machine unique names (based on the internal IP address) and probably lots of networking stuff that I don’t pretend to understand. One thing I learned early on was that attempting to rename my machines to something more memorable than IP-0AE456B0 (for example) was very bad as it seemed to start a recurring reboot issue. I could never exactly figure this one out and the Amazon support forums seemed to contain several unresolved threads of this nature. Similarly bad things seemed to happen when my C# code attempted to join the machine to the domain.
After a lot of trial and error I came to the conclusion that it was the ec2config service that was causing the issues and that I would be better off not trying to compete with it. So I changed my startup executable to detect whether it was the first boot of the machine and depending on this follow different code branches.
First boot? (detected by the absence of a file called firstboot on the C: drive)
Yes ->
No -> Do the domain joining
7. Force a reboot using “shutdown -r -t: 0 /f”
Once your machine has surfaced after its second reboot it’s on the network and ready to go. Any subsequent reboots won’t change anything as the amazon service is still disabled and my executable detects that it’s now on example.com and exits. Maybe this is a long-winded way to automate networking on EC2 but I really struggled to find information on how to do this. The majority of support threads I visited seems to be geared towards Linux users.
Overall not the most intuitive process but one that wasn’t too much of an issue to achieve.
Next, in the third and final part, I will cover using CloudWatch to monitor EC2 instances…