HW3 Guide

Updated 5 Oct 2026

DES431 — HW3: Querying Data by Using Athena

Complete Step-by-Step Guide (AWS Academy Data Engineering, Module 4)

Note on scope: This guide covers everything documented in the lecture slides — accessing the lab, the 7-task overview, the fully detailed Task 5 credential setup, and how to submit/end the lab. The click-by-click instructions inside Tasks 1–4, 6, and 7 live in the AWS Academy lab guide itself (the page that opens after you click Start Lab), since the slide deck only summarizes those tasks at a high level. Follow those on-screen instructions when you reach them — this guide tells you exactly where to find them and what each task is trying to accomplish.


Part 1 — What You're Building

Amazon Athena is a serverless, interactive SQL query service that lets you query data sitting directly in Amazon S3 — no database servers to manage.

How the pieces fit together:

Amazon S3  →  AWS Glue Crawler  →  AWS Glue Data Catalog  →  Amazon Athena  →  Amazon QuickSight
 (raw data)   (scans data, infers    (stores table/schema      (SQL queries      (visualization,
              schema)                 metadata)                 on S3 data)       optional)
  • S3: stores your raw files (this lab uses a taxi trip dataset in CSV).
  • Glue Crawler: scans S3 data and automatically creates table definitions.
  • Glue Data Catalog: the "schema registry" — holds database/table metadata.
  • Athena: lets you run SQL directly against that cataloged data.

Why it's useful (from the slides):

  • Pay only for the data your query actually scans.
  • No infrastructure to provision — start querying instantly.
  • Standard, open SQL syntax.
  • Fast, even on large datasets.
  • Supports multiple file formats: CSV, JSON, Parquet, Avro, ORC.

The scenario: A data scientist named Mary needs to run advanced SQL queries across multiple CSV files stored in the same S3 bucket, aggregate them into one queryable database, and clean up the schema (column names/types). You'll set this up for her using Athena + Glue.


Part 2 — Accessing the Lab

Step 1: Go to AWS Academy

  1. Log in to AWS Academy.
  2. Select the course: AWS Academy Data Engineering [131274].

Step 2: Navigate to the Right Module

  1. Click Modules in the left sidebar.
  2. Open Module 4: Design Principles and Patterns for Data Pipelines.
  3. Inside the module list, click Lab: Querying Data by Using Athena.

Step 3: Read the Lab Overview

The lab page will show:

"Sofía is happy with the proof of concept (POC) that you created for Amazon S3 and the team is learning how to use it. However, one of the data scientists, Mary, would like to perform more advanced queries on comma-separated values (CSV) data..."

This is your scenario framing — Athena is the tool you'll use to solve Mary's problem. Skim it once before starting.


Part 3 — Starting the Lab

Step 4: Start the Lab Session

  1. At the top of the lab instructions, click ▶ Start Lab.
  2. Wait for the environment to provision (you'll see a countdown timer, e.g. 02:11, indicating remaining session time).
  3. Once the green AWS indicator/button appears (top-left area, next to the timer), click it — this opens the AWS Management Console in a new tab.

Step 5: Confirm You're Logged in as the Right User

  1. In the AWS Console, top-right corner, check the account/user name.
  2. It must show something starting with voclabs/... (e.g. voclabs/user2729014=Test_Student).
  3. If you see a different/existing AWS login: sign out of that account first, then reopen the AWS button from the lab page.

⚠️ Logging in with the wrong account is the most common setup mistake — double-check this before doing anything else.

Step 6: Locate Your Cloud Access Credentials (for later use)

Back on the lab instructions page:

  1. Click i AWS Details (top bar, next to Start Lab / End Lab).
  2. This expands a Cloud Access panel showing:
    • AWS CLI credentials (click Show to reveal)
    • Cloud Labs session timing info
    • SSH key / AWS SSO details
    • Any lab-specific values like BucketName, MarysAccessKey, etc.
  3. You won't need the AWS CLI credentials until Task 5 — but note this panel's location now, since you'll come back to it.

Part 4 — The 7 Tasks (Overview)

According to the slides, this lab has these objectives. Work through them in order, following the detailed instructions that appear inside the AWS Academy lab guide itself for each one:

#TaskWhat You're Doing
1Create an AWS Glue database from the taxi datasetUse the Athena query editor to create a Glue database and table; define the schema using Athena's bulk add columns feature
2Analyze January taxi data using bucketsThe full dataset has all months combined — January has been split into a separate file to optimize your Athena queries
3Partition taxi data by paytypeUse partitioning in Athena to organize/optimize queries by payment type
4Create Athena viewsBuild a view that calculates total fare value paid by credit card vs. cash, to simplify analysis for other users
5Create Athena named queries via CloudFormationUse the Cloud9 IDE + CLI + a CloudFormation template to create reusable named queries; review the Policy-For-Data-Scientists IAM policy
6Review IAM policy for Athena/Glue accessExamine what permissions Policy-For-Data-Scientists grants for using Athena and Glue
7Confirm Mary can use the named queryVerify, using the AWS CLI in Cloud9, that a user (Mary) can successfully access and run the named query

By the end, you should be able to:

  • Use the Athena query editor to create a Glue database and table.
  • Define a schema via Athena's bulk add columns feature.
  • Configure Athena against an S3 dataset.
  • Optimize Athena queries against a sample dataset.
  • Create views in Athena.
  • Create Athena named queries using CloudFormation.
  • Review an IAM policy for Athena named-query users.
  • Confirm CLI access to a named query in Cloud9.

Part 5 — Task 5 in Full Detail: Creating Named Queries via CloudFormation

This is the task with fully documented steps in the slides.

Step 7: Understand What This Task Requires

  • You'll use the Cloud9 IDE to create a file and run terminal commands.
  • Before running any AWS CLI command, you must load temporary session credentials into the terminal — otherwise every aws ... command will fail with an auth error.

Step 8: Open AWS Details and Expand AWS CLI

  1. On the lab instructions page, click i AWS Details.
  2. Find the AWS CLI row and click Show.
  3. You'll see a credential block like:
[default]
aws_access_key_id=ASIAxxxxxxxxxxxxxxxx
aws_secret_access_key=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
aws_session_token=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...(very long)
  1. Select and copy the entire block, including the [default] header line.

⚠️ These are temporary session credentials. They expire when your lab session times out. If a command later fails with an expired/invalid token error, come back to this step, copy a fresh block, and repeat Steps 9–11.

Step 9: Open the Terminal in Cloud9

  1. Switch to your Cloud9 IDE tab (you may need to open it from the AWS Console — search "Cloud9" — if it's not already open).
  2. At the bottom of the IDE, find the tab bar: PROBLEMS | OUTPUT | DEBUG CONSOLE | TERMINAL | PORTS.
  3. Click TERMINAL.

Step 10: Open the Credentials File with nano

In the terminal prompt (it will look like [ec2-user@ip-10-0-1-205 environment]$), type exactly:

nano /home/ec2-user/.aws/credentials

Press Enter.

  • This launches the nano text editor inside the terminal, showing the contents of the credentials file (it may already contain a default/expired [default] block).

Step 11: Paste Your Credentials

  1. Click inside the terminal so it has focus.

  2. Paste (Ctrl+V / Cmd+V) the block you copied in Step 8.

  3. If old content is present, make sure your final file has one clean [default] section with all three lines:

    [default]aws_access_key_id=...aws_secret_access_key=...aws_session_token=...

💡 Never retype the session token by hand — it's very long and easy to mistype. Always copy-paste.

Step 12: Save and Exit nano

nano's shortcuts appear at the bottom of the terminal window (^ = Ctrl):

  1. Press Ctrl + X to begin exiting.
  2. nano asks: Save modified buffer? → press Y (Yes).
  3. It confirms the filename to save to → press Enter to confirm and write.

You'll land back at the normal $ terminal prompt.

Step 13: Verify the Credentials Work

Run:

aws sts get-caller-identity

Expected success output (your values will differ):

{
    "UserId": "AROAR5RZ6L3AR3UR2P6PZ:user5411524=Test_Student",
    "Account": "132191772353",
    "Arn": "arn:aws:sts::132191772353:assumed-role/voclabs/user5411524=Test_Student"
}
  • ✅ Success: JSON output showing your name (e.g. Test_Student) in the Arn field.
  • ❌ Failure: errors like Unable to locate credentials or token has expired → re-check Steps 10–12, or grab fresh credentials from Step 8 if your session has timed out.

Step 14: Continue with the Rest of Task 5

Once credentials are verified, continue following the AWS Academy lab guide's on-screen instructions to:

  • Create the file needed for the CloudFormation stack.
  • Run the AWS CLI command to launch the CloudFormation stack that creates the Athena named query.
  • Review the Policy-For-Data-Scientists IAM policy referenced in the task.

Part 6 — Submitting Your Work

Step 15: Submit Progress

  1. At the top of the lab instructions, click Submit.
  2. When prompted, choose Yes to confirm.
  3. This records your task-by-task progress and score.

Step 16: Capture Proof for Your Assignment Sheet

  1. Click your profile/account icon (top-left in the AWS Academy learner interface) to reveal your name.
  2. Make sure both your name and the score panel (e.g. Total score 45/45 with each task's individual score) are visible on screen.
  3. Take a screenshot showing both, and paste it into your assignment submission sheet.

Example of what the score panel looks like:

Total score                          45/45

[Task 1a] Database created            5/5
[Task 1b] Database table created      5/5
[Task 1c] Database table previewed    5/5
[Task 2]  Database table jan exists   5/5
[Task 4]  Student queried using views 5/5
[Task 5a] Student tested the query    5/5
[Task 5b] CloudFormation stack created 5/5
[Task 5c] CreateNamedQuery event recorded 5/5
[Task 7]  GetNamedQuery event recorded 5/5

Each of these line items corresponds to a checkpoint the lab auto-grades as you complete tasks — if any show 0/5, go back and re-check that task before submitting your final screenshot.


Part 7 — Ending the Lab

Step 17: End the Lab Session

  1. At the top of the lab page, click ■ End Lab.
  2. Select Yes to confirm you want to end the session.
  3. This releases your AWS lab environment (credentials from Task 5 will no longer work after this point).

Quick Reference: Full Workflow at a Glance

StageKey Action
AccessAWS Academy → Data Engineering [131274] → Module 4 → Lab: Querying Data by Using Athena
StartClick Start Lab → click AWS button → confirm voclabs/... login
Tasks 1–4Follow on-screen lab guide: create Glue DB/table, analyze Jan data, partition by paytype, create views
Task 5i AWS Details → Show AWS CLI creds → Cloud9 terminal → nano /home/ec2-user/.aws/credentials → paste → Ctrl+X, Y, Enter → verify with aws sts get-caller-identity → continue CloudFormation steps
Tasks 6–7Review Policy-For-Data-Scientists IAM policy; confirm named-query access via CLI
SubmitClick Submit → Yes → screenshot name + score panel → paste into assignment sheet
FinishClick End Lab → Yes

Guide compiled from DES431 HW3 lecture slides (Dr. Apichon Witayangkurn, apichon@siit.tu.ac.th).