Practicing ETL implementation using S3, AWS Glue, and Pyspark
- Open the S3 console and create a bucket
- Create a folder named "input" inside the S3 bucket.
- Create a folder named "output" inside the S3 bucket to store the transformed data.
- Upload the data present inside /Data folder in this repository into the "s3://bucket-name/input" folder created in Step 1
- Got to AWS Glue Service console page.
- Click on Crawlers, add crawler button.
- Give your crawler a name and click next
- Specify crawler source type as datastore and check the crawl all the folders radio button.
- Select S3 as Data Store and Select input folder as the crawler target from s3 (s3://bucket-name/input)
- Click on No, to add another datastore and click next.
- Choose to create an IAM role (if you don't have one present for existing crawlers), Name it, and click next.
- Select "Run on demand" as a schedule for your crawler and hit next.
- Click on Add Database option (in case you don't have any databases present to store the schema of the table crawled from s3).
- Give your database a name and click next.
- Review your choices and click on finish.
- Go to Crawlers in the AWS Glue Console Page and select the crawler you created in Step 3.
- Click on Actions and select the Run Crawler option.
- Once your crawler is run successfully, you will be able to see the table metadata schema under (Databases > Tables > input)
- Now click on Glue job and add job option
- Configure Job properties like name, IAM role, and under Job Parameters change the worker node to 2, click next.
- Choose the existing data catalog that we crawled in Step 4 as a data source, click next.
- Choose Transformation as Change Schema (which we will overwrite with our use case.)
- Choose data target as same input data catalog table we crawled, click next.
- Click on save the job and Edit the script.
- Copy and paste the contents of the /PySpark Scripts/GlueScript.py file to the script shown on the screen.
- This script is applying a simple transformation just for learning and testing purposes, you can write more complex transformations according to your use case.
- If you get lost on the page just follow => (select the glue job > actions > edit script)
- Click on the save button to save your change in the script.
- Click on Run Job.
- Once your Job is run successfully, you will be able to see the partition stored inside your output folder inside your s3 bucket created in Step 1.
- If your job is stuck at some error, please check failure logs (AWS Glue console > select the job > History > ErrorLogs) in AWS CloudWatch.