AWS CodeDeploy
User Guide (API Version 2014-10-06)

The procedures in this guide support the new console design. If you choose to use the older version of the console, you will find many of the concepts and basic procedures in this guide still apply. To access help in the new console, choose the information icon.

Step 5: Update and Redeploy Your WordPress Application

Now that you've successfully deployed your application revision, update the WordPress code on the development machine, and then use AWS CodeDeploy to redeploy the site. Afterward, you should see the code changes on the Amazon EC2 instance.

Set Up the WordPress Site

To see the effects of the code change, finish setting up the WordPress site so that you have a fully functional installation.

  1. Type your site's URL into your web browser. The URL is the public DNS address of the Amazon EC2 instance plus a /WordPress extension. For this example WordPress site (and example Amazon EC2 instance public DNS address), the URL is http://ec2-01-234-567-890.compute-1.amazonaws.com/WordPress.

  2. If you haven't set up the site yet, the WordPress default welcome page appears. Choose Let's go!.

  3. To use the default MySQL database, on the database configuration page, type the following values:

    • Database Name: test

    • User Name: root

    • Password: Leave blank.

    • Database Host: localhost

    • Table Prefix: wp_

    Choose Submit to set up the database.

  4. Continue the site setup. On the Welcome page, fill in any values you want, and choose Install WordPress. When the installation is complete, you can sign in to your dashboard.

Important

During the deployment of the WordPress application, the change_permissions.sh script updated permissions of the /tmp/WordPress folder so anyone can write to it. Now is a good time to run the following command to restrict permissions so that only you, the owner, can write to it:

chmod -R 755 /var/www/html/WordPress

Modify the Site

To modify the WordPress site, go to the application's folder on your development machine:

cd /tmp/WordPress

To modify some of the site's colors, in the wp-content/themes/twentyfifteen/style.css file, use a text editor or sed to change #fff to #768331.

On Linux or other systems with GNU sed, use:

sed -i 's/#fff/#768331/g' wp-content/themes/twentyfifteen/style.css

On macOS, Unix, or other systems with BSD sed, use:

sed -i '' 's/#fff/#768331/g' wp-content/themes/twentyfifteen/style.css

Redeploy the Site

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

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, remember that you do not need to create an application.) Give the new revision the same key as before (WordPressApp.zip). Upload it to the same Amazon S3 bucket you created earlier (for example, codedeploydemobucket).

Use the AWS CLI, the AWS CodeDeploy console, or the AWS CodeDeploy APIs to redeploy the site.

To redeploy the site (CLI)

Call the create-deployment command to create a deployment based on the newly uploaded revision. Use the application named WordPress_App, the deployment configuration named CodeDeployDefault.OneAtATime, the deployment group named WordPress_DepGroup, and the revision named WordPressApp.zip in the bucket named codedeploydemobucket:

aws deploy create-deployment \ --application-name WordPress_App \ --deployment-config-name CodeDeployDefault.OneAtATime \ --deployment-group-name WordPress_DepGroup \ --s3-location bucket=codedeploydemobucket,bundleType=zip,key=WordPressApp.zip

You can check the status of the deployment, as described in Monitor and Troubleshoot Your Deployment.

After AWS CodeDeploy has redeployed the site, revisit the site in your web browser to verify the colors have been changed. (You might need to refresh your browser.) If the colors have been changed, congratulations! You have successfully modified and redeployed your site!

To redeploy the site (console)

  1. Sign in to the AWS Management Console and open the AWS CodeDeploy console at https://console.aws.amazon.com/codedeploy.

    Note

    Sign in with the same account or IAM user information that you used in Getting Started with AWS CodeDeploy.

  2. In the navigation pane, expand Deploy, and then choose Applications.

  3. In the list of applications, choose WordPress_App.

  4. On the Deployment groups tab, choose WordPress_DepGroup.

  5. Choose Create deployment.

  6. On the Create deployment page:

    1. In Deployment group, choose WordPress_DepGroup.

    2. In the Repository type area, choose My application is stored in Amazon S3, and then copy your revision's Amazon S3 link into the Revision location box. To find the link value:

      1. In a separate browser tab:

        Sign in to the AWS Management Console and open the Amazon S3 console at https://console.aws.amazon.com/s3/.

        Browse to and open codedeploydemobucket, and then choose your revision, WordPressApp.zip.

      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 into the Revision location box in the AWS CodeDeploy console.

    3. If a message appears saying the file type could not be detected, choose .zip.

    4. Leave the Deployment description box blank.

    5. Expand Deployment group overrides and from Deployment configuration, choose CodeDeployDefault.OneAtATime.

    6. Choose Start deployment. Information about your newly created deployment appears on the Deployments page.

    7. You can check the status of the deployment, as described in Monitor and Troubleshoot Your Deployment.

      After AWS CodeDeploy has redeployed the site, revisit the site in your web browser to verify the colors have been changed. (You might need to refresh your browser.) If the colors have been changed, congratulations! You have successfully modified and redeployed your site!