| « PreviousNext » | |
![]() ![]() ![]() | Did this page help you? Yes | No | Tell us about it... |
Topics
The following diagram illustrates a typical software development life cycle including deploying your application to AWS Elastic Beanstalk.

Typically, after developing and testing your application locally, you
will deploy your application to AWS Elastic Beanstalk. At this point, your application will be live at a
URL such as http://myexampleapp-wpams3yrvj.elasticbeanstalk.com. Because your
application will be live, you should consider setting up multiple environments, such as
a testing environment and a production environment. You can point your domain name to
the Amazon Route 53 (a highly
available and scalable Domain Name System (DNS) web service) 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 then make any updates and redeploy to AWS Elastic Beanstalk. After you are
satisfied with all of your changes, you can upload your latest version to your
production environment. The following sections provide more details explaining each
stage of the software development life cycle.
After installing AWS DevTools on your local computer, you use the Git command line as you normally would to create your local repository and add and commit changes. You create your PHP application as you normally would with your favorite editor. If you don't already have a PHP application ready, you can use a simple "Hello World" application. Type the following program into your favorite editor, and save it as a PHP file.
<html> <head> <title>PHP Test</title> </head> <body> <?php echo '<p>Hello World</p>'; ?> </body> </html>
Next, create a new local repository, add your new program, and commit your change.
git add . git commit -m "initial check-in"
Note
For information about Git commands, go to Git - Fast Version Control System.
Normally, at this point you would test your application locally before deploying to AWS Elastic Beanstalk. Suppose you find a few issues you would like to fix. Using the above "Hello World" application, add a "!" after "Hello World" and check in your changes. Update your index.php file, and then type the following commands to check in your updated file.
git add . git commit -m "my second check-in"
After you commit your changes, you should see a response similar to the following:
[master 0535814] my second check-in 1 files changed, 1 insertions(+), 1 deletions(-)
Note the commit ID that is generated. AWS DevTools will use this ID to generate a version label for your application.
After testing your application, you are ready to deploy it to AWS Elastic Beanstalk. Deploying requires the following steps:
Use the AWS Management Console, CLI, or APIs to create a sample application.
Configure your Git environment. AWS DevTools is configured through the git aws.config command.
Update the sample application with your application.
When you update the sample application with your application, AWS Elastic Beanstalk replaces the existing sample application version with your new application version in the existing environment.
To create a sample application
Follow the instructions at Creating New Applications to create a sample AWS Elastic Beanstalk application using the AWS Management Console, CLI, or APIs. When selecting a container, select either 32-bit or 64-bit Amazon Linux running PHP.
Verify that your AWS Elastic Beanstalk environment is healthy. You should see something similar to the following illustration. Note that it also says running version First Release.

After you have created a sample application to AWS Elastic Beanstalk, you need to configure your Git environment.
To configure your Git environment
Make sure you have version 2.3 of the AWS Elastic Beanstalk command line tools installed.
To check what version you have installed, use the following command.
eb --version
To download the command line tools, go to AWS Elastic Beanstalk Command Line Tool page and follow the instructions in the README.txt file in the ZIP file.
From your Git repository directory, type the following command.
git aws.config
When you are prompted for the AWS access key, type your access key. To get your access key information, go to Access Credentials.
AWS Access Key: AKIAIOSFODNN7EXAMPLE
Note
If you see an error instead of being prompted for configuration information, there may be an issue with your setup. Try installing AWS DevTools again. For instructions, see Getting Set Up.
When you are prompted for the AWS secret key, type your secret key. To get your secret key information, go to Access Credentials.
AWS Secret Key: wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
When you are prompted for the AWS Elastic Beanstalk region, type the region or press
Enter to accept the default region. For
information about this product's regions, go to Regions and Endpoints in the Amazon Web Services General
Reference.
AWS Region [default to us-east-1]:
When you are prompted for the AWS Elastic Beanstalk application name, type the name of the application. The application name should match the application name that you used when you created your sample application in Creating New Applications. In this example, we use HelloWorld.
AWS Elastic Beanstalk Application: HelloWorld
Note
If you have a space in your application name, make sure you do not use quotes.
When you are prompted for the AWS Elastic Beanstalk environment name, type the name of the environment. The environment name should match the environment name you used when you created your sample application in Creating New Applications. In this example, we use HelloWorldEnv.
AWS Elastic Beanstalk Environment: HelloWorldEnv
After configuring your Git environment, you are ready to update the sample application with your application.
If you want to update your Git environment, you can use the git
aws.config command. When prompted, you can update your configuration
options. If you want to keep any previous settings, press the Enter
key.
To remove the settings created by the repository setup, issue the following commands:
git config --remove-section alias.aws
git config --remove-section alias.aws.elasticbeanstalk
rm .git/AWSDevTools
Note
AWS DevTools is write-only. You cannot clone a Git repository using AWS DevTools.
To update the sample application with your local application
Type the following command.
git aws.push
If everything worked as expected, you should see something similar to the following:
Counting objects: 5, done.
Delta compression using up to 4 threads.
Compressing objects:100% (2/2), done.
Writing objects: 100% (3/3), 298 bytes, done.
Total 3 (delta 1), reused 0 (delta 0)
To https://<some long string>@git.elasticbeanstalk.us-east-1.amazon.com/helloworld/helloworldenv
44c7066..b1f11a1 master -> master Verify that your application has been updated. In the AWS Elastic Beanstalk Console, you should now see something similar to the following illustration. Note that the running version has been updated and begins with the commit ID from your last commit.

To investigate any issues, you can connect to your Amazon EC2 instance. For instructions on how to connect to your instance, see Listing and Connecting to Server Instances. You can also view logs to help you with debugging. For more information about viewing logs, see Debug/View Logs .
You can configure your environment so that the logs from the Amazon EC2 instances running your applications are copied by AWS Elastic Beanstalk to the Amazon S3 bucket associated with your application. For instructions on how to view these logs from the AWS Management Console, see Working with Logs.
Now that you have tested your application, it is easy to edit your application, redeploy, and see the results in moments. First, make changes to your application and commit your changes. Then deploy a new application version to your existing AWS Elastic Beanstalk environment.
git add . git commit -m "my third check-in" git aws.push
A new application version will be uploaded to your AWS Elastic Beanstalk environment.
You can use the AWS Management Console, CLIs, or APIs to manage your AWS Elastic Beanstalk environment. For more information, see Managing and Configuring Applications and Environments Using the Console, CLI, and APIs.
When you are satisfied with all of the changes you want to make to your application, you can deploy it to your production environment. First, you'll need to create a new production environment using the AWS Management Console, CLIs, or APIs. Then you can update your application in your production environment using AWS DevTools. When you update your application using AWS DevTools, AWS Elastic Beanstalk will create a new application version. For information on how to deploy an already existing application version to a new environment, see Launching New Environments. The following steps walk you through creating a new environment, and then updating your application in that environment with a new application version using AWS DevTools.
To deploy to production using AWS DevTools
To launch a new environment, follow the steps at Launching New Environments.
Check in final changes.
git add . git commit -m "final check-in"
Deploy your application to production.
git aws.push --environment my-production-env
You can also configure Git to push from a specific branch to a specific environment. For more information, see Deploying a Git Branch to a Specific Environment.
If you need to deploy an existing application to an existing environment, you can do so using the AWS Management Console, CLI, or APIs. You may want to do this if, for instance, you need to roll back to a previous application version. For instructions on how to deploy an existing application version to an existing environment, see Deploying Versions to Existing Environments.