Setting the file. One moment. S3 Files · Ingesting Into Data Lake · aws/agent-toolkit-for-aws · Skills Docs
Import structured data files (CSV, TSV, JSON, Parquet, Avro, ORC) from S3 into tables.
54.11
Glue Job Scripts
70
Creating Amazon Aurora Db Cluster With Instances
93
Routing Traffic With Route53 And CloudFront
Resilience Program Design
Creating API Gateway Stage
- Detect load pattern: One-time (“load this file”) vs recurring (“set up a pipeline”, “keep updated”)
- Choose approach: Glue ETL (default, can be scheduled) vs Athena (fallback for simple loads)
- Require Glue 5.1 or higher for all Iceberg targets (S3 Tables and standard Iceberg).
- Discover available MCP tools: Search for S3 Tables MCP, Data Processing MCP, IAM MCP by keyword – do not hardcode tool names.
Use MCP tools when available. Fall back to AWS CLI only when MCP tool discovery finds no matching tools.
- Identify source: Ask user for S3 path and file format (CSV, JSON, Parquet, Avro, ORC)
- Sample files: List and download samples to understand structure
- Detect partitions: For Parquet/ORC, look for Hive-style partitioning (
year=2024/month=01/)
- Build schema: CSV (headers + sample values), JSON (type mapping), Parquet/Avro/ORC (embedded schema)
- Map types: Source types to target types (STRING to INT/DATE/TIMESTAMP based on content). See type-transformations.md.
- Handle conflicts: New columns (schema evolution via ALTER TABLE), type mismatches (cast/skip/fail), missing columns (ask user: use NULL or fail)
- Nested JSON/arrays (if detected): Ask the user which approach they prefer before proceeding:
- Flatten – Expand structs into separate columns, explode arrays into rows
- Preserve – Keep as STRUCT/ARRAY types
- Do not proceed until the user has chosen.
- Check if table exists using MCP or CLI
- Create table if needed: Delegate to creating-data-lake-table (opens in a new tab) for all target types. Pass the target format (S3 Tables, standard Iceberg, or raw files) and schema. See iceberg-catalog-config-and-usage.md for target-specific catalog configuration used in the subsequent Glue job.
- Evolve schema if needed: Compare schemas, generate ALTER TABLE ADD COLUMNS, execute via Athena
- Check for existing role: Look for
AWSGlueServiceRole-* or GlueServiceRole-*
- Verify permissions: AWSGlueServiceRole managed policy, S3 access, S3 Tables inline policy (if S3 Tables target)
- Create role if needed: Trust policy for
glue.amazonaws.com, attach policies, capture role ARN
When to use: Default for most loads. Required for recurring/scheduled imports, complex transformations, large datasets (millions+ rows).
Create external table, build INSERT INTO query with transformations, execute and monitor, clean up.
When to use: Simple one-time loads only. Small to medium datasets. SQL transformations sufficient.
- Row count validation
- Null checks on critical columns
- Type validation via sample check
- Spot-check data
Present summary: what was loaded, how to query, any issues, next steps.
Use Glue ETL when: recurring loads, complex transforms, large datasets, format-specific handling, data quality validation.
Use Athena when: simple one-time load, small/medium dataset, SQL transforms sufficient, Glue unavailable.
Use Glue Triggers (most cases): single job, simple schedule, no complex dependencies.
Use MWAA/Airflow (advanced): multiple sources with coordinated loading, complex dependencies, branching logic.
- S3 path only: Infer one-time load, proceed with discovery
- S3 path + table name: Check if table exists, infer schema, execute load
- “--recurring” or “--pipeline”: Force recurring pipeline via Glue
- No args: Walk through workflow interactively
- S3 Tables requires Glue 5.1 or higher. Standard Iceberg also requires Glue 5.1 or higher for proper Iceberg compatibility.
- S3 Tables CREATE TABLE must NOT include a LOCATION clause. Standard Iceberg MUST include one.
- When creating tables for S3 Tables import, use the Spark DDL path (Path B) in creating-data-lake-table to ensure the Glue catalog is configured.
- Target-specific catalog configuration and Glue version requirements are defined in iceberg-catalog-config-and-usage.md.
references/s3-files.md