Deploying Elastic Beanstalk Applications in .NET Using the Deployment Tool
The AWS Toolkit for Visual Studio includes a deployment tool, a command line tool that provides the same functionality as the deployment wizard in the AWS Toolkit. You can use the deployment tool in your build pipeline or in other scripts to automate deployments to Elastic Beanstalk.
The deployment tool supports both initial deployments and redeployments. If you previously deployed your application using the deployment tool, you can redeploy using the deployment wizard within Visual Studio. Similarly, if you have deployed using the wizard, you can redeploy using the deployment tool.
The deployment tool does not apply recommended values for configuration options like the console or EB CLI. Use configuration files to ensure that any settings that you need are configured when you launch your environment.
This chapter walks you through deploying a sample .NET application to Elastic Beanstalk using the deployment tool, and then redeploying the application using an incremental deployment. For a more in-depth discussion about the deployment tool, including the parameter options, see Deployment Tool.
To use the deployment tool, you need to install the AWS Toolkit for Visual Studio. For information on prerequisites and installation instructions, see AWS Toolkit for Microsoft Visual Studio.
The deployment tool is typically installed in one of the following directories on Windows:
C:\Program Files\AWS Tools\Deployment Tool\awsdeploy.exe
C:\Program Files (x86)\AWS Tools\Deployment Tool\awsdeploy.exe
Deploy to Elastic Beanstalk
To deploy the sample application to Elastic Beanstalk using the deployment tool, you first need to
ElasticBeanstalkDeploymentSample.txt configuration file, which
is provided in the
Samples directory. This configuration file contains
the information necessary to deploy your application, including the application name,
application version, environment name, and your AWS access credentials. After modifying the
configuration file, you then use the command line to deploy the sample application. Your web
deploy file is uploaded to Amazon S3 and registered as a new application version with Elastic Beanstalk. It
will take a few minutes to deploy your application. Once the environment is healthy, the
deployment tool outputs a URL for the running application.
To deploy a .NET application to Elastic Beanstalk
Samplessubdirectory where the deployment tool is installed, open
ElasticBeanstalkDeploymentSample.txtand enter your AWS access key and AWS secret key as in the following example.
### AWS Access Key and Secret Key used to create and deploy the application instance AWSAccessKey = AKIAIOSFODNN7EXAMPLE AWSSecretKey = wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
For API access, you need an access key ID and secret access key. Use IAM user access keys instead of AWS root account access keys. IAM lets you securely control access to AWS services and resources in your AWS account. For more information about creating access keys, see How Do I Get Security Credentials? in the AWS General Reference.
At the command line prompt, type the following:
C:\Program Files (x86)\AWS Tools\Deployment Tool>awsdeploy.exe /w Samples\ElasticBeanstalkDeploymentSample.txt
It takes a few minutes to deploy your application. If the deployment succeeds, you will see the message,
Application deployment completed; environment health is Green.
If you receive the following error, the CNAME already exists.
[Error]: Deployment to AWS Elastic Beanstalk failed with exception: DNS name (MyAppEnv.elasticbeanstalk.com) is not available.
Because a CNAME must be unique, you need to change
In your web browser, navigate to the URL of your running application. The URL will be in the form <CNAME.elasticbeanstalk.com> (e.g.,
Redeploy to Elastic Beanstalk
You can redeploy your application using an incremental deployment. Incremental deployments are faster because you are updating only the files that have changed instead of all the files. This section walks you through redeploying the sample application you deployed in Deploy to Elastic Beanstalk.
To edit and redeploy a .NET application to Elastic Beanstalk
AWSDeploymentSampleApp.zipfrom the Samples directory to a location on your computer such as
Modify one of the files in the
AWSDeploymentSampleAppdirectory. For example, you can modify the title in
ElasticBeanstalkDeploymentSample.txtconfiguration file, do the following:
Specify the location where you extracted the files. This means modifying the value for the
DeploymentPackagekey in the
Incremental Deployment Settingssection in
ElasticBeanstalkDeploymentSample.txt. For example:
Remove the # in front of
#in front of
Non-Incremental Deployment Settings.
At the command line, type the following:
C:\Program Files (x86)\AWS Tools\Deployment Tool>awsdeploy.exe /r Samples\ElasticBeanstalkDeploymentSample.txt
If this command succeeds, you should see something similar to the following:
...environment 'MyAppEnvironment' found and available for redeployment (configuration parameters not required for redeployment will be ignored) ...starting redeployment to AWS Elastic Beanstalk environment 'MyAppEnvironment' ...starting incremental deployment to environment 'MyAppEnvironment' ...finished incremental deployment in 9199.9199 ms
In your web browser, navigate to the same URL as in Deploy to Elastic Beanstalk. You should see your updated application.