How to Update an EB Application for AWS

By John Paul Mueller

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.

  1. Download thephp-v1.zipfile.
  2. 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.

  3. Open theindex.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.

  4. Locate the line that reads <h1>Congratulations!</h1> and replace it with <h1>Hello There!</h1>.

    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.

  5. 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:

  1. Place the files for your application into an archive.
    The normal archive format is a .zip file.
  2. Open the application dashboard by clicking its entry in the initial EB page.
    You see options for working with the application.
    application dashboards AWS
    The application dashboard lets you perform application-related tasks.
  3. Click Upload and Deploy.
    You see an Upload and Deploy dialog box.
    Upload and Deploy
    Use the Upload and Deploy dialog box to upload new application versions.
  4. Click Browse.

    You see a File Upload window consistent with your platform and browser.

  5. Select the file containing the modified application code and click Open.
    EB displays the filename next to the Browse button.
  6. 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:

  1. 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.
  2. 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.
    available app versions AWS
    The example now has two available versions.
  3. 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.
  4. Click Deploy.
    EB displays messages telling you that it’s updating the environment. At some point, the application indictor turns green again.
    deployment options AWS
    You specify deployment options as part of making an update available.