AWS EC2 – Clone Windows Server Machines That Are Domain Joined

active-directoryamazon ec2amazon-web-serviceswindows-server-2008-r2

Firstly, I am using these as a base guide:
http://docs.aws.amazon.com/AWSEC2/latest/WindowsGuide/ami-create-standard.html
http://reduktor.net/2014/09/autoscale-ec2-instances-ad-aws/

Secondly, our region doesn't support the AWS directory service

Scenario

I am looking to create a "base AMI" for a set of application servers we have. I may need to deploy 1 or more new servers based off of this image.

The instances are originially created from EC2 Windows Server 2008 R2 Datacenter base AMI (Created by Amazon)

The applications themselves are static, licensing is completely redistributable, and the config doesn't need to change on one machine vs another.

The ONLY thing that is different from one machine to the other is the hostname and network config. Network config is handled by EC2, so the hostname is really the only thing that needs to change from once instance to another

The machines are part of Active Directory, and have specific OU Group Policy rules applied to the machines. They will all join the same OU.

Goal:

My goal is to have a base AMI. When this AMI is launched it auto-joins the domain OR is already joined to the domain.

The applications that are ran from the machine REQUIRE domain accounts to run the Windows Services. So I can't have an image that's not joined to the domain.

An idea I had (Will test this tomorrow):

  • Create a default/generic hostname "server-xy", join the domain and create my AMI. Power down the source VM then deploy from AMI. Once it boots, rename it to its final hostname "server-02". Then deploy another from AMI, rename it, rinse and repeat — sound viable? EDIT: this didn't work since renaming it invalidates the original hostname at the domain level. Seems like what I would like to do might not be feasible.

Best Answer

As a general rule for a domain joined Windows machine, you shouldn't clone it as is. You should remove it from the domain and use sysprep. Then you can use this as a template/base AMI. Each new clone will be joined using a new SID, name, IP to the domain, making a new computer account in the AD.

Related Topic