<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Tsebek Badmaev on Medium]]></title>
        <description><![CDATA[Stories by Tsebek Badmaev on Medium]]></description>
        <link>https://medium.com/@badmaev.t?source=rss-2942ff4c5b20------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*_LYuIZOJAze8UYQo6e6NJQ.jpeg</url>
            <title>Stories by Tsebek Badmaev on Medium</title>
            <link>https://medium.com/@badmaev.t?source=rss-2942ff4c5b20------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 24 Nov 2026 00:45:17 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@badmaev.t/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Designing a Complete ETL Pipeline Workflow with AWS]]></title>
            <link>https://medium.com/rock-your-data/designing-a-complete-etl-pipeline-workflow-with-aws-eca258c3a724?source=rss-2942ff4c5b20------2</link>
            <guid isPermaLink="false">https://medium.com/p/eca258c3a724</guid>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[api]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[etl]]></category>
            <dc:creator><![CDATA[Tsebek Badmaev]]></dc:creator>
            <pubDate>Mon, 13 Jan 2025 19:00:54 GMT</pubDate>
            <atom:updated>2025-01-13T19:00:54.981Z</atom:updated>
            <content:encoded><![CDATA[<p>Today, I’ll walk you through a practical guide to building a fully automated ETL pipeline that processes raw API data, transforms it, and makes it available for BI tools. This pipeline leverages core AWS services, including Lambda for data extraction and transformation, S3 for data storage, Glue with Crawlers for creating a data catalog, and Athena alongside Glue jobs for advanced transformations.</p><p>This project builds on <a href="https://medium.com/u/94acdd63cb53">Maksim Kazartsev</a> project, “<a href="https://medium.com/@kazarmax/from-api-to-dashboard-building-an-end-to-end-etl-pipeline-with-aws-3c1f4048676d">From API to Dashboard: Building an End-to-End ETL Pipeline with AWS</a>”. The first three steps of this pipeline are identical to Maksim’s project, so their descriptions here are concise. For a detailed walkthrough, please refer to Maksim’s original project. Starting from Step 4, the process differs, so it’s highly recommended to complete Maksim’s project before proceeding with this guide.</p><h3>Project Architecture and Execution Flow</h3><p>The following diagram represents the solution architecture implemented in this project.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0NP-_hfql39wLDLGiSmQpw.png" /></figure><p><strong>Project flow</strong>:</p><ol><li>EventBridge daily schedule</li><li>Run data extraction code</li><li>Store raw data</li><li>Transform raw data</li><li>Store transformed data</li></ol><h3>Used Services</h3><p>In this project, we will be using the following services:</p><ul><li><strong>Adzuna API — </strong>provides access to job market data, allowing users to query job listings and other employment-related information in real-time. In this project, it serves as the public data source for the ETL pipeline.</li><li><strong>AWS Cloud </strong>(Amazon Web Services) is a comprehensive cloud computing platform offering a wide range of computing power, storage, networking, and databases services. AWS provides the backbone for all services in this project, enabling the deployment and management of cloud-based resources.</li><li><strong>AWS IAM (Identity and Access Management)</strong> allows you to manage access to AWS resources securely. It controls who has access to which services. In this project, it defines the roles and permissions for Lambda functions, S3, and other services.</li><li><strong>AWS CloudWatch </strong>is a monitoring service for AWS cloud resources and applications. It helps track performance metrics and monitor logs. In this project, it’s used to monitor the Lambda function execution logs.</li><li><strong>EventBridge</strong> allows the scheduling and automation of AWS services. In this project, it’s used to trigger the Lambda function that extracts raw data from API on a daily schedule.</li><li><strong>AWS Lambda</strong> is a serverless compute service that runs your code in response to events. In this project, it automates the data extraction by running custom Python code to handle Adzuna API data and move it through the pipeline.</li><li><strong>Amazon S3 (Simple Storage Service)</strong> is a scalable object storage service. In this project, S3 stores the extracted and transformed files from the Adzuna API.</li><li><strong>AWS Glue </strong>is a serverless data integration service that makes it easier to discover, prepare, move, and integrate data from multiple sources. In this project, Glue Crawler is used to create metadata tables in the data catalog. Glue job transforms and cleans data to make it available for Athena.</li><li><strong>AWS Athena</strong> is a serverless, interactive query service that allows to analyze data in S3 using standard SQL. In this project, it creates tables and works as part of the Glue job.</li></ul><h3>Project Prerequisites</h3><p>You will need the following stuff to be able to follow along with this guide and accomplish the project:</p><ul><li>Python</li><li><a href="https://developer.adzuna.com/">Adzuna API account</a> (with application id and application key)</li><li>AWS Account</li></ul><h3>Data Source</h3><p>In this project, we query the <strong>Adzuna API</strong> to extract job listings specifically related to <em>Data Engineer</em> roles in Canada. The API is configured to get job posts in Canada that mention <em>data engineer</em> in the job title or description. Additionally, we limit the results to job listings posted within the last two days.</p><h3>Project Implementation Steps</h3><p>The project implementation can be broken down into the following major steps:</p><ol><li>Researching Adzuna API</li><li>Creating Amazon S3 bucket and folders</li><li>Developing Lambda function to extract data</li><li>Developing Glue job to transform data</li><li>Creating Glue Crawler for the staging table</li><li>Developing Glue job to process staging table</li><li>Creating EventBridge schedule and S3 events to automate ETL pipeline</li></ol><h3>Step 1. Researching Adzuna API</h3><p>We will use the <a href="https://developer.adzuna.com/">Adzuna API</a> to extract Data Engineering job data in Canada. The first step is to explore the API, understand its data structure, and identify the fields we need (e.g., job title, location, company). Tools like <strong>Jupyter Notebook</strong> or <strong>VS Code</strong> are useful for testing API calls and transforming data.</p><p>The goal is to connect to the API, pull sample data, and prepare it for the ETL pipeline. You can refer to this script <a href="https://github.com/kazarmax/adzuna_etl_aws/blob/main/adzuna_research.py">adzuna_research.py</a> from Maksim’s project repo for guidance.</p><h3>Step 2. Creating Amazon S3 bucket and folders</h3><p>We will need the following structure in Amazon S3 for the project:</p><pre>adzuna-etl-project:<br>   - raw_data<br>      - to_process<br>      - processed<br>   - transformed_data</pre><p><em>adzuna-etl-project</em> is a bucket. All the rest is the folders inside it.</p><p>To create a bucket, open <a href="https://console.aws.amazon.com/s3/">https://console.aws.amazon.com/s3/</a> and click <strong>Create bucket</strong> button. Use default settings.</p><p>Create the necessary folders inside the bucket using the <strong>Create folder</strong> button (you can use default settings).</p><h3>Step 3. Developing Lambda function to extract data</h3><p>AWS Lambda allows you to run your Python (and not only) scripts in AWS Cloud triggered by some event.</p><p>In this step, we will create a Lambda function that executes Python script to extract data from the Adzuna API and save it into S3 bucket in .json format.</p><p>The process of creating and configuring the lambda function includes the following activities:</p><ul><li>Creating IAM role for Lambda function</li><li>Creating a Lambda function</li><li>Configuring the Lambda function</li><li>Creating a layer to import the requests Python library into the Lambda function</li><li>Testing the Lambda function</li></ul><p>Please refer to Maksim’s <a href="https://medium.com/@kazarmax/from-api-to-dashboard-building-an-end-to-end-etl-pipeline-with-aws-3c1f4048676d">project</a> for more details and code for Lambda function.</p><h3>Step 4. Developing Glue job to transform data</h3><p>In this step, we will create AWS Glue job with Apache Spark to process and transform the raw JSON data, save it in <em>.parquet</em> files in the <em>adzuna-etl-project/transformed_data/ </em>s3 folder, and move processed JSON file to the specific s3 folder.</p><h4>4.1 AWS Glue role</h4><p>Firstly, you need to create an IAM role for AWS Glue job. Follow these steps to do that:</p><ol><li>Go to <a href="https://console.aws.amazon.com/iam/">https://console.aws.amazon.com/iam/</a></li><li>Under <strong>Access management</strong>, click <strong>Roles </strong>and then <strong>Create Role</strong></li><li>Select <strong>AWS Service</strong> as <strong>Trusted entity type</strong></li><li>Under <strong>Use case</strong>, select <strong>Glue</strong></li><li>Click <strong>Next</strong> to move to <strong>Step 2</strong></li><li>In Step 2 choose <em>AWSGlueServiceRole</em> and <em>AmazonAthenaFullAccess</em> policies</li><li>Enter a <strong>Name</strong>, for example, <em>AWSGlueCustomRole</em></li><li>Provide some meaningful description</li><li>Click <strong>Create role</strong>.</li></ol><p>In addition, Glue job needs access to the S3 bucket. Use the following policy JSON as a template to add access to the role that you’ve created recently for your project and adjust it as needed based on your s3 folder names:</p><pre>{<br>    &quot;Version&quot;: &quot;2012-10-17&quot;,<br>    &quot;Statement&quot;: [<br>        {<br>            &quot;Effect&quot;: &quot;Allow&quot;,<br>            &quot;Action&quot;: [<br>                &quot;s3:PutObject&quot;,<br>                &quot;s3:ListBucket&quot;,<br>                &quot;s3:GetObject&quot;,<br>                &quot;s3:PutObjectAcl&quot;,<br>                &quot;s3:DeleteObject&quot;<br>            ],<br>            &quot;Resource&quot;: [<br>                &quot;arn:aws:s3:::adzuna-etl-project&quot;,<br>                &quot;arn:aws:s3:::adzuna-etl-project/*&quot;<br>            ]<br>        }<br>    ]<br>}</pre><h4>4.2 AWS Glue job</h4><p>To create and configure an AWS Glue job, follow these steps:</p><ol><li>Go to <a href="https://console.aws.amazon.com/glue/">https://console.aws.amazon.com/glue/</a></li><li>In the left menu, under <em>AWS Glue</em>, click <em>ETL jobs</em></li><li>In the <em>Create job</em>, click <em>Script editor</em></li><li>In the <em>Engine</em> dropdown, select <em>Spark</em></li><li>In the <em>Options</em>, select <em>Start fresh </em>and click <em>Create script</em></li><li>Give it a name, for example, <em>adzuna-transform-spark-job</em></li><li>Switch to the <em>Job details</em> tab</li><li>In the <em>IAM role</em>, select the role you created earlier</li><li>In the <em>Language</em>, select <em>Python 3</em></li><li>In the <em>Requested number of workers</em>, put 2 (minimum allowed number of workers)</li><li>Switch to the Script tab and put the following code into the Script text area:</li></ol><pre>import boto3<br>import json<br>from pyspark.sql import SparkSession<br>from pyspark.sql.types import *<br>from pyspark.sql.functions import col, to_timestamp<br>from datetime import datetime<br><br># Initialize S3 client<br>s3 = boto3.client(&quot;s3&quot;)<br><br># Define paths<br>bucket_name = &quot;adzuna-etl-project&quot;<br>source_path = &quot;raw_data/to_process/&quot;<br>destination_path = &quot;transformed_data/&quot;<br>processed_path = &quot;raw_data/processed/&quot;<br><br># Create Spark session<br>spark = SparkSession.builder.appName(&quot;GlueJob&quot;).getOrCreate()<br><br># Define schema for the JSON data<br>schema = StructType([<br>    StructField(&quot;id&quot;, StringType(), True),<br>    StructField(&quot;title&quot;, StringType(), True),<br>    StructField(&quot;location&quot;, StructType([<br>        StructField(&quot;display_name&quot;, StringType(), True)<br>    ])),<br>    StructField(&quot;company&quot;, StructType([<br>        StructField(&quot;display_name&quot;, StringType(), True)<br>    ])),<br>    StructField(&quot;category&quot;, StructType([<br>        StructField(&quot;label&quot;, StringType(), True)<br>    ])),<br>    StructField(&quot;description&quot;, StringType(), True),<br>    StructField(&quot;redirect_url&quot;, StringType(), True),<br>    StructField(&quot;created&quot;, StringType(), True)<br>])<br><br># List files in source directory<br>response = s3.list_objects_v2(Bucket=bucket_name, Prefix=source_path)<br>if &quot;Contents&quot; in response:<br>    files = [obj[&quot;Key&quot;] for obj in response[&quot;Contents&quot;]]<br>else:<br>    print(&quot;No files found in the source path.&quot;)<br>    files = []<br><br># Process each file<br>for file_key in files:<br>    print(f&quot;Processing file: {file_key}&quot;)<br><br>    # Read JSON file with schema<br>    s3_path = f&quot;s3://{bucket_name}/{file_key}&quot;<br>    df = spark.read.schema(schema).json(s3_path)<br><br>    # Transform the data<br>    transformed_df = df.select(<br>        col(&quot;id&quot;).alias(&quot;job_id&quot;),<br>        col(&quot;title&quot;).alias(&quot;job_title&quot;),<br>        col(&quot;location.display_name&quot;).alias(&quot;job_location&quot;),<br>        col(&quot;company.display_name&quot;).alias(&quot;job_company&quot;),<br>        col(&quot;category.label&quot;).alias(&quot;job_category&quot;),<br>        col(&quot;description&quot;).alias(&quot;job_description&quot;),<br>        col(&quot;redirect_url&quot;).alias(&quot;job_url&quot;),<br>        to_timestamp(col(&quot;created&quot;)).alias(&quot;job_created&quot;)<br>    )<br><br>    # Get current date and timestamp for partitioning<br>    current_date = datetime.now().strftime(&quot;%Y-%m-%d&quot;)<br>    current_timestamp = datetime.now().strftime(&quot;%Y%m%d_%H%M%S&quot;)<br><br>    # Write to Parquet<br>    output_path = f&quot;s3://{bucket_name}/{destination_path}/dt={current_date}/adzuna_transformed_data_{current_timestamp}.parquet&quot;<br>    transformed_df.write.mode(&quot;overwrite&quot;).parquet(output_path)<br><br>    # Move processed file to the processed folder<br>    processed_file_key = file_key.replace(source_path, processed_path)<br>    s3.copy_object(<br>        Bucket=bucket_name,<br>        CopySource={&quot;Bucket&quot;: bucket_name, &quot;Key&quot;: file_key},<br>        Key=processed_file_key<br>    )<br>    s3.delete_object(Bucket=bucket_name, Key=file_key)<br>    print(f&quot;Moved file to processed: {processed_file_key}&quot;)<br><br># Stop Spark session<br>spark.stop()</pre><h3>Step 5. Create Glue Crawler</h3><p>We will use Crawler to create a table and then we can query data using Athena. We need to create IAM role with all required permissions for Crawler, then create Crawler and, eventually, make a Lambda function that can trigger Crawler when new data arrives into S3 bucket.</p><h4><strong>5.1 Creating IAM role for the Glue Crawler</strong></h4><p>For our Glue Crawler to access the required AWS resources, such as S3, we must create an IAM role with all the required policies and assign it to the function.</p><p>Follow these steps to do that:</p><ol><li>Go to <a href="https://console.aws.amazon.com/iam/">https://console.aws.amazon.com/iam/</a></li><li>Under <strong>Access management</strong>, click <strong>Roles </strong>and then <strong>Create Role</strong></li><li>Select <strong>AWS Service</strong> as <strong>Trusted entity type</strong></li><li>Under <strong>Use case</strong>, select <strong>Glue</strong></li><li>Click <strong>Next</strong> to move to <strong>Step 2</strong></li><li>In Step 2 choose <em>AmazonS3ReadOnlyAccess </em>and<em> AWSGlueServiceRole</em> policies</li><li>Enter a <strong>Name</strong>, for example, <em>GlueCrawlerRole</em></li><li>Provide some meaningful description</li><li>Click <strong>Create role</strong>.</li></ol><h4><strong>5.2 Creating IAM role for Lambda function</strong></h4><p>For our Lambda function to access the required AWS resources, such as execution Crawler, we must create an IAM role with all the required policies and assign it to the function.</p><p>Follow these steps to do that:</p><ol><li>Go to <a href="https://console.aws.amazon.com/iam/">https://console.aws.amazon.com/iam/</a></li><li>Under <strong>Access management</strong>, click <strong>Roles </strong>and then <strong>Create Role</strong></li><li>Select <strong>AWS Service</strong> as <strong>Trusted entity type</strong></li><li>Under <strong>Use case</strong>, select <strong>Lambda</strong></li><li>Click <strong>Next</strong> to move to <strong>Step 2</strong></li><li>In Step 2 choose <em>AWSGlueServiceRole </em>and<em> AWSLambdaBasicExecutionRole</em> policies</li><li>Enter a <strong>Name</strong>, for example, <em>LambdaCrawlerRole</em></li><li>Provide some meaningful description</li><li>Click <strong>Create role</strong>.</li></ol><h4><strong>5.3 Creating Glue Crawler</strong></h4><p>Create a Glue Crawler to parse a folder with parquet files and create a table. Follow these steps to do that:</p><ol><li>Go to AWS Console and choose Glue</li><li>Find Crawler in the left menu</li><li>Click <strong>Create crawler</strong></li><li>In Step 1 enter a <strong>Name</strong>, for example, <em>adzuna-tables-crawler</em></li><li>In Step 2 <strong>Add a data source</strong> and choose S3 path to the folder with parquet files</li><li>Set up <strong>Subsequent crawler runs</strong></li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/603/1*mPyPUotfAUpnM6XerEgcSA.png" /></figure><p>7. In Step 3 choose IAM role <em>GlueCrawlerRole </em>that we’ve created before</p><p>8. In Step 4 choose an existing Database or create a new one</p><p>9. Review and create a Crawler</p><h4><strong>5.4 Creating Lambda function to run Crawler</strong></h4><ol><li>Go to <a href="https://console.aws.amazon.com/lambda/">https://console.aws.amazon.com/lambda/</a></li><li>Click <strong>Create function</strong></li><li>Select <strong>Author from scratch</strong></li><li>Give it a <strong>Function name</strong>, for example, <em>trigger-glue-crawler</em></li><li>As a <strong>Runtime</strong>, select Python (I used Python 3.11 for the project)</li><li>Select <em>x86_64</em> as <strong>Architecture</strong></li><li>In the <strong>Execution role</strong>, select <strong>Use an existing role </strong>and select the role you’ve created in the previous step</li><li>Click <strong>Create function</strong></li></ol><h4><strong>5.5 Configuring the Lambda function</strong></h4><ol><li>In the <em>lambda_function</em> code text area, insert the following code:</li></ol><pre>import boto3<br>import logging<br><br># Initialize the Glue client<br>glue_client = boto3.client(&#39;glue&#39;)<br>logger = logging.getLogger()<br>logger.setLevel(logging.INFO)<br><br>def lambda_handler(event, context):<br>    # Specify your Glue Crawler name<br>    crawler_name = &#39;adzuna_tables_crawler&#39;<br><br>    # Start the Glue Crawler<br>    try:<br>        response = glue_client.start_crawler(Name=crawler_name)<br>        logger.info(f&quot;Glue Crawler {crawler_name} started successfully.&quot;)<br>    except Exception as e:<br>        logger.error(f&quot;Error starting Glue Crawler: {str(e)}&quot;)<br><br>    return {<br>        &#39;statusCode&#39;: 200,<br>        &#39;body&#39;: &#39;Glue Crawler triggered successfully&#39;<br>    }</pre><p>2. Click <strong>Deploy</strong> to save changes.</p><p>3. Click the <strong>Configuration</strong> tab and in the <strong>General configuration</strong> menu, click <strong>Edit</strong></p><p>4. Change the <strong>Timeout</strong> to 30 seconds.</p><h4><strong>5.6 Creating a trigger in the S3 bucket</strong></h4><ol><li>Go to your existing bucket</li><li>Choose <strong>Properties</strong> menu</li><li>Navigate to <strong>Event notifications</strong></li><li>Click <strong>Create event notification</strong></li><li>Enter <strong>Event name</strong>, for example, <em>NewFileNotification</em></li><li>As a <strong>Prefix</strong> enter a path to the folder with parquet files <em>transformed_data/</em></li><li>Choose <em>Put</em>, <em>Post</em>, and <em>Copy</em> in the <strong>Object creation</strong> menu as an <strong>Event type</strong></li><li>In the <strong>Destination</strong> choose <strong>Lambda function</strong> and specify <em>TriggerGlueCrawler</em></li><li>Click <strong>Save changes</strong></li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iBEFLEbGsdeVivM4qamtRg.png" /><figcaption>S3 bucket event notifications</figcaption></figure><p>Now when you run a Glue job for transformation, it creates a parquet file and this new object will trigger a Lambda function that runs a Crawler. At first run Crawler will create a new table, then it will add new data to the existing table.</p><h4><strong>5.7 Athena table</strong></h4><p>We have another option how to create and update a table with transformed data. We can use Athena table with partition projection. It automatically read partitions and append new data to the table.</p><p>Go to <a href="https://console.aws.amazon.com/lambda/">https://console.aws.amazon.com/athena/</a> and paste in the editor this SQL query:</p><pre>CREATE EXTERNAL TABLE staging__jobs (<br>    job_id STRING,<br>    job_title STRING,<br>    job_location STRING,<br>    job_company STRING,<br>    job_category STRING,<br>    job_description STRING,<br>    job_url STRING,<br>    job_created TIMESTAMP<br>)<br>PARTITIONED BY (dt DATE)<br>ROW FORMAT SERDE &#39;org.apache.hadoop.hive.ql.io.parquet.serde.ParquetHiveSerDe&#39;<br>STORED AS PARQUET<br>LOCATION &#39;s3://adzuna-etl-project/transformed_data/&#39;<br>TBLPROPERTIES (<br>  &#39;projection.enabled&#39;=&#39;true&#39;, <br>  &#39;projection.dt.format&#39;=&#39;yyyy-MM-dd&#39;, <br>  &#39;projection.dt.interval&#39;=&#39;1&#39;, <br>  &#39;projection.dt.interval.unit&#39;=&#39;DAYS&#39;, <br>  &#39;projection.dt.range&#39;=&#39;2024-09-01,NOW&#39;, <br>  &#39;projection.dt.type&#39;=&#39;date&#39;)</pre><p>Now you don’t need to use Glue Crawler, you just need to run Glue job for transformation and Athena table appends new partition to the table.</p><h3>Step 6. Developing Glue job to process staging table</h3><p>In this step, we will create AWS Glue job with Python shell to clean staging data and create a final table. We’ve already created IAM role on step 4 so we can use it for this job.</p><p>We are going to use “UNLOAD” function to store the output of the Athena query as a <em>.parquet</em> file in the s3 folder. We need to create a final table with partition projection in Athena:</p><pre>CREATE EXTERNAL TABLE marts__jobs (<br>    job_id STRING,<br>    job_title STRING,<br>    job_location STRING,<br>    job_company STRING,<br>    job_category STRING,<br>    job_description STRING,<br>    job_url STRING,<br>    job_created TIMESTAMP  -- Correct schema<br>)<br>PARTITIONED BY (dt DATE)<br>ROW FORMAT SERDE &#39;org.apache.hadoop.hive.ql.io.parquet.serde.ParquetHiveSerDe&#39;<br>STORED AS PARQUET<br>LOCATION &#39;s3://adzuna-etl-project/marts/&#39;<br>TBLPROPERTIES (<br>  &#39;projection.enabled&#39;=&#39;true&#39;, <br>  &#39;projection.dt.format&#39;=&#39;yyyy-MM-dd&#39;, <br>  &#39;projection.dt.interval&#39;=&#39;1&#39;, <br>  &#39;projection.dt.interval.unit&#39;=&#39;DAYS&#39;, <br>  &#39;projection.dt.range&#39;=&#39;2024-09-01,NOW&#39;, <br>  &#39;projection.dt.type&#39;=&#39;date&#39;)</pre><p>To create and configure an AWS Glue job, follow these steps:</p><ol><li>Go to <a href="https://console.aws.amazon.com/glue/">https://console.aws.amazon.com/glue/</a></li><li>In the left menu, under <em>AWS Glue</em>, click <em>ETL jobs</em></li><li>In the <em>Create job</em>, click <em>Script editor</em></li><li>In the <em>Engine</em> dropdown, select <em>Python shell</em></li><li>In the <em>Options</em>, select <em>Start fresh </em>and click <em>Create script</em></li><li>Give it a name, for example, <em>adzuna-unload-job</em></li><li>Switch to the <em>Job details</em> tab</li><li>In the <em>IAM role</em>, select the role you created earlier</li><li>Switch to the Script tab and put the following code into the Script text area:</li></ol><pre>import boto3<br>import datetime<br>import time<br><br># Initialize clients and resources<br>s3_client = boto3.client(&#39;s3&#39;, &#39;us-east-1&#39;)<br>athena = boto3.client(&#39;athena&#39;, &#39;us-east-1&#39;)<br>s3 = boto3.resource(&#39;s3&#39;, &#39;us-east-1&#39;)<br><br>query_template = &quot;&quot;&quot;UNLOAD (<br><br>SELECT stj.*    <br>FROM adzuna.staging__jobs stj<br>LEFT JOIN adzuna.marts__jobs mrt ON stj.job_id = mrt.job_id<br>WHERE mrt.job_id IS NULL<br><br>)<br>TO &#39;s3://{bucket}/{prefix}&#39;<br>WITH (format = &#39;PARQUET&#39;, compression = &#39;GZIP&#39;)&quot;&quot;&quot;<br><br># Execute Athena query<br>def run_query(query):<br>    response = athena.start_query_execution(<br>        QueryString=query,<br>        QueryExecutionContext={&#39;Database&#39;: &#39;adzuna&#39;},<br>        ResultConfiguration={&#39;OutputLocation&#39;: athena_result_bucket}<br>    )<br>    return response<br><br># Monitor the status of the query execution<br>def monitor_query(query_execution_id):<br>    while True:<br>        status = athena.get_query_execution(QueryExecutionId=query_execution_id)<br>        state = status[&#39;QueryExecution&#39;][&#39;Status&#39;][&#39;State&#39;]<br>        if state in [&#39;SUCCEEDED&#39;, &#39;FAILED&#39;, &#39;CANCELLED&#39;]:<br>            return state<br>        print(f&#39;Query is still running... Waiting for completion...&#39;)<br>        time.sleep(45)  # Wait for 45 seconds before checking the status again<br><br># Manually define the variables before running the job<br>target_bucket_name = &#39;adzuna-etl-project&#39;<br>athena_result_bucket = &#39;s3://adzuna-etl-project/athena_query_output/&#39;<br><br>current_date = datetime.now().strftime(&quot;%Y-%m-%d&quot;)<br><br>target_bucket = s3.Bucket(target_bucket_name)<br><br># Process each date and hour range<br>target_prefix = f&quot;marts/dt={current_date}&quot;<br>        <br># Run the query <br>query = query_template.format(bucket=target_bucket_name, prefix=target_prefix)<br>response = run_query(query)<br>query_execution_id = response[&#39;QueryExecutionId&#39;]<br>        <br># Monitor the query execution<br>print(f&#39;Starting query for date {current_date}...&#39;)<br>query_status = monitor_query(query_execution_id)<br><br>if query_status == &#39;SUCCEEDED&#39;:<br>    print(f&#39;Query for date {current_date} completed successfully&#39;)<br>else:<br>    print(f&#39;Query for date {current_date} failed with status {query_status}&#39;)</pre><h3>Step 7. Creating schedule and triggers to automate ETL pipeline</h3><p>At this point, when the ETL pipeline is implemented, tested and works as expected, it’s time to schedule it for automatic execution.</p><p>For this purpose, we will create an EventBridge schedule and S3 events.</p><h4><strong>7.1 EventBridge schedule</strong></h4><p>Follow these steps:</p><ol><li>Go to <a href="https://console.aws.amazon.com/glue/">https://console.aws.amazon.com/events/</a></li><li>In the left menu click <strong>Rules</strong>, then click <strong>Create rule </strong>button</li><li>Fill in the rule <strong>Name</strong>, for example, <em>adzuna-etl-run-daily</em></li><li>Fill in the <strong>Rule description</strong>, for example, <em>Schedule to run Adzuna ETL daily</em></li><li>In the <strong>Rule type</strong>, select <strong>Schedule </strong>and then click <strong>Continue in EventBridge Scheduler</strong></li><li>Under <strong>Schedule pattern</strong>, select <strong>Recurring schedule</strong></li><li>Select the right <strong>Time zone</strong> for you</li><li>Under <strong>Schedule type</strong>, select <strong>Cron-based schedule </strong>and type in the following cron expression: <strong><em>cron(0 0 * * ? *)</em></strong></li><li>In the <strong>Flexible time window</strong>, select <strong>Off</strong></li><li>Click <strong>Next</strong></li><li>Under <strong>Target detail</strong>, select <strong>Templated targets</strong>, and then select <strong>AWS Lambda</strong></li><li>Under <strong>Invoke</strong>, in the <strong>Lambda function</strong> dropdown, select <br><em>lambda_adzuna_extract_data</em> and click <strong>Next</strong></li><li>In the <strong>Action after schedule completion</strong>, select <strong>NONE</strong></li><li>Optionally, in the <strong>Retry policy</strong>, set the <strong>Maximum age of event</strong> to 5 minutes and <strong>Retry attempts</strong> to 3 times</li><li>Click <strong>Next</strong></li><li>Click <strong>Create schedule</strong></li></ol><p>Now, the ETL pipeline will be triggered every day at 00:00 UTC.</p><h4>7.2 S3 events</h4><p>As you remember, we have an event notification within S3 bucket that invokes Lambda funtion for Glue Crawler. Event notification is not able to invoke Glue job so we need to create two new Lambda functions to invoke Glue jobs.</p><p>Another option here is Step function. Please refer to Maksim’s project to implement it.</p><p>We’ve already created IAM role for Lambda to run Glue Crawler, so we are going to use it for new functions. Follow these steps to create the first one:</p><ol><li>Go to <a href="https://console.aws.amazon.com/lambda/">https://console.aws.amazon.com/lambda/</a></li><li>Click <strong>Create function</strong></li><li>Select <strong>Author from scratch</strong></li><li>Give it a <strong>Function name</strong>, for example, t<em>rigger-glue-transform-job</em></li><li>As a <strong>Runtime</strong>, select Python (I used Python 3.11 for the project)</li><li>Select <em>x86_64</em> as <strong>Architecture</strong></li><li>In the <strong>Execution role</strong>, select <strong>Use an existing role </strong>and select the role you’ve created in the previous step</li><li>Click <strong>Create function</strong></li><li>In the <em>lambda_function</em> code text area, insert the following code:</li></ol><pre>import boto3<br>import logging<br><br># Initialize the Glue client<br>glue_client = boto3.client(&#39;glue&#39;)<br><br>def lambda_handler(event, context):<br>    # Set up logging<br>    logger = logging.getLogger()<br>    logger.setLevel(logging.INFO)<br>    <br>    try:<br>        # Name of the Glue job to trigger<br>        job_name = &#39;adzuna-transform-spark-job&#39;<br>        <br>        # Trigger the Glue job<br>        response = glue_client.start_job_run(JobName=job_name)<br>        <br>        # Log the JobRunId returned by Glue<br>        logger.info(f&quot;Successfully triggered Glue job &#39;{job_name}&#39;. JobRunId: {response[&#39;JobRunId&#39;]}&quot;)<br>        <br>        return {<br>            &#39;statusCode&#39;: 200,<br>            &#39;body&#39;: f&quot;Successfully triggered Glue job &#39;{job_name}&#39; with JobRunId: {response[&#39;JobRunId&#39;]}&quot;<br>        }<br>    <br>    except Exception as e:<br>        logger.error(f&quot;Error triggering Glue job: {str(e)}&quot;)<br>        return {<br>            &#39;statusCode&#39;: 500,<br>            &#39;body&#39;: f&quot;Error triggering Glue job: {str(e)}&quot;<br>        }</pre><p>10. Click <strong>Deploy</strong> to save changes.</p><p>11. Click the <strong>Configuration</strong> tab and in the <strong>General configuration</strong> menu, click <strong>Edit</strong></p><p>12. Change the <strong>Timeout</strong> to 30 seconds.</p><p>13. Create S3 event notification as we did on the step 5.6 and choose Lambda function.</p><p>14. The same we need to do in order to create another Lambda function and S3 event notification to trigger <em>adzuna-unload-job </em>(from Step 6).</p><h3>Conclusion</h3><p>In this project, we demonstrated how to build a fully automated, end-to-end ETL pipeline using AWS cloud services.</p><p>We began by retrieving job listings for Data Engineering roles in Canada from the Adzuna API, storing the raw data in Amazon S3. Next, we cleaned and transformed the data using AWS Glue and Apache Spark, and made it accessible for analysis in Athena.</p><p>By completing these steps, you now have a robust and scalable ETL pipeline that can be adapted to a wide range of use cases. This project highlights how AWS services seamlessly integrate to automate data workflows and deliver real-time insights, from data collection to visualization.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=eca258c3a724" width="1" height="1" alt=""><hr><p><a href="https://medium.com/rock-your-data/designing-a-complete-etl-pipeline-workflow-with-aws-eca258c3a724">Designing a Complete ETL Pipeline Workflow with AWS</a> was originally published in <a href="https://medium.com/rock-your-data">Rock Your Data</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Elementary data for observability within dbt project]]></title>
            <link>https://medium.com/rock-your-data/elementary-data-for-observability-within-dbt-project-54e3cf0b4069?source=rss-2942ff4c5b20------2</link>
            <guid isPermaLink="false">https://medium.com/p/54e3cf0b4069</guid>
            <category><![CDATA[dbt]]></category>
            <category><![CDATA[analytics-engineering]]></category>
            <category><![CDATA[elementary]]></category>
            <dc:creator><![CDATA[Tsebek Badmaev]]></dc:creator>
            <pubDate>Tue, 26 Mar 2024 20:51:45 GMT</pubDate>
            <atom:updated>2024-03-26T20:51:45.223Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ijY9ONMIfUdHoITEZKRJTw.jpeg" /></figure><p>One of the greatest features of dbt is the availability of a vast number of external packages and how easily you can integrate them into your project. Elementary is one of those packages and it helps to implement data observability and alerting.</p><p>Let’s start with a brief overview of the observability. <a href="https://www.youtube.com/watch?v=jfg9wBJBtKk">Here</a> is a great YouTube video that reveals the definition and key concepts. Observability is crucial for understanding the health and performance of data systems and it involves:</p><ul><li>Monitoring</li><li>Tracking</li><li>Analyzing data</li></ul><h3>dbt project initialization</h3><p>Since Elementary is a dbt package, we should start by initializing the dbt project. It’s great if you already have one. Project initialization begins with Python virtual environment installation. You can find many guides on how to set up dbt project. We won’t stop at this point, as this is not the focus of our article. I just want to point out that you need to add some models and tests to get data in the Elementary report.</p><h3>Elementary installation</h3><p>Elementary has two versions — cloud and open source. We choose the open source (OSS) version. <a href="https://docs.elementary-data.com/oss/oss-introduction">Here</a> is a great step-by-step guide from the official website with text descriptions and videos.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Nw5FqRZTre-yNDoVwszytQ.png" /><figcaption>Screenshot from the Elementary official website</figcaption></figure><h4><strong>The first part</strong> is the Elementary dbt package installation.</h4><ol><li>Add elementary to <strong>packages.yml</strong>. I’ve already had some packages so just added the following:</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/656/1*P8gE4_rMaD7nyt-eMaJSHA.png" /></figure><p>2. Add to your <strong>dbt_project.yml</strong> Elementary model. This means Elementary models will have their own schema:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*O80TtQyLxAUkji1Xu9MLzg.png" /></figure><p>3. Import the package and build Elementary models using the following commands:</p><pre>#install needed dependencies<br>dbt deps <br>#run dbt models <br>dbt run</pre><p>4. Validate the installation by running some tests</p><pre>#run dbt tests<br>dbt test</pre><p>After the tests are finished we can check the results in the Elementary table</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XV5WX0VV4E31yBIugl3hUg.png" /></figure><h4><strong>The second part</strong> is Elementary CLI installation.</h4><p>In order to connect, Elementary needs a connection profile in a file named <strong>profiles.yml</strong>. Elementary can generate the profile by running the following command:</p><pre>dbt run-operation elementary.generate_elementary_cli_profile</pre><p>Copy the output, and add the profile to your <strong>profiles.yml</strong>, but don’t forget to use Environment Variables for sensitive information like your account, username, and password.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/890/1*MBMuVcmdafQGL-mNqjo1cA.png" /></figure><p>We can set Environment Variables once for the duration of your CLI session</p><pre># set environment variables once for MacOS<br>export SNOWFLAKE_ACCOUNT=your_account<br>export SNOWFLAKE_USER=your_user<br>export SNOWFLAKE_PASSWORD=your_password</pre><p>Or we can automate the Environment Variable setup. For MacOS follow these steps:</p><ul><li>Navigate to your virtual environment’s directory. Inside, you’ll find a <strong>bin</strong> directory that contains scripts that are run when the virtual environment is activated or deactivated.</li><li>Find the <strong>activate</strong> script within the <strong>bin</strong> directory. This script is executed whenever you activate your virtual environment.</li><li>Edit the <strong>activate</strong> script to include the export commands above for your environment variables at the end of the file.</li></ul><p>To install the <strong>monitor module</strong> run:</p><pre># install monitor module<br>pip install elementary-data<br># based on your platform run one of the following commands (no need to run all)<br>pip install &#39;elementary-data[snowflake]&#39;<br>pip install &#39;elementary-data[bigquery]&#39;<br>pip install &#39;elementary-data[redshift]&#39;<br>pip install &#39;elementary-data[databricks]&#39;<br>pip install &#39;elementary-data[athena]&#39;<br>## Postgres doesn&#39;t require this step</pre><p>Run command <strong>edr --help</strong> in the terminal to ensure the installation was successful. You should get this message:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-xa754OUldEmUxp_4SllVg.png" /></figure><h3>Elementary observability report generation</h3><p>Now we can generate the report that can be used for visualization and exploration of data from the dbt-package tables. That includes dbt test results, Elementary anomaly detection results, dbt artifacts, test runs, etc.</p><p>Run the following command to generate the report as an HTML file:</p><pre>edr report</pre><h3>Observability report overview</h3><p>Let’s discover the following features in the report:</p><ul><li>The main page with dashboard — it’s data health review with charts that show the number of tests, their execution, failures, and anomalies</li><li>Lineage of the dbt project</li><li>Test execution history where we could see every test execution in detail and could find frequently failing tests</li><li>Model duration which shows the time execution of each model in the dbt project and allows to see failures, and detect bottlenecks</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ha9JWEqx87Ex6dfe31CVsQ.png" /></figure><h3>Comparison of Open source version with Cloud version</h3><p>Cloud version set up is very similar to the OSS version. You need to install Elementary dbt package, but instead of Elementary CLI installation, you need to create an account and connect your data warehouse.</p><p>Additional features in the cloud version:</p><ul><li>Catalog which is the data catalog of a dataset and shows table description, columns information, dependencies, and SQL query (typically stored in the <em>target</em> path of the dbt project)</li><li>Test configuration that allows the creation of different types of tests</li><li>Alerts and rules are allowed to create alerts in the UI</li></ul><p>There are 3 types of tests in the test configuration:</p><ul><li>Table tests: Freshness, Volume, Schema changes</li><li>Column tests: Unique, Not null, Accepted values, Relationship</li><li>Custom query test</li></ul><h3>Conclusion</h3><p>During our weekly Surfalytics session, we discussed about Elementary (OSS and Cloud), and dbt Cloud.</p><p>Elementary cloud version has some additional features, but they can be covered with open source products:</p><ul><li>Catalog can be replaced with dbt docs. The Catalog in Elementary doesn’t allow you to edit description so this is the biggest cons</li><li>Tests are very similar to dbt built-in tests (especially column tests) and you can use SODA or Great Expectations</li><li>Alerts and rules you can set up for OSS version, but not in UI</li></ul><p>The price for Elementary cloud version is higher than dbt Cloud so it’s better to use dbt Cloud where you can use catalog, lineage, observe tests, and create alerts. In addition, dbt Cloud can be used as an orchestration tool.</p><p>In terms of time and cost the best choice is dbt Cloud. If you want to reduce costs or can’t use the cloud (or maybe you are a big fan of the open source solutions) then you can build the project using all open-source products.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=54e3cf0b4069" width="1" height="1" alt=""><hr><p><a href="https://medium.com/rock-your-data/elementary-data-for-observability-within-dbt-project-54e3cf0b4069">Elementary data for observability within dbt project</a> was originally published in <a href="https://medium.com/rock-your-data">Rock Your Data</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building an ETL Pipeline: From S3 to Tableau via AWS Glue and Athena]]></title>
            <link>https://medium.com/@badmaev.t/building-an-etl-pipeline-from-s3-to-tableau-via-aws-glue-and-athena-76816e683450?source=rss-2942ff4c5b20------2</link>
            <guid isPermaLink="false">https://medium.com/p/76816e683450</guid>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[tableau]]></category>
            <category><![CDATA[etl]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[pipeline]]></category>
            <dc:creator><![CDATA[Tsebek Badmaev]]></dc:creator>
            <pubDate>Sun, 11 Feb 2024 15:55:29 GMT</pubDate>
            <atom:updated>2024-02-11T15:55:29.788Z</atom:updated>
            <content:encoded><![CDATA[<p>Building a data pipeline can be a complex task and might be resolved in different ways. This guide walks you through the process of storing data in an <strong>S3</strong> bucket, creating an ETL pipeline with <strong>AWS Glue</strong>, querying data using <strong>Athena</strong>, and finally visualizing it in <strong>Tableau</strong>.</p><h3>You’ll learn how to:</h3><ul><li>Create an <strong>IAM</strong> user in AWS</li><li>Load data into an <strong>S3</strong> bucket</li><li>Process data with <strong>AWS Glue</strong></li><li>Perform queries using <strong>Athena</strong></li><li>Connect <strong>Tableau</strong> to <strong>Athena</strong> for data visualization</li></ul><h3>Overview of the architecture</h3><ul><li><strong>IAM:</strong> AWS Identity and Access Management (IAM) secures access to AWS services, ensuring that only authorized users and processes can access the data pipeline components</li><li><strong>S3:</strong> Amazon S3 is a scalable storage solution for raw and processed data, offering high durability and availability</li><li><strong>AWS Glue &amp; Crawler:</strong> AWS Glue automates data preparation for analysis, with the Glue Crawler automating schema discovery and metadata cataloging in the Glue Data Catalog</li><li><strong>Athena:</strong> A serverless query service, Athena allows SQL querying directly on data in S3, integrated with the Glue Data Catalog for seamless data analysis</li><li><strong>Tableau:</strong> A visualization tool that connects to various sources for interactive data analysis and dashboard creation, transforming</li></ul><p>Here’s the diagram which shows the workflow of the project we’re going to build:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ic9joIFb-jby3oFPTqR8BQ.png" /></figure><h3>Step 1: Creating an IAM user</h3><p>To start, log into your AWS account, navigate to the IAM dashboard, and create a new user, “<strong>surf-dev”</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xbY_VJLOUMFp1GnVizLZWQ.png" /></figure><p>Assign this user permissions for S3, Glue, and Athena by attaching the necessary policies. This step ensures that your pipeline is both efficient and secure. Log in as IAM user into your AWS account.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SR7W6_o6jPtsrpCIP5yKTw.png" /></figure><h3>Step 2: Setting up S3 buckets</h3><p>Choose a region close to your primary users to minimize latency and create a new bucket named “<strong>restaurant-orders”</strong>.</p><blockquote>I set <strong>us-west-2</strong> since that region is closest to my location. Choosing the closest region to the location where you deploy your resources is highly recommended.</blockquote><p>Inside this bucket, create folders for raw data and processed data marts. Upload your data, such as CSV files, into the “<strong>raw”</strong> folder. This folder structure helps in data management and processing.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*g60PEgb42IDxXqGuMhqnkQ.png" /></figure><p>In this project, we’ll use a dataset with restaurant orders (<em>you can download it </em><a href="https://mavenanalytics.io/data-playground?accessType=open&amp;tags=NXBNqbCUPNOBzgZYNeH6x"><em>here</em></a>). We have two CSV files in the dataset and need to load them into the “<strong>raw”</strong> folder.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*e9JiIQ_R8-42CrUx157cCw.png" /></figure><h3>Step 3: Building ETL with AWS Glue</h3><p>Navigate to the AWS Glue console and start a new Visual ETL. Here we’re able to create an ETL pipeline: select your source to ingest data, apply transformations, and upload the result.</p><p>Select your data source from S3 and specify the path and data format. We have CSV files with the delimiter “Comma (,)”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wfmbq96XRAjJE3TMwinHug.png" /></figure><p>Then perform some transformations. For instance, you might change the schema to ensure that the date and time fields are correctly formatted.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7JabtcLFlMxhvVmNL3SNRg.png" /></figure><p>Join operations can be performed to combine data from different sources, such as order details and menu items. Add a new transformation “Join”, and specify the join type and condition for this action.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*l88sKVWqNa4DPX78l0SEDA.png" /></figure><p>This join operation will return all fields from both tables, so we might drop the duplicate field <strong>“menu_item_id”</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AWqE-O4YZgklkd2Sca7hYQ.png" /></figure><p>Eventually, we should select a target destination for our final table. In <strong>“Targets”</strong> we can choose <strong>“Amazon S3”</strong> and specify a format, compression type, and location. In the <strong>“S3 Target Location”</strong> field select folder <strong>“marts”</strong> into the S3 bucket.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*i5y0AwTIHDuUBoyv5tuH7Q.png" /></figure><p>Once you’ve configured your job, assign it a name, such as <strong>“Restaurant Orders”</strong> and then click <strong>“Save”.</strong> In the <strong>“Job Details”</strong> section, you’ll notice a requirement for an IAM role. Since we haven’t specified any roles yet, we’ll need to create one. This step ensures that AWS Glue has the necessary permissions to execute your ETL job securely and efficiently.</p><p>Navigate to the AWS Management Console as the root user and select the IAM service to create a new role named <strong>“glue_access_s3”</strong>. To avoid interrupting your ETL setup, consider opening AWS in a separate browser tab. For this role, you will need to attach the necessary permission policies, ensuring that AWS Glue has the appropriate access to manage resources and execute tasks within your S3 bucket.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GSmA1wp_JsHWHdGokKJS0g.png" /></figure><p>Next, navigate back to your AWS Glue ETL job setup and select the <strong>“glue_access_s3”</strong> role. Keep all other ETL job parameters at their default values, save your job, and then click “Run” to initiate the process.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HpyKu_WWsb1cu7YDbbqzuw.png" /></figure><p>Upon successful completion of the job, it’s time to create a database and populate tables using the Glue Crawler. The Crawler generates metadata, enabling AWS Glue and services like Athena to view information stored in S3 as a structured database with tables.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4Z3_aIGdJAuHNcggsI-JyA.png" /></figure><p>Create a new crawler named <strong>“surf-rest-orders”</strong>. Choose your S3 bucket and the <strong>“marts”</strong> folder within it as the data source. Next, select the existing IAM role <strong>“glue_access_s3”</strong> for the crawler.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Wk1Wdr6E__eBb85VCtcIHw.png" /></figure><p>At step 4, you’re prompted to specify an output target. Without an existing database, you’ll need to create one. Open the <strong>”Databases”</strong> menu in a new window and establish a database named <strong>”restaurant”</strong>. Return to the crawler setup, select your new database at step 4, then finalize by clicking <strong>“Create Crawler”</strong> and running it.</p><p>After the crawler completes its run, you can visit the database to view your newly created table, ready for analysis and integration into your data processing workflow.</p><h3>Step 4: Querying data using Athena</h3><p>With your data processed and stored in S3, AWS Athena allows you to run SQL queries directly against this data. Before querying, set up an <strong>“athena_output”</strong> folder in S3 for query results. Within the <strong>“Settings”</strong> menu of Athena, specify this folder as the destination for your query outputs. Athena is serverless, so you can start querying your data immediately without the need for database setup or management.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KtcCmBadV6NDbOZYAD-4zQ.png" /></figure><h3>Step 5: Connecting to Tableau</h3><p>The final step is to visualize your data in Tableau, a powerful tool for creating interactive data visualizations. To establish a connection between Tableau and Athena, it’s essential to first install the JDBC driver (<a href="https://docs.aws.amazon.com/athena/latest/ug/jdbc-v2.html">AWS guideline</a>). Additionally, you will require specific credentials, including the server name, the S3 directory where your data resides, and an access key.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/506/1*ewIr_ZjQ7gJIVgzxlroZMA.png" /></figure><p>Create an access key for your IAM user <strong>“surf-dev”</strong> and use these credentials in Tableau to establish a connection. Once connected, you can create dashboards and reports based on your Athena queries, providing valuable insights into your data.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9dz_j8y_cymelTKBJ3cZjw.png" /></figure><p>With the Tableau connection to the Athena service established and our table visible, we are now equipped to develop dashboards.</p><h3>Conclusion</h3><p>This project demonstrates the power of AWS services in building an ETL pipeline and using Tableau for data visualization. While the dataset used here is simple, the principles and techniques apply to more complex data analytics needs. Through this guide, you’ve learned how to set up and manage an ETL pipeline that is scalable, secure, and efficient.</p><p>Thanks for reading!</p><p><em>Follow me on LinkedIn — </em><a href="https://www.linkedin.com/in/tsebek-badmaev/*"><em>https://www.linkedin.com/in/tsebek-badmaev/</em></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=76816e683450" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>