We run our web application on Amazon EC2 with load-balanced, autoscaling web servers (IIS).
Before autoscaling, our deployment process was file-copy to a couple of big web servers.
Now with autoscaling we have anything from 5 to 12 webservers which appear and vanish at will, making the deployment process more difficult.
To address this, I wrote a powershell script that retrieves the IP of servers in an autoscaling group and uses MSDeploy to synchronise them with a designated deployment server (in load balancer, outside of autoscaling group). It then creates a new AMI and updates the autoscaling config.
All seemed to be good, until after rebuilding the deployment server, the sync script does not update the running state of the web sites. So I can put the site into maintenance mode.
I would like to know:
how other people approach the problem (specifically syncing iis servers in autoscaling ec2) (in the absence of WFF for IIS 8)
why the start/stop sync is failing
Code:
Set-AWSCredentials -AccessKey XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX -SecretKey XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Set-DefaultAWSRegion "us-west-2"
$date = get-date
$dateString = $date.ToString("yyyyMMdd-HHmm")
$name = $dateString + "Web"
$imageId = new-ec2image -InstanceId x-xxxxxxxx -Name $name -NoReboot 1
$launchConfiguration = New-ASLaunchConfiguration -LaunchConfigurationName $name -ImageId $imageId -InstanceType "m3.medium" -SecurityGroups @('Web') -InstanceMonitoring_Enabled $false
Update-AsAutoScalingGroup -AutoScalingGroupName "XxxxxxxxxxxxXxxxxxxxxx" -LaunchConfigurationName $name
$a = Get-ASAutoScalingInstance | select -expandproperty InstanceId | Get-EC2Instance | select -expandproperty RunningInstance | select -property PrivateIpAddress
foreach($ip in $a)
{
$command = "C:\Program Files\IIS\Microsoft Web Deploy V3\msdeploy.exe"
$arg = "-dest:webServer,computerName=" + $ip.PrivateIpAddress;
$args = @('-verb:sync', '-source:webServer', $arg)
&$command $args
}