Minimum configuration to use codedeploy with .NET MVC in AWS

trying codedeploy for the first time in AWS and looking for a minimum to get going? Using code deploy in aws needs 3 minimum steps

  1. install codedeploy agent on targets instances
  2. setup appconfig.yml file to direct how codedeploy will work, where it will deploy using agents etc
  3. setup codedeploy on console to trigger push to target.

to setup codedeploy agent on target instance where you wish to deploy code, please use following commands (for windows server as we are targetting mvc over IIS web server)

Set-ExecutionPolicy RemoteSigned
Import-Module AWSPowerShell

PS C:\Users\Administrator> powershell.exe -Command Set-AWSCredentials 
-AccessKey 'xxxxx' -SecretKey 'xxxx' Initialize-AWSDefaults

(there are better ways to do this but just going with this for demo)
New-Item –Path "c:\temp" –ItemType "directory" -Force
powershell.exe -Command Read-S3Object -BucketName bucket-name 
-Key latest/codedeploy-agent.msi -File c:\temp\codedeploy-agent.msi
-AccessKey 'xxxxx' -SecretKey 'xxxxxx'
c:\temp\codedeploy-agent.msi /quiet /l c:\temp\host-agent-install-log.txt
powershell.exe -Command Get-Service -Name codedeployagent

bucket-name represents one of the following:

  • aws-codedeploy-us-east-1 for instances in the US East (N. Virginia) region
  • aws-codedeploy-us-east-2 for instances in the US East (Ohio) region
  • aws-codedeploy-us-west-1 for instances in the US West (N. California) region
  • aws-codedeploy-us-west-2 for instances in the US West (Oregon) region
  • aws-codedeploy-ca-central-1 for instances in the Canada (Central) region
  • aws-codedeploy-eu-west-1 for instances in the EU (Ireland) region
  • aws-codedeploy-eu-west-2 for instances in the EU (London) region
  • aws-codedeploy-eu-central-1 for instances in the EU (Frankfurt) region
  • aws-codedeploy-ap-northeast-1 for instances in the Asia Pacific (Tokyo) region
  • aws-codedeploy-ap-northeast-2 for instances in the Asia Pacific (Seoul) region
  • aws-codedeploy-ap-southeast-1 for instances in the Asia Pacific (Singapore) region
  • aws-codedeploy-ap-southeast-2 for instances in the Asia Pacific (Sydney) region
  • aws-codedeploy-ap-south-1 for instances in the Asia Pacific (Mumbai) region
  • aws-codedeploy-sa-east-1 for instances in the South America (São Paulo) region

If the AWS CodeDeploy agent is installed and running, after the Get-Service command call, you should see output similar to the following:


Status   Name                DisplayName
------   ----                -----------
Running  codedeployagent    CodeDeploy Host Agent Service

use the below code to make a simple appconfig.yml file and place it in the root if the zip file along with entire publish code. Make sure you published your code using file system option and not the web deploy that is used for beanstalk deployments.

just upload this zip to s3 and use codedeploy to push the file to target.

version: 0.0
os: windows
files:
– source: \
destination: c:\inetpub\wwwroot\

my final zip file structure looked like this and it worked successfully.

appconfig