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
.jpgof 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:
- Provision an Amazon S3 bucket to store raw unstructured data for machine learning.
- Use Amazon Rekognition to identify objects, people, or scenes in an image.
- Extract sentiment and key entities from unstructured text using Amazon Comprehend.
- 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:
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.
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
- Log into the AWS Management Console.
- Navigate to S3 and click Create bucket.
- Enter
brainybee-ai-lab-<YOUR_ACCOUNT_ID>as the Bucket name. - 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.
aws s3 cp sample-image.jpg s3://brainybee-ai-lab-<YOUR_ACCOUNT_ID>/▶Console alternative
- In the S3 Console, click on your new bucket.
- Click the Upload button.
- Click Add files, select
sample-image.jpgfrom your computer. - 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.
aws rekognition detect-labels \
--image '{"S3Object":{"Bucket":"brainybee-ai-lab-<YOUR_ACCOUNT_ID>","Name":"sample-image.jpg"}}' \
--max-labels 5 \
--region us-east-1Explanation: 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
- Navigate to Amazon Rekognition in the AWS Console.
- In the left sidebar, click Label detection.
- Under the demo section, upload your
sample-image.jpg. - 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).
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-1Explanation: 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.
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)
- Navigate to Amazon Comprehend in the AWS Console.
- Click Launch Amazon Comprehend.
- Scroll down to the Real-time analysis section.
- Paste your text into the Input text box.
- 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:
- Storage Verification: Run
aws s3 ls s3://brainybee-ai-lab-<YOUR_ACCOUNT_ID>/.- Expected Output: You should see
sample-image.jpglisted with its timestamp and file size.
- Expected Output: You should see
- Rekognition Verification: Review the JSON output from Step 3.
- Expected Output: A list of
Labelscontaining aName(e.g., "Nature", "Dog") and aConfidencescore close to 99.0.
- Expected Output: A list of
- Comprehend Verification: Review the JSON output from Step 4.
- Expected Output:
"Sentiment": "POSITIVE"should be the top-level key.
- Expected Output:
Troubleshooting
| Error Message / Issue | Likely Cause | Solution |
|---|---|---|
InvalidToken or AccessDenied | Your 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. |
BucketAlreadyExists | Another AWS user globally has taken the S3 bucket name. | Change your bucket name to include more random characters. |
InvalidS3ObjectException | Rekognition cannot find the image. | Check that the --image JSON string in Step 3 exactly matches your bucket name and file name. |
UnrecognizedClientException | The 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:
-
Delete the image file from S3:
bashaws s3 rm s3://brainybee-ai-lab-<YOUR_ACCOUNT_ID>/sample-image.jpg -
Delete the empty S3 bucket:
bashaws s3 rb s3://brainybee-ai-lab-<YOUR_ACCOUNT_ID> -
(Optional) Verify the bucket is gone:
bashaws s3 ls | grep brainybee-ai-labIf 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.
Quick Comparison Table
| AWS Service | Core Capability | Real-World Example |
|---|---|---|
| Amazon Comprehend | Natural Language Processing (NLP) | Automatically categorizing support tickets as "Angry" or "Happy". |
| Amazon Rekognition | Computer Vision | Verifying user identities by comparing an ID photo to a selfie. |
| Amazon Lex | Conversational Interfaces | Building a chatbot for a hotel website to handle booking requests. |
| Amazon SageMaker | Build, Train, Deploy ML Models | Data scientists writing custom Python code to predict stock market trends. |
| Amazon Kendra | Enterprise ML Search | Creating an internal search engine that reads company PDFs to answer employee HR questions. |