Hands-On Lab918 words

Hands-On Lab: AWS AI/ML and Storage Services Integration

AWS artificial intelligence and machine learning (AI/ML) services and analytics services

Hands-On Lab: AWS AI/ML and Storage Services Integration

Welcome to this guided hands-on lab! Artificial intelligence (AI) and machine learning (ML) are among the most exciting areas in cloud computing today. AWS provides a suite of managed AI services that allow you to add powerful capabilities—like natural language processing (NLP) and computer vision—to your applications without requiring deep ML expertise.

In this 30-minute lab, we will combine Amazon S3 (for storage) with Amazon Comprehend (for text analytics) and Amazon Rekognition (for image analysis) to demonstrate how these services interact.


Prerequisites

Before starting this lab, ensure you have the following ready:

  • AWS Account: Active AWS account with Administrator or PowerUser access.
  • CLI Tools: AWS CLI installed and configured (aws configure) with valid access keys.
  • Prior Knowledge: Basic familiarity with the terminal/command prompt and understanding of cloud storage concepts.
  • Local Files: You will need a sample image (e.g., a .jpg of a landscape, animal, or city) saved on your local machine.

[!WARNING] Never hardcode or share your AWS credentials. Always use environment variables or secure AWS CLI profiles.


Learning Objectives

By completing this lab, you will be able to:

  1. Provision an Amazon S3 bucket to store raw unstructured data for machine learning.
  2. Use Amazon Rekognition to identify objects, people, or scenes in an image.
  3. Extract sentiment and key entities from unstructured text using Amazon Comprehend.
  4. Clean up and tear down AWS resources to avoid unexpected charges.

Architecture Overview

The following diagram illustrates the workflow of the services we are building:

Loading Diagram...

Step-by-Step Instructions

Step 1: Create an S3 Bucket for ML Data

Amazon S3 (Simple Storage Service) is the foundational object storage layer for most data analytics and ML workflows on AWS. We need a place to store our image before analyzing it.

bash
aws s3 mb s3://brainybee-ai-lab-<YOUR_ACCOUNT_ID>

[!TIP] S3 bucket names must be globally unique. Replace <YOUR_ACCOUNT_ID> with your actual 12-digit AWS account number or a unique random string.

Console alternative
  1. Log into the AWS Management Console.
  2. Navigate to S3 and click Create bucket.
  3. Enter brainybee-ai-lab-<YOUR_ACCOUNT_ID> as the Bucket name.
  4. Leave all other settings as default and click Create bucket.

📸 Screenshot: [Placeholder: S3 Bucket Creation screen]

Step 2: Upload a Sample Image

Find a sample image on your computer (e.g., sample-image.jpg). We will upload this image to our newly created S3 bucket.

bash
aws s3 cp sample-image.jpg s3://brainybee-ai-lab-<YOUR_ACCOUNT_ID>/
Console alternative
  1. In the S3 Console, click on your new bucket.
  2. Click the Upload button.
  3. Click Add files, select sample-image.jpg from your computer.
  4. Click Upload at the bottom of the screen.

Step 3: Analyze Image with Amazon Rekognition

Amazon Rekognition makes it easy to add image and video analysis to your applications. We will ask Rekognition to detect labels (objects, scenes, concepts) in the image we just uploaded.

bash
aws rekognition detect-labels \ --image '{"S3Object":{"Bucket":"brainybee-ai-lab-<YOUR_ACCOUNT_ID>","Name":"sample-image.jpg"}}' \ --max-labels 5 \ --region us-east-1

Explanation: This command tells Rekognition to look at sample-image.jpg inside your S3 bucket and return the top 5 labels describing what it sees along with a confidence score.

Console alternative
  1. Navigate to Amazon Rekognition in the AWS Console.
  2. In the left sidebar, click Label detection.
  3. Under the demo section, upload your sample-image.jpg.
  4. View the resulting tags and confidence scores on the right-hand panel.

Step 4: Analyze Text Sentiment with Amazon Comprehend

Amazon Comprehend uses natural-language processing (NLP) to find insights and relationships in text. Let's analyze a sample review to determine its sentiment (Positive, Negative, Neutral, or Mixed).

bash
aws comprehend detect-sentiment \ --text "AWS machine learning services like SageMaker and Comprehend are incredibly powerful and easy to use!" \ --language-code en \ --region us-east-1

Explanation: Unlike Rekognition which read from S3, here we are passing the text string directly into the synchronous Comprehend API. You should receive a JSON response indicating a high POSITIVE sentiment score.

Step 5: Extract Entities with Amazon Comprehend

Comprehend can also pull out key entities like Organizations, Locations, Persons, and Dates.

bash
aws comprehend detect-entities \ --text "Jeff Bezos founded Amazon in Bellevue, Washington in 1994." \ --language-code en \ --region us-east-1
Console alternative (Steps 4 & 5)
  1. Navigate to Amazon Comprehend in the AWS Console.
  2. Click Launch Amazon Comprehend.
  3. Scroll down to the Real-time analysis section.
  4. Paste your text into the Input text box.
  5. Click Analyze and explore the Entities and Sentiment tabs below to see the visual output.

Checkpoints

Verify your progress after the steps above to ensure everything is functioning correctly:

  1. Storage Verification: Run aws s3 ls s3://brainybee-ai-lab-<YOUR_ACCOUNT_ID>/.
    • Expected Output: You should see sample-image.jpg listed with its timestamp and file size.
  2. Rekognition Verification: Review the JSON output from Step 3.
    • Expected Output: A list of Labels containing a Name (e.g., "Nature", "Dog") and a Confidence score close to 99.0.
  3. Comprehend Verification: Review the JSON output from Step 4.
    • Expected Output: "Sentiment": "POSITIVE" should be the top-level key.

Troubleshooting

Error Message / IssueLikely CauseSolution
InvalidToken or AccessDeniedYour AWS CLI credentials are not configured or have expired.Run aws configure and provide valid access keys. Ensure your IAM user has S3 and AI service permissions.
BucketAlreadyExistsAnother AWS user globally has taken the S3 bucket name.Change your bucket name to include more random characters.
InvalidS3ObjectExceptionRekognition cannot find the image.Check that the --image JSON string in Step 3 exactly matches your bucket name and file name.
UnrecognizedClientExceptionThe region specified doesn't support the requested AI service.Append --region us-east-1 to your commands, as US-East-1 supports all AI services.

Cost Estimate

This lab is designed to be highly cost-effective and falls comfortably within the AWS Free Tier if you are eligible:

  • Amazon S3: Standard storage for one image is a fraction of a cent.
  • Amazon Rekognition: Free tier includes 1,000 image analyses per month.
  • Amazon Comprehend: Free tier includes 50,000 units of text (100 characters = 1 unit) per month.
  • Total Estimated Cost: $0.00

Clean-Up / Teardown

[!WARNING] Remember to run the teardown commands to avoid ongoing charges. Even though storage costs are negligible, it is best practice to clean up lab environments.

To destroy the resources created in this lab, execute the following commands in your CLI:

  1. Delete the image file from S3:

    bash
    aws s3 rm s3://brainybee-ai-lab-<YOUR_ACCOUNT_ID>/sample-image.jpg
  2. Delete the empty S3 bucket:

    bash
    aws s3 rb s3://brainybee-ai-lab-<YOUR_ACCOUNT_ID>
  3. (Optional) Verify the bucket is gone:

    bash
    aws s3 ls | grep brainybee-ai-lab

    If nothing is returned, the teardown was successful.


Concept Review: AWS AI/ML Ecosystem

To solidify what we just practiced, let's look at how the AWS AI/ML services fit together based on the CLF-C02 syllabus.

Loading Diagram...

Quick Comparison Table

AWS ServiceCore CapabilityReal-World Example
Amazon ComprehendNatural Language Processing (NLP)Automatically categorizing support tickets as "Angry" or "Happy".
Amazon RekognitionComputer VisionVerifying user identities by comparing an ID photo to a selfie.
Amazon LexConversational InterfacesBuilding a chatbot for a hotel website to handle booking requests.
Amazon SageMakerBuild, Train, Deploy ML ModelsData scientists writing custom Python code to predict stock market trends.
Amazon KendraEnterprise ML SearchCreating an internal search engine that reads company PDFs to answer employee HR questions.

Ready to study AWS Certified Cloud Practitioner (CLF-C02)?

Practice tests, flashcards, and all study notes — free, no sign-up needed.

Start Studying — Free