Step 5: Update and redeploy your "hello, world!" application - Amazon CodeDeploy
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China (PDF).

Step 5: Update and redeploy your "hello, world!" application

Now that you've successfully deployed your application revision, on the development machine, make an update to the webpage's code, and then use CodeDeploy to redeploy the site. After redeployment, you should be able to see the changes on the Amazon EC2 instance.

Modify the webpage

  1. Go to your c:\temp\HelloWorldApp subfolder and use a text editor to modify the index.html file:

    cd c:\temp\HelloWorldApp notepad index.html
  2. Revise the contents of the index.html file to change the background color and some of the text on the webpage, and then save the file:

    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>Hello Again, World!</title> <style> body { color: #ffffff; background-color: #66cc00; font-family: Arial, sans-serif; font-size:14px; } </style> </head> <body> <div align="center"><h1>Hello Again, World!</h1></div> <div align="center"><h2>You have successfully deployed a revision of an application using CodeDeploy</h2></div> <div align="center"> <p>What to do next? Take a look through the <a href="http://www.amazonaws.cn/codedeploy">CodeDeploy Documentation</a>.</p> </div> </body> </html>

Redeploy the site

Now that you've modified the code, use Amazon S3 and CodeDeploy to redeploy the webpage.

Bundle and upload the changes to Amazon S3 as described in Bundle the application's files into a single archive file and push the archive file. (As you follow those instructions, you do not need to create a new application.) Give the revision the same key as before (HelloWorld_App.zip). Upload it to the same Amazon S3 bucket you created earlier (for example, codedeploydemobucket).

Use the Amazon CLI or the CodeDeploy console to redeploy the site.

To redeploy the site (CLI)

Call the create-deployment command to create a deployment based on the uploaded revision, again using the application named HelloWorld_App, the deployment configuration named CodeDeployDefault.OneAtATime, the deployment group named HelloWorld_DepGroup, and the revision named HelloWorld_App.zip in the bucket named codedeploydemobucket:

aws deploy create-deployment --application-name HelloWorld_App --deployment-config-name CodeDeployDefault.OneAtATime --deployment-group-name HelloWorld_DepGroup --s3-location bucket=codedeploydemobucket,bundleType=zip,key=HelloWorld_App.zip

You can check the status of the new deployment, as described in Monitor and troubleshoot your deployment.

When CodeDeploy has redeployed the site, revisit the site in your web browser to verify that the background color and text on the webpage have been changed. (You may need to refresh your browser.) If the background color and text has been changed, then congratulations! You've modified and redeployed your site!

To redeploy the site (console)

  1. Sign in to the Amazon Web Services Management Console and open the CodeDeploy console at https://console.amazonaws.cn/codedeploy.

    Note

    Sign in with the same user that you set up in Getting started with CodeDeploy.

  2. On the navigation pane, choose Applications.

  3. In the Applications list, choose HelloWorld_App.

  4. In the Deployments tab, choose Create deployment.

    1. In the Deployment group list, choose HelloWorld_DepGroup.

    2. In Revision location, enter the Amazon S3 link for your revision.

      To find the link value:

      1. Sign in to the Amazon Web Services Management Console and open the Amazon S3 console at https://console.amazonaws.cn/s3/.

        Browse to and open codedeploydemobucket, and then choose your revision, HelloWorld_App.zip, in the Amazon S3 console.

      2. If the Properties pane is not visible in the Amazon S3 console, choose the Properties button.

      3. In the Properties pane, copy the value of the Link field.

      4. Return to the CodeDeploy console, then paste the link into Revision location.

    3. In Revision file type, if a message appears stating that the file type could not be detected, choose .zip.

    4. Leave Deployment description blank.

    5. Expand Deployment group overridesIn the Deployment configuration list, choose CodeDeployDefault.OneAtATime, and then choose Create deployment.

      You can check the status of the deployment as described in Monitor and troubleshoot your deployment.

      When CodeDeploy has redeployed the site, revisit the site in your web browser to verify that the background color and text on the webpage have been changed. (You may need to refresh your browser.) If the background color and text has been changed, congratulations! You've modified and redeployed your site!