Purpose of the Blog:
It’s been more than 4 years I’m working with AWS but still I
feel that Autoscaling with Domain environment is a challenge for the Corporate,
Especially if you have PCI and Corporate Policy which will not allow you to use
AWS directory service or Simple AD serveries as it is not compliance with PCI.
AWS PCI compliance
Services:
And every time you go and ask AWS support they will give you
nice document how we can achieve this using AWS Directory services or Sample
AD. According to them it is the only way to achieve this at this moment.
So I faced lot of issues to designing autoscaling policy for
many corporate organization who want to use autoscaling but not ready to sync
the corporate AD with sample AD.
I have told few of my client in recent past the only way to
autoscale in the domain environment is we have to use AWS Simple AD and they
are not happy with my suggestion.
So this time I tried to do some POC before I tell a
corporate client again the same things and yes I have an answer, “We can do this without using AWS directory
services/Simple AD also”.
I have written the full steps below how you can achieve this
in the domain environment.
Prepare your golden AMI:
- Launch a new windows server instance.
- Open the group policy management console using “gpedit.msc “ from run. Navigate to the console tree, click Scripts (Startup/Shutdown). The path is Computer Configuration\Windows Settings\Scripts (Startup/Shutdown). Select “PowerShell Script” put the below script and select the option “Run Windows PowerShell script first” and save it.
Sample
PowerShell Script:
Set-ExecutionPolicy -ExecutionPolicy
RemoteSigned -Force
$newDNSServers =
"192.168.152.133","192.168.152.2"
$adapters = Get-WmiObject
Win32_NetworkAdapterConfiguration | Where-Object {$_.DNSServerSearchOrder -ne
$null}
$adapters | ForEach-Object
{$_.SetDNSServerSearchOrder($newDNSServers)}
$domain = "myDomain"
$password = "myPassword!" |
ConvertTo-SecureString -asPlainText -Force
$username =
"$domain\myUserAccount"
$credential = New-Object
System.Management.Automation.PSCredential($username,$password)
Add-Computer –DomainName - $domain --OUPath "OU=”The OU where you
wat to place autoscale servers”,DC=”Domain Prefix” ,DC=”Dommin suffix” -Credential $credential
shutdown /r /t 90
del
C:\Windows\System32\GroupPolicy\Machine\Scripts\Startup\script_name.ps1
The Script I used
for my POC:
Set-ExecutionPolicy -ExecutionPolicy
RemoteSigned -Force
$newDNSServers = "172.31.0.100 ","172.31.0.2"
$adapters = Get-WmiObject
Win32_NetworkAdapterConfiguration | Where-Object {$_.DNSServerSearchOrder -ne
$null}
$adapters | ForEach-Object
{$_.SetDNSServerSearchOrder($newDNSServers)}
$domain = "aws.local"
$password = "Pass@word1" |
ConvertTo-SecureString -asPlainText -Force
$username =
"$domain\aws-autoscale"
$credential = New-Object
System.Management.Automation.PSCredential($username,$password)
Add-Computer -DomainName $domain
-OUPath "OU=aws-autoscale,DC=aws,DC=local" -Credential $credential
shutdown /r /t 90
del
C:\Windows\System32\GroupPolicy\Machine\Scripts\Startup\test.ps1
Note about above PowerShell Script:
I do not want to hardcode the DNS server IP in the network
config so I change the DNS setting by using first four command.
The last line “del” command is very important because you
will end up with infinite loop if the script run again after the reboot (you
need to reboot the system to reflect the domain level changes for the server).
- I have installed IIS for my sample testing to check the autoscaling using ELB.
- Once you have configured your webserver settings you need to use “Ec2Config.exe” and shutdown the instance with the process shown below (“Random -Shutdown with sysprep”).
- Wait for some time it will run the sysprep and stop the instance. This step is very important because in windows domain environment each computer should have it’s unique SID value. With the help of “Ec2Config.exe” you can retrieve the password from the AWS console for each instances which will come up during autoscaling. To know more about windows syspep please go through the below link
- URL: https://technet.microsoft.com/en-us/library/cc721940(v=ws.10).aspx
- Create an AMI of the instance.
Configure Autoscaling
:
Once the AMI creation is completed configure the autoscaling
group. Please refer to the below document for configuring autoscalling policy.
Validate instances
domain/workgroup profile:
Login to the instances launched by the autoscaling group and
check that whether it is added to the domain or not.
Few screenshot from
my POC :
- Instances are launched from the autoscaling group.
- Login to the instances and check that it added to domain or not.
Test your Sample web
application by using ELB URL:
Check the health of the ELB instances ( I always
prefer to configure http based health check) and access the web application
using the ELB URL.
Screenshot form my
POC:
Health check of the ELB instances launched by an
autoscaling group.
Clean up your OU:
As we are using autoscalling for the domain environment, you
can see lots of computer objects still exists in the OU which was already
deleted by the autoscaling group termination policy. So it is very important to
cleanup those Computer objects .You can use the blow PowerShell script and run
it through windows task scheduler cleanup the resources which currently
didn’t exist in the domain.
PowerShell Script:
$then =
(Get-Date).AddDays(-15) # The 15 is the number of days from today since the
last logon.
Get-ADComputer -Property Name,lastLogonDate
-Filter {lastLogonDate -lt $then} | Remove-ADComputer # If you would like to Remove these computer
accounts
Thanks for visiting
my Blog Site.
Sudipta Saha
AWS Solution
Architect –Professional Level (AWS-PSA-2596)
Great blog.you put Good stuff.All the topics were explained briefly.so quickly understand for me.I am waiting for your next fantastic blog.Thanks for sharing.Any coures related details learn...
ReplyDeleteAws Online Training
The Information about AWS Autoscaling Windows Instances in the Domain Environment was very much useful My sincere thanks for sharing this post please continue to share this kind of post
ReplyDeleteAWS Training in BTM Layout || AWS Training in Marathahalli
Super blog! very easy to understand keep update like thanks AWS Online Training
ReplyDelete3D Animation Training in Noida
ReplyDeleteBest institute for 3d Animation and Multimedia
Best institute for 3d Animation Course training Classes in Noida- webtrackker Is providing the 3d Animation and Multimedia training in noida with 100% placement supports. for more call - 8802820025.
3D Animation Training in Noida
Company Address:
Webtrackker Technology
C- 67, Sector- 63, Noida
Phone: 01204330760, 8802820025
Email: info@webtrackker.com
Website: http://webtrackker.com/Best-institute-3dAnimation-Multimedia-Course-training-Classes-in-Noida.php
Sap fico training institute in Noida
ReplyDeleteSap fico training institute in Noida - Webtrackker Technology is IT Company which is providing the web designing, development, mobile application, and sap installation, digital marketing service in Noida, India and out of India. Webtrackker is also providing the sap fico training in Noida with working trainers.
WEBTRACKKER TECHNOLOGY (P) LTD.
C - 67, sector- 63, Noida, India.
F -1 Sector 3 (Near Sector 16 metro station) Noida, India.
+91 - 8802820025
0120-433-0760
0120-4204716
EMAIL: info@webtrackker.com
Website: www.webtrackker.com
Thanks for blog really informative. Hope i will find more interesting post from you
ReplyDeleteaws training in bangalore
Amazon web services training in bangalore
best AWS Training institute in Bangalore
aws training institutes in bangalore
aws certification course in bangalore
Your info is really amazing with impressive content..Excellent blog with informative concept. Really I feel happy to see this useful blog, Thanks for sharing such a nice blog..
ReplyDeleteIf you are looking for any Data science Related information please visit our website Data science courses in Pune page!
Wow it is really wonderful and awesome thus it is very much useful for me to understand many concepts and helped me a lot.it is really explainable very well and i got more information from your blog.
ReplyDeleteaws training in chennai | aws training in annanagar | aws training in omr | aws training in porur | aws training in tambaram | aws training in velachery
Excellent Articles!!!Blogs are very much useful for me to understand many concepts...Awaiting for your Feature posts...Big Thanks
ReplyDeleteBEST JAVA TRAINING IN CHENNAI WITH PLACEMENT
Java training in chennai | Java training in annanagar | Java training in omr | Java training in porur | Java training in tambaram | Java training in velachery
It was really nice to read article written on this blog. I would also like to add few techniques with best of my knowledge which can help reader more and more.keep it up!!
ReplyDeleteandroid training in chennai
android online training in chennai
android training in bangalore
android training in hyderabad
android Training in coimbatore
android training
android online training
I appreciate your efforts because it conveys the message of what you are trying to say. It's a great skill to make even the person who doesn't know about the subject could able to understand the subject.
ReplyDeleteAws Training in Chennai
Aws Training in Velachery
Aws Training in Tambaram
Aws Training in Porur
Aws Training in Omr
Aws Training in Annanagar
This comment has been removed by the author.
ReplyDeleteCommunication is a two way process. If done properly, it gives excellent result. Thus opting for the best Integrated Marketing Communication Course on Talentedge is wise. To know more visit:
ReplyDeleteTalk To Astrologer expert will show you the right direction in your life, and that is the reason StarsTell.com provides consultation service. So, to avail of the online consultation facility, you must visit https://www.starstell.com/talk-to-astrologer.php
ReplyDeleteGreat piece of writing! The combination of your straightforward and succinct writing style, along with meticulously researched information, resulted in a highly educational and pleasant reading experience.
ReplyDeleteBecome a Professional Gigolo Boy to Create Unforgettable Memories - Embrace Gigolomania!
This was a very insightful read. The statistics on wind energy really stood out to me. Looking forward to your next piece.
ReplyDeleteGet an Expert Marriage Problem Solution with MyAstron Astrology
This comment has been removed by the author.
ReplyDeleteWonderful blog that is enjoyable to read. It has very helpful information.
ReplyDeleteIf you want extra income with a day or night part-time job, join a part-time playboy job . It is a good source of income with a lot and less work. Apply for a callboy job at callboyone.com and earn a lot of money making part-time calls.