tfrege
tfrege

Reputation: 101

How to install IIS in Windows EC2 using AWS CodeDeploy?

I need to deploy a .NET project on an EC2 instance running Windows, and in order for the code to run I need to make sure the instance has IIS installed. This also needs to be automated (hence the need for CodeDeploy). How can I install IIS and MS-SQL using CodeDeploy?

I'm a bit familiar with CodeBuild but I don't think it will particularly help me here. I'm using CodeBuild to build/compile the .NET application and put the output in S3. Now I need the next step which is taking that code and putting it on an EC2 running IIS and MS-SQL.

Upvotes: 1

Views: 1567

Answers (1)

shariqmaws
shariqmaws

Reputation: 8890

I would recommend to install IIS/MS-Sql from within UserData of the EC2 instance or use a Pre-baked (Golden) Image approach. Installing software via CodeDeploy is not recommended as such feature installation may take long time in Windows environment and is error prone.

An example UserData to install IIS on Windows is as follows:

<powershell>
Import-Module ServerManager
tzutil /s "AUS Eastern Standard Time"
Add-WindowsFeature Web-WebServer -includeAllSubFeature -logpath $env:temp\\Web-WebServer_feature.log
Add-WindowsFeature Web-Mgmt-Tools -includeAllSubFeature -logpath $env:temp\\Web-Mgmt-Tools_feature.log
</powershell>

Use CodeDeploy to Deploy your application artifacts and restart any service(s) if required. Deployment instructions for CodeDeploy are stored in appspec.yml file in the root of your source package. The syntax for a Windows version to deploy to IIS is detailed here [1].

References:
[1] https://docs.aws.amazon.com/codedeploy/latest/userguide/tutorials-windows-configure-content.html#tutorials-windows-configure-content-add-appspec-file

Upvotes: 2

Related Questions