How to Update an EB Application for AWS
You’ll need to make sure your AWS applications are updated regularly. Applications don’t exist in a vacuum: organizational and other requirements change, environments evolve, user needs change, and so on. As the application functionality and operation changes, so must the application configuration and setup. The environmental needs change as well. In other words, you must perform an EB update to keep the application current so that users can continue using it. The following information describes the kinds of changes you need to consider during an update.
Getting the sample code and making a change
You’re extremely unlikely to upload just one version of your application. An application actually has a life cycle, and change is simply part of the process. Making changes using the sample application means getting the current code and then doing something with it. The following steps help you get a copy of the current application and perform a small change on it.
- Download the
- Expand the archive into its own folder (directory) on your hard drive.
You see a number of application files, including
index.php. Modifying the code changes how the web page appears.
- Open the
index.phpfile using any text editor.
The text editor must output pure text files without any formatting. For example, Notepad on Windows systems, gedit on Linux systems, and TextEdit on Mac systems are all examples of pure text editors. On the other hand, Microsoft Word, LibreOffice, and FreeOffice are all examples of editors that you can’t use to make modifications to PHP files.
- Locate the line that reads
<h1>Congratulations!</h1>and replace it with
The change you’ve just made modifies the greeting you see. It’s a small change, but it serves to demonstrate how modifications typically work.
- Save the file. The modified file is now ready to upload to Amazon.
Uploading the modified application
To see any coding changes you make, you must upload the changes to AWS. It doesn’t matter how complex the application becomes: At some point, you use the same process to upload changed files. The following steps describe how to perform this task:
- Place the files for your application into an archive.
The normal archive format is a
- Open the application dashboard by clicking its entry in the initial EB page.
You see options for working with the application.
- Click Upload and Deploy.
You see an Upload and Deploy dialog box.
- Click Browse.
You see a File Upload window consistent with your platform and browser.
- Select the file containing the modified application code and click Open. EB displays the filename next to the Browse button.
- Type Changed-Greeting in the Version Label field and then click Deploy.
EB displays messages telling you that it’s updating the environment. Be patient; this process can take a few minutes to complete. At some point, the application indictor turns green again (and you see the check mark icon).
Switching application versions
You now have two application versions uploaded to the EC2 instance. In some cases, you may have to switch between application versions. Perhaps a fix in a new version really didn’t work out, so you need to go to an older, more stable, version. The following steps describe how to switch between versions:
- Click Upload and Deploy. Look again at the image above. Notice the Application Versions Page link. This page contains a listing of all the versions available for use.
- Click the Application Versions Page link.
You see the Application Versions page. The last field of the table shows where each version is deployed. In this case, Changed-Greeting is deployed, but Sample Application isn’t.
- Check the Sample Application version and click Deploy. EB displays the deployment options. The fields contain the same environment settings as before. You don’t want to change these settings unless you want to create a new environment.
- Click Deploy.
EB displays messages telling you that it’s updating the environment. At some point, the application indictor turns green again.