Skip to main content
Welcome back. In this lesson you’ll make a small UI change, push it through your CI/CD pipeline, confirm a new Docker image has been produced and pushed to Amazon ECR, update the Amazon ECS service to use the new task definition, and finally trace the running container image back to the originating Git commit. We’ll cover:
  • Editing the application source in Cloud9
  • Committing and pushing the change to CodeCommit
  • Starting a build in CodeBuild that builds and pushes an image to ECR
  • Updating the ECS service to use the new task definition revision
  • Verifying the running application and tracing the image back to the commit hash
This walkthrough demonstrates why tagging Docker images with the Git commit hash (in addition to or instead of latest) is critical for traceability and safe rollbacks.

1) Edit the application in Cloud9

  • In the Cloud9 editor open templates/login.html.
  • Replace the existing heading (for example LOGIN) with the new heading LOGIN V2 and save the file.
Example change inside templates/login.html:

2) Commit and push the change from the Cloud9 terminal

From your Cloud9 environment, stage, commit, and push to the CodeCommit repository:
Example output when the push completes:

3) Start a new build in AWS CodeBuild

  • In the AWS Console go to CodeBuild → Build projects.
  • Select your project and click Start build.
  • Monitor the build logs. The buildspec should perform steps such as:
    • Checking aws --version
    • Building the Docker image
    • Tagging the image (including the Git commit hash)
    • Pushing the image to the ECR repository
When the build finishes you should see the newly pushed image in Amazon ECR (tagged with the commit hash). Confirm the new image in the ECR console:
The image shows the Amazon Elastic Container Registry interface with a list of images under the repository "cryptoproject," displaying details like image tags, artifact type, push dates, and size.

4) Update the Amazon ECS service to use the new task definition

  • In the AWS Console open ECS → Task Definitions and verify that CodeBuild (or your pipeline) registered a new task definition revision.
  • Navigate to Clusters → <your production cluster> → Services → <your service> → Update.
  • From the task definition drop-down, choose the new revision (for example, revision 3), proceed through the update flow and click Update.
  • ECS will perform a rolling deployment: old tasks will be replaced by tasks using the new task definition.

5) Monitor the deployment and inspect the running tasks

  • The service will show a deployment in progress. Wait until the deployment shows primary status 100% and all tasks are healthy.
  • Under the cluster Tasks tab you should see the recently launched task(s) and timestamps matching your deployment.
Here’s the running tasks view showing newly launched tasks:
The image shows the Amazon Elastic Container Service (ECS) console, displaying details of running tasks within a cluster named "ProductionCluster" for a service called "crypto-app." Tasks are listed with their status, launch type, and resource specifications.

Inspect the task and application

  • Select a task, open the container details to view the image URI and network bindings.
  • Use the network binding URL (public IP / load balancer target) to open the application and confirm the UI change (the login heading should now show LOGIN V2).
Open task details (container configuration, image, and bindings) to inspect further:
The image shows a screenshot of the AWS Management Console, specifically the Amazon Elastic Container Service (ECS) interface, displaying task details and configuration for a service running with Fargate.
Click the network binding URL to verify the running app shows LOGIN V2. View the runtime task overview and bindings (ports, ENI, subnet, etc.):
The image shows an Amazon Elastic Container Service (ECS) console displaying details about a running task in a production cluster, including task overview and network bindings for specific ports.

6) Trace the running image back to the Git commit

  • In the ECS task details note the container image URI. The image tag commonly contains the Git commit hash (for example 3257666).
  • In the AWS Console open ECR → <your repository> and find the image tag used by your running task.
  • Copy that commit hash and open CodeCommit → <your repository> → Commits.
  • Search or filter by the commit hash to find the exact commit that introduced the change.
Open the commit in CodeCommit to review the diff and confirm the change:
The image shows an AWS CodeCommit repository page listing recent commits for a project named "aws-microservice-project," with details such as commit IDs, messages, dates, authors, and actions.
Example snippet showing the relevant change:
This proves the traceability from running task → ECR image → CodeCommit commit. Tagging images with the commit hash makes it straightforward to debug, audit, and roll back deployments.
Tagging images with the commit hash improves traceability. When a deployment behaves unexpectedly, you can identify the exact commit that produced the image running in production and inspect that commit in your repository.

Quick reference — typical commands and locations

Summary

  • Edited templates/login.html in Cloud9 and pushed the change to AWS CodeCommit.
  • Started CodeBuild which built and pushed a Docker image to Amazon ECR (image tagged with the commit hash).
  • Updated the ECS service to a new task definition revision and validated the UI change (LOGIN V2).
  • Traced the running container image back to the specific CodeCommit commit for full traceability.
Links and references

Watch Video