Menu
AWS for DevOps
Getting Started Guide

Step 9.2: Change the Source Code for AWS Elastic Beanstalk

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 Elastic Beanstalk.

To change the source code for AWS CodeDeploy, go to Step 9.1: Change AWS CodeDeploy 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 Elastic Beanstalk

  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 styles.css command to open the styles.css file in the vi editor.

  4. Change line 36 of styles.css:

    Copy
    background-color: #fff

    to:

    Copy
    background-color: #0e0

    This will change the background color of the word Congratulations! on the index.php page from white to green.

    Note

    If you are unfamiliar with the vi editor, you can make this change by typing vi styles.css followed by two commands. To go to line 36, type :36, and then press Enter. To change #fff on line 36 to #0e0, type :s/#fff/#0e0, and then press Enter.

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

  6. Run the vi index.php command to open the index.php file in the vi editor.

  7. Change the following line of code:

    Copy
    <p>Your AWS Elastic Beanstalk <em>PHP</em> application is now running on your own dedicated environment in the AWS&nbsp;Cloud</p>

    to:

    Copy
    <p>Your redeployed AWS Elastic Beanstalk <em>PHP</em> application is now running on your own dedicated environment in the AWS&nbsp;Cloud</p>

    Note

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

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

  9. 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 files"
    Copy
    git push
  10. After the push is successful, open the AWS CodePipeline console at https://console.aws.amazon.com/codepipeline/.

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

  12. If the pipeline is not displayed, then on the All Pipelines page, choose the name of the pipeline you created in Step 7.2: Elastic Beanstalk Pipeline.

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