Menu
AWS for DevOps
Getting Started Guide

Step 9.1: Change the Source Code for AWS CodeDeploy

In this step, you will change the source code in AWS CodeCommit. As soon as you push the code to the repository, AWS CodePipeline will deploy it to the deployment target in AWS CodeDeploy.

To change the source code for Elastic Beanstalk, go to Step 9.2: Change Elastic Beanstalk Source Code.

To change the source code for AWS OpsWorks, go to Step 9.3: Change AWS OpsWorks Source Code.

To change the source code for AWS CodeDeploy

  1. You should already be logged in to the instance you launched in Step 2.3: Launch an Amazon EC2 Instance to Access the AWS CodeCommit Repository. If not, follow the instructions in Connect to Your Linux Instance in the Amazon EC2 User Guide for Linux Instances.

  2. From the command prompt on the instance, run the pwd command to confirm you are in the /home/ec2-user/my-demo-repo directory. If a path other than /home/ec2-user/my-demo-repo appears in the output, run the cd ~/my-demo-repo command.

  3. From the ~/my-demo-repo directory, run the vi index.html command to open the index.html file in the vi editor.

  4. Change the following line of code:

    Copy
    background-color: #0188cc

    to:

    Copy
    background-color: #66cc00

    This will change the background color of the page from blue to green.

    Note

    If you are unfamiliar with the vi editor, you can make the change by typing :%s/#0188cc/#66cc00 and pressing Enter.

  5. Change the following line of code:

    Copy
    <h2>This application was deployed using AWS CodeDeploy</h2>

    to:

    Copy
    <h2>This application was redeployed using AWS CodeDeploy</h2>

    This will change the text that appears on the web page.

    Note

    If you are unfamiliar with the vi editor, you can make the change by typing :%s/deployed/redeployed and pressing Enter.

  6. To save your changes, type the :wq command, and then press Enter.

  7. Run the following Git commands, one at a time, to add, commit, and then push the changed code to the AWS CodeCommit repository.

    Copy
    git add .
    Copy
    git commit -m "Changed source code file"
    Copy
    git push
  8. After the push is successful, open the AWS CodePipeline console at https://console.aws.amazon.com/codepipeline/.

  9. In the AWS region selector, choose US East (N. Virginia).

  10. If the pipeline is not displayed, then on the All Pipelines page, choose the name of the pipeline you created in Step 7.1: AWS CodeDeploy Pipeline.

  11. When Succeeded is displayed for the Source and Deploy stages, go to Step 10.1: Verify AWS CodeDeploy Changes. (It may take several minutes for AWS CodePipeline to detect the push to the repository.)