|« PreviousNext »|
|Did this page help you? Yes | No | Tell us about it...|
The following diagram illustrates a typical software development life cycle that includes deploying your application to AWS Elastic Beanstalk.
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 Eclipse if you want to set up different AWS accounts for testing, staging, and production. For more information about managing multiple accounts, see Managing Multiple AWS 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.
The AWS Toolkit provides an AWS Java web project template for use in Eclipse. The template creates a WTP dynamic web project that includes the AWS SDK for Java in the project's classpath. Your AWS Account credentials and a simple index.jsp file are provided to help you get started.
AWS Elastic Beanstalk supports Java 1.5 and 1.6.
To create a new AWS Java web project in Eclipse
Click File from the Eclipse file menu, and select New.
Select. The New AWS Java Web Project wizard appears.
Enter the name of your AWS Java Web Project in the Project name field.
Select the AWS account you want to use to deploy your application. If you haven't already configured an account, click Configure AWS accounts to add a new account. For instructions on how to add a new account, go to Managing Multiple AWS Accounts.
Select the application you want to start from. If you select Travel Log - Sample Java Web Application, then you need to select the following items:
From the Use services in this region list, click the region where you want your application to run.
From the Language list, click the language that you want the application to be displayed in.
A new AWS Java web project is created inside your Eclipse workspace. To help you
get started developing your project, a basic index.jsp file is included inside your
WebContent folder. Your AWS security credentials are included in the
AwsCredentials.properties file inside your src folder.
You can test and debug your application before you deploy it to AWS Elastic Beanstalk using the built-in WTP tools.
To test and debug your application locally
Right-click your Java web project in the Project Explorer view.
Select Run As, and click Run On Server. The Run On Server wizard appears.
Select Manually define a new server.
Expand the Apache item in the Server Type explorer and select Tomcat v6.0 Server or Tomcat v7.0 Server.
You might be prompted to install Apache. If you are using Microsoft Windows, you can click the Download and Install button to install the software. After you have installed the software, click Finish.
You will now see your application appear on the localhost.
After you have tested your application, you can now deploy to AWS Elastic Beanstalk.
The Elastic Beanstalk server is an Eclipse WTP server with added functionality that enables you to restart, publish, and terminate your Java web application. The Elastic Beanstalk server in Eclipse represents an AWS Elastic Beanstalk environment. An environment is a running instance of an application on the AWS platform.
Before deploying your application, you must define your server and configure your application.
To define your Java web application server
Right-click your Java web project in the Project Explorer view.
Select Amazon Web Services, and click Deploy to AWS Elastic Beanstalk. The Run On Server wizard appears.
Select Manually define a new server.
Expand the Amazon Web Services item in the Server Type explorer and select AWS Elastic Beanstalk for Tomcat 6 or AWS Elastic Beanstalk for Tomcat 7.
Enter the server's host name and server name in the provided fields. Click Next. The Configure Application and Environment options appear.
You have defined your AWS Java web application server. You must still configure your AWS Java web application before deployment.
Each application has a configuration and a version. A specific application instance is called an environment. An environment can have only one version at a time, but you can have multiple simultaneous environments running the same or different versions. AWS resources created for an environment include one elastic load balancer, an Auto Scaling group, and one or more Amazon EC2 instances.
To configure your Amazon web application
Select an Amazon region from the Region drop-down menu.
Enter an application name in the provided field, and optionally provide an application description.
Enter an environment name in the provided field, and optionally provide an environment description. The environment name must be unique within your AWS Account. Click Next.
Click Deploy with a key pair.
Right-click anywhere inside the key pair list menu and select New Key Pair. The Create New Key Pair dialog box appears.
Enter a key pair name in the Key Pair Name text field. Enter a private key directory in the Private Key Directory text field, or click Browse and select a directory.
Select the Use incremental deployment check box 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.
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.
Users must have permission to create a default profile. For more information, see Granting IAM Users Permissions to Create IAM Roles.
Click OK and select the newly created key pair in the key pair list menu.
After you finish the wizard, you will be prompted to enter a new version label for your application version, and then a new server will appear in the Server view. Your Java web project will be exported as a WAR 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, and it will open your application in a web browser when it's ready.
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.
Now that you have tested your application, it is easy to edit and redeploy it, and to see the results in moments. Typically, when you redeploy your application, all of the files will get updated. However, if you choose to do an incremental deployment, the toolkit will update the modified files, making your deployment faster.
To choose to use incremental deployments
In the AWS Toolkit for Eclipse, expand the AWS Elastic Beanstalk node and your application node.
In AWS Explorer, double-click your AWS Elastic Beanstalk environment.
In the Overview pane, expand the AWS Elastic Beanstalk Deployment tab, and then select Use Incremental Deployments.
To edit and redeploy your Java web application
In Eclipse, locate and open the index.jsp file in the Project Explorer or Package Explorer view. Edit the source contained in the file.
Right-click your Java web project in the Project Explorer or Package Explorer view.
Select Amazon Web Services, and click Deploy to AWS Elastic Beanstalk. The Run on Server wizard appears.
Select Choose an existing server, and click Finish.
If you launched a new environment using the AWS Management Console, you will need to import your existing environments into Eclipse. For more information, see Importing Existing Environments into Eclipse.
When the application has deployed successfully, index.jsp is displayed in Eclipse and shows any edits you have made.
When you are satisfied with all of the changes you want to make to your application, you can deploy your application to your production environment. To deploy the existing version of the application to production with zero downtime, follow the steps at Deploying Versions with Zero Downtime. You can also create a new environment inside Eclipse, but you will need to specify a new version for your application. For instructions on deploying to AWS Elastic Beanstalk inside Eclipse, see Deploy to AWS Elastic Beanstalk.