AWS Elastic Beanstalk
Developer Guide (API Version 2010-12-01)
« PreviousNext »
View the PDF for this guide.Go to the AWS Discussion Forum for this product.Go to the Kindle Store to download this guide in Kindle format.Did this page help you?  Yes | No |  Tell us about it...

Develop, Test, and Deploy

The following diagram of a typical software development life cycle includes deploying your application to AWS Elastic Beanstalk.

Software Development Life Cycle

After developing and testing your application locally, you will typically deploy your application to AWS Elastic Beanstalk. After deployment, your application will be live at a URL such as http://myexampleapp-wpams3yrvj.elasticbeanstalk.com. Because your application is live, you should consider setting up multiple environments, such as a testing environment and a production environment. You can use the AWS Toolkit for Visual Studio if you want to set up different AWS accounts for testing, staging, and production. For more information about managing multiple accounts, see Managing Multiple Accounts.

Amazon Route 53 is a highly available and scalable Domain Name System (DNS) web service. You can point your domain name to the Amazon Route 53 CNAME <yourappname>.elasticbeanstalk.com. Contact your DNS provider to set this up. For information about how to map your root domain to your Elastic Load Balancer, see Using AWS Elastic Beanstalk with Amazon Route 53 to Map Your Domain to Your Load Balancer.

After you remotely test and debug your AWS Elastic Beanstalk application, you can make any updates and then redeploy to AWS Elastic Beanstalk. After you are satisfied with all of your changes, you can upload the latest version to your production environment. The following sections explain each stage of the software development life cycle.

Create a Project

Visual Studio provides templates for different programming languages and application types. You can start with any of these templates. The AWS Toolkit for Visual Studio also provides three project templates that bootstrap development of your application: AWS Console Project, AWS Web Project, and AWS Empty Project. For this example, you'll create a new ASP.NET Web Application.

To create a new ASP.NET Web Application project

  1. In Visual Studio, on the File menu, click New and then click Project.

  2. In the New Project dialog box, click Installed Templates, click Visual C#, and then click Web. Click ASP.NET Web Application, type a project name, and then click OK.

To run a project

  • Do one of the following:

    • Press F5.

    • Select Start Debugging from the Debug menu.

Test Locally

Visual Studio makes it easy for you to test your application locally. To test or run ASP.NET web applications, you need a web server. Visual Studio offers several options, such as Internet Information Services (IIS), IIS Express, or the built-in Visual Studio Development Server. To learn about each of these options and to decide which one is best for you, go to Web Servers in Visual Studio for ASP.NET Web Projects .

Deploy to AWS Elastic Beanstalk

After testing your application, you are ready to deploy it to AWS Elastic Beanstalk.

To deploy your application to AWS Elastic Beanstalk using the AWS Toolkit for Visual Studio

  1. In Solution Explorer, right-click your application and then select Publish to AWS. The Publish to AWS wizard opens.

    Publish to AWS Wizard 1
  2. Enter your account information.

    1. In the AWS account to use for deployment list, click your account, or click Other to enter new account information.

    2. In the Region list, click the region where you want to deploy your application. For information about this product's regions, go to Regions and Endpoints in the Amazon Web Services General Reference. If you select a region that is not supported by AWS Elastic Beanstalk, then the option to deploy to AWS Elastic Beanstalk will become unavailable.

    3. Select Deploy new application with template text box and click Elastic Beanstalk.

    4. Click Next. The Application page appears.

      Publish to Beanstalk Wizard 2
  3. Enter your application details.

    1. In the Name box, type the name of the application.

    2. In the Description box, type a description of the application. This step is optional.

    3. The version label of the application is automatically populated in the Deployment version label text box.

    4. Select Deploy application incrementally to deploy only the changed files. An incremental deployment is faster because you are updating only the files that changed instead of all the files. If you choose this option, an application version will be set from the Git commit ID. If you choose to not deploy your application incrementally, then you can update the version label in the Deployment version label box.

    5. Click Next. The Environment page appears.

      Publish to Beanstalk Wizard 3
  4. Describe your environment details.

    1. Select the Create a new environment for this application button.

    2. In the Name box, type a name for your environment.

    3. In the Description box, type a description for your environment. This step is optional.

    4. The environment URL is automatically populated in the Environment URL box once you move your cursor to the box.

    5. Click the Check availability button to make sure the environment URL is available.

    6. Click Next. The AWS Options page appears.

      Publish to Beanstalk Wizard 4
  5. Configure additional options and security information for your deployment.

    1. In the Container Type list, click 64bit Windows Server 2012 running IIS 8 or 64bit Windows Server 2008 running IIS 7.5.

    2. In the Instance Type list, click Micro.

    3. In the Key pair list, click Create new key pair. Type a name for the new key pair—in this example, we use my example key pair—and then click OK. A key pair enables you to remote desktop into your Amazon EC2 instances. For more information on Amazon EC2 key pairs, see Using Credentials in the Amazon Elastic Compute Cloud User Guide.

    4. Select an instance profile.

      If you are using a non-legacy container, you have the option to select an instance profile. If you are using a legacy container, this option does not appear in the dialog box. An instance profile provides applications and services access to AWS resources using temporary security credentials. For example, if your application requires access to DynamoDB, it must use AWS security credentials to make an API request. The application can use the temporary security crendentials so you do not have to store long-term credentials on an EC2 instance or update the EC2 instance every time the credentials are rotated. In addition, Elastic Beanstalk requires an instance profile to rotate logs to Amazon S3. The Instance Profile list displays the profiles available for your AWS Elastic Beanstalk environment. If you do not have an instance profile, you can select Create a default instance profile. AWS Elastic Beanstalk creates a default instance profile and updates the Amazon S3 bucket policy to allow log rotation. If you choose to not use the default instance profile, you need to grant permissions for AWS Elastic Beanstalk to rotate logs. For instructions, see Using a Custom Instance Profile. For more information about log rotation, see Configuring Containers with AWS Elastic Beanstalk. For more information about using instance profiles with AWS Elastic Beanstalk, see Using IAM Roles with AWS Elastic Beanstalk.

      Note

      Users must have permission to create a default profile. For more information, see Granting IAM Users Permissions to Create IAM Roles.

    5. If you are using a non-legacy container, you have the option to create your environment inside an existing VPC; to do this, click Launch into VPC. You can configure the VPC information on the next page. For more information about Amazon VPC, go to Amazon Virtual Private Cloud (Amazon VPC). For a list of supported non-legacy container types, see Why are some container types marked legacy?.

    6. Click Next. If you selected to launch your environment inside a VPC, the VPC Options page appears; otherwise, the Additional Options page appears.

      Publish to Beanstalk Wizard 5
  6. Configure your VPC options.

    1. Select the VPC ID of the VPC in which you would like to launch your environment.

      Note

      If you do not see the VPC information, then you have not created a VPC in the same region in which you are launching your environment. To learn how to create a VPC, see Using AWS Elastic Beanstalk with Amazon VPC.

    2. In the ELB Scheme list, select private if you do not want your elastic load balancer to be available to the Internet.

    3. Select the subnets for the elastic load balancer and the EC2 instances. If you created public and private subnets, make sure the elastic load balancer and the EC2 instances are associated with the correct subnet. By default, Amazon VPC creates a default public subnet using 10.0.0.0/24 and a private subnet using 10.0.1.0/24. You can view your existing subnets in the Amazon VPC console at https://console.aws.amazon.com/vpc/.

    4. Select the VPC security group for your NAT instance. For instructions on how to create this security group and update your default VPC security group, see Step 2: Configure the Default VPC Security Group for the NAT Instance.

  7. Click Next. The Application Options page appears.

    Publish to Beanstalk Wizard 6
  8. Configure your application options.

    1. Select .NET Runtime 4.0 from the Target runtime pull-down menu.

    2. Elastic Load Balancing uses a health check to determine whether the Amazon EC2 instances running your application are healthy. The health check determines an instance's health status by probing a specified URL at a set interval. You can override the default URL to match an existing resource in your application (e.g., ‘/myapp/index.aspx’) by entering it in the Application health check URL box. For more information about application health checks, see Health Checks.

    3. Type an email address if you want to recieve Amazon Simple Notification Service (Amazon SNS) notifications of important events affecting your application.

    4. The Application Environment section lets you specify environment variables on the Amazon EC2 instances that are running your application. This setting enables greater portability by eliminating the need to recompile your source code as you move between environments.

    5. Click the application credentials option you want to use to deploy your application.

    6. Click Next. If you have previously set up an Amazon RDS database, the Amazon RDS DB Security Group page appears. Otherwise, skip the next step to review your deployment information.

      Publish to Beanstalk Wizard 7
  9. Configure the Amazon RDS Database security group.

    1. If you want to connect your Elastic Beanstalk environment to your Amazon RDS DB Instance, then select one or more security groups. Click Next. The Review page appears.

    Publish to Beanstalk Wizard 8
  10. Review your deployment options. If everything is as you want, click Deploy.

    Your ASP.NET project will be exported as a web deploy file, uploaded to Amazon S3, and registered as a new application version with Elastic Beanstalk. The Elastic Beanstalk deployment feature will monitor your environment until it becomes available with the newly deployed code. On the env:<environment name> tab, you will see status for your environment.

    Environment Status

Debug/View Logs

To investigate any issues, you can view logs. For information about viewing logs, see Working with Logs. If you need to test remotely, you can connect to your Amazon EC2 instances. For instructions on how to connect to your instance, see Listing and Connecting to Server Instances.

Edit the Application and Redeploy

Now that you have tested your application, it is easy to edit and redeploy your application and see the results in moments.

To edit and redeploy your ASP.NET web application

  1. In Solution Explorer, right-click your application, and then click Republish to Environment <your environment name>. The Re-publish to AWS Elastic Beanstalk wizard opens.

    Publish to Beanstalk Wizard 1
  2. Review your deployment details and click Deploy.

    Note

    If you want to change any of your settings, you can click Cancel and use the Publish to AWS wizard instead. For instructions, see Deploy to AWS Elastic Beanstalk .

    Your updated ASP.NET web project will be exported as a web deploy file with the new version label, uploaded to Amazon S3, and registered as a new application version with Elastic Beanstalk. The Elastic Beanstalk deployment feature monitors your existing environment until it becomes available with the newly deployed code. On the env:<environment name> tab, you will see the status of your environment.

Deploy to Production

When you are satisfied with all of the changes you want to make to your application, you can deploy your application version to your production environment.

To deploy an application version to production

  1. Right-click your AWS Elastic Beanstalk application by expanding the AWS Elastic Beanstalk node in AWS Explorer. Select View Status.

  2. In the App: <application name> tab, click Versions.

    Application Versions
  3. Click the application version you want to deploy and click Publish Version. The Publish Application Version wizard appears.

    Publish Application Version Wizard 1
  4. Describe your environment details.

    1. Select the Create a new environment for this application button.

    2. In the Name box, type a name for your environment name.

    3. In the Description box, type a description for your environment. This step is optional.

    4. The environment URL is auto-populated in the Environment URL box.

    5. Click Check availability to make sure the environment URL is available.

    6. Click Next. The AWS Options page appears.

  5. Configure additional options and security information for your deployment.

    1. In the Container Type list, click 64bit Windows Server 2012 running IIS 8 or 64bit Windows Server 2008 running IIS 7.5.

    2. In the Instance Type list, click Micro.

    3. In the Key pair list, click Create new key pair. Type a name for the new key pair—in this example, we use my example key pair—and then click OK. A key pair enables you to remote desktop into your Amazon EC2 instances. For more information on Amazon EC2 key pairs, see Using Credentials in the Amazon Elastic Compute Cloud User Guide.

    4. Select an instance profile.

      If you are using a non-legacy container, you have the option to select an instance profile. If you are using a legacy container, this option does not appear in the dialog box. An instance profile provides applications and services access to AWS resources using temporary security credentials. For example, if your application requires access to DynamoDB, it must use AWS security credentials to make an API request. The application can use the temporary security crendentials so you do not have to store long-term credentials on an EC2 instance or update the EC2 instance every time the credentials are rotated. In addition, Elastic Beanstalk requires an instance profile to rotate logs to Amazon S3. The Instance Profile list displays the profiles available for your AWS Elastic Beanstalk environment. If you do not have an instance profile, you can select Create a default instance profile. AWS Elastic Beanstalk creates a default instance profile and updates the Amazon S3 bucket policy to allow log rotation. If you choose to not use the default instance profile, you need to grant permissions for AWS Elastic Beanstalk to rotate logs. For instructions, see Using a Custom Instance Profile. For more information about log rotation, see Configuring Containers with AWS Elastic Beanstalk. For more information about using instance profiles with AWS Elastic Beanstalk, see Using IAM Roles with AWS Elastic Beanstalk.

      Note

      Users must have permission to create a default profile. For more information, see Granting IAM Users Permissions to Create IAM Roles.

    5. If you are using a non-legacy container, you have the option to create your environment inside an existing VPC; to do this, click Launch into VPC. You can configure the VPC information on the next page. For more information about Amazon VPC, go to Amazon Virtual Private Cloud (Amazon VPC). For a list of supported non-legacy container types, see Why are some container types marked legacy?.

    6. Click Next. If you selected to launch your environment inside a VPC, the VPC Options page appears, otherwise the Additional Options page appears.

      Publish to Beanstalk Wizard 3
  6. Configure your VPC options.

    1. Select the VPC ID of the VPC in which you would like to launch your environment.

      Note

      If you do not see the VPC information, then you have not created a VPC in the same region in which you are launching your environment. To learn how to create a VPC, see Using AWS Elastic Beanstalk with Amazon VPC.

    2. In the ELB Scheme list, select private if you do not want your elastic load balancer to be available to the Internet.

    3. Select the subnets for the elastic load balancer and the EC2 instances. If you created public and private subnets, make sure the elastic load balancer and the EC2 instances are associated with the correct subnet. By default, Amazon VPC creates a default public subnet using 10.0.0.0/24 and a private subnet using 10.0.1.0/24. You can view your existing subnets in the Amazon VPC console at https://console.aws.amazon.com/vpc/.

    4. Select the VPC security group for your NAT instance. For instructions on how to create this security group and update your default VPC security group, see Step 2: Configure the Default VPC Security Group for the NAT Instance.

    5. Click Next. The Application Options page appears.

      Publish to Beanstalk Wizard 5
  7. Configure your application options.

    1. Select .NET Runtime 4.0 from the Target runtime pull-down menu.

    2. Elastic Load Balancing uses a health check to determine whether the Amazon EC2 instances running your application are healthy. The health check determines an instance's health status by probing a specified URL at a set interval. You can override the default URL to match an existing resource in your application (e.g., /myapp/index.aspx) by entering it in the Application health check URL box. For more information about application health checks, see Health Checks.

    3. Elastic Load Balancing uses a health check to determine whether the Amazon EC2 instances running your application are healthy. The health check determines an instance's health status by probing a specified URL at a set interval. You can override the default URL to match an existing resource in your application (e.g., ‘/myapp/index.aspx’) by entering it in the Application health check URL box. For more information about application health checks, see Health Checks.

    4. Type an email address if you want to recieve Amazon Simple Notification Service (Amazon SNS) notifications of important events affecting your application.

    5. The Application Environment section lets you specify environment variables on the Amazon EC2 instances that are running your application. This setting enables greater portability by eliminating the need to recompile your source code as you move between environments.

    6. Click the application credentials option you want to use to deploy your application.

    7. Click Next. If you have previously set up an Amazon RDS database, the Amazon RDS DB Security Group page appears. Otherwise, skip the next step to review your deployment information.

      Publish to Beanstalk Wizard 6
  8. Configure the Amazon RDS Database security group.

    1. If you want to connect your Elastic Beanstalk environment to your Amazon RDS DB Instance, select one or more security groups. Click Next. The Review page appears.

    Publish to Beanstalk Wizard 7
  9. Review your deployment options, and click Deploy.

    Your ASP.NET project will be exported as a web deploy file and uploaded to Amazon S3. The Elastic Beanstalk deployment feature will monitor your environment until it becomes available with the newly deployed code. On the env:<environment name> tab, you will see status for your environment.

Deploy an Existing Application Version to an Existing Environment

You can deploy an existing application to an existing environment if, for instance, you need to roll back to a previous application version.

To deploy an application version to an existing environment

  1. Right-click your AWS Elastic Beanstalk application by expanding the AWS Elastic Beanstalk node in AWS Explorer. Select View Status.

  2. In the App: <application name> tab, click Versions.

    Application Versions
  3. Click the application version you want to deploy and click Publish Version. The Publish Application Version wizard appears.

    Publish Application Version Wizard 1
  4. Click Next. The Review page appears.

    Publish Application Version Wizard 2
  5. Review your deployment options, and click Deploy.

    Your ASP.NET project will be exported as a web deploy file and uploaded to Amazon S3. The Elastic Beanstalk deployment feature will monitor your environment until it becomes available with the newly deployed code. On the env:<environment name> tab, you will see status for your environment.