AWS Developer Tools Blog

Custom Elastic Beanstalk Application Deployments

In the previous post, you learned how to use the new deployment manifest for the the Windows container in AWS Elastic Beanstalk to deploy a collection of ASP.NET Core and traditional ASP.NET applications. The deployment manifest supports a third deployment type, custom application deployment.

Custom application deployment is a powerful feature for advanced users who want to leverage the power of Elastic Beanstalk to create and manage their AWS resources and also have complete control over how their application is deployed. For a custom application deployment, you declare the PowerShell scripts for the three actions that Elastic Beanstalk performs: install, restart, and uninstall. Install is used when a deployment is initiated, restart is used when the RestartAppServer API is called (which can be done from either the toolkit or the web console), and uninstall is invoked on the previous deployment whenever a new deployment occurs.

For example, you might have an ASP.NET application that you want to deploy, and your documentation team has written a static website that they want to include with the deployment. You can do this by writing your deployment manifest as follows.

  "manifestVersion": 1,
  "deployments": {
    "msDeploy": [
        "name": "app",
        "parameters": {
          "appBundle": "",
          "iisPath": "/"
    "custom": [
        "name": "PowerShellDocs",
        "scripts": {
          "install": {
            "file": "install.ps1"
          "restart": {
            "file": "restart.ps1"
          "uninstall": {
            "file": "uninstall.ps1"

The scripts listed for each action are in the application bundle relative to the deployment manifest file. For this example, the application bundle will also contain a file that contains the static website from your documentation team.

The install.ps1 script extracts the .zip file and sets up the IIS path.

Add-Type -assembly ""
[io.compression.zipfile]::ExtractToDirectory('./', 'c:inetpubwwwrootdocumentation')

C:WindowsSysNativeWindowsPowerShellv1.0powershell.exe -Command {New-WebApplication -Name documentation -PhysicalPath  c:inetpubwwwrootdocumentation -Force}

Because your application is running in IIS, the restart action will invoke an IIS reset.

iisreset /timeout:1

For uninstall scripts, it’s important to clean up all settings and files that were performed during the install stage so that when the new version is being installed, you can avoid any collision with the previous deployments. For this example, you need to remove the IIS application for the static website and remove the files.

C:WindowsSysNativeWindowsPowerShellv1.0powershell.exe -Command {Remove-WebApplication -Name documentation}

Remove-Item -Recurse -Force 'c:inetpubwwwrootdocumentation'

Using these scripts files and the file that are included in the application bundle, the deployment will deploy your ASP.NET application and then deploy the documentation site.

This example showed a simple deployment of a simple static website. By using the power of custom application deployment, you can deploy any type of application and let Elastic Beanstalk manage the AWS resources for the application.